policy.sgml 440 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196
  1. <!doctype debiandoc system [
  2. <!-- include version information so we don't have to hard code it
  3. within the document -->
  4. <!entity % versiondata SYSTEM "version.ent"> %versiondata;
  5. <!-- current Debian changes file format -->
  6. <!entity changesversion "1.8">
  7. ]>
  8. <debiandoc>
  9. <book>
  10. <titlepag>
  11. <title>Debian Policy Manual</title>
  12. <author><qref id="authors">The Debian Policy Mailing List</qref></author>
  13. <version>version &version;, &date;</version>
  14. <abstract>
  15. This manual describes the policy requirements for the Debian
  16. distribution. This includes the structure and
  17. contents of the Debian archive and several design issues of
  18. the operating system, as well as technical requirements that
  19. each package must satisfy to be included in the distribution.
  20. </abstract>
  21. <copyright>
  22. <copyrightsummary>
  23. Copyright &copy; 1996,1997,1998 Ian Jackson
  24. and Christian Schwarz.
  25. </copyrightsummary>
  26. <p>
  27. These are the copyright dates of the original Policy manual.
  28. Since then, this manual has been updated by many others. No
  29. comprehensive collection of copyright notices for subsequent
  30. work exists.
  31. </p>
  32. <p>
  33. This manual is free software; you may redistribute it and/or
  34. modify it under the terms of the GNU General Public License
  35. as published by the Free Software Foundation; either version
  36. 2, or (at your option) any later version.
  37. </p>
  38. <p>
  39. This is distributed in the hope that it will be useful, but
  40. <em>without any warranty</em>; without even the implied
  41. warranty of merchantability or fitness for a particular
  42. purpose. See the GNU General Public License for more
  43. details.
  44. </p>
  45. <p>
  46. A copy of the GNU General Public License is available as
  47. <file>/usr/share/common-licenses/GPL</file> in the Debian
  48. distribution or on the World Wide Web at
  49. <url id="http://www.gnu.org/copyleft/gpl.html"
  50. name="the GNU General Public Licence">. You can also
  51. obtain it by writing to the Free Software Foundation, Inc.,
  52. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  53. </p>
  54. </copyright>
  55. </titlepag>
  56. <toc detail="sect1">
  57. <chapt id="scope">
  58. <heading>About this manual</heading>
  59. <sect>
  60. <heading>Scope</heading>
  61. <p>
  62. This manual describes the policy requirements for the Debian
  63. distribution. This includes the structure and
  64. contents of the Debian archive and several design issues of the
  65. operating system, as well as technical requirements that
  66. each package must satisfy to be included in the
  67. distribution.
  68. </p>
  69. <p>
  70. This manual also describes Debian policy as it relates to
  71. creating Debian packages. It is not a tutorial on how to build
  72. packages, nor is it exhaustive where it comes to describing
  73. the behavior of the packaging system. Instead, this manual
  74. attempts to define the interface to the package management
  75. system that the developers have to be conversant with.<footnote>
  76. Informally, the criteria used for inclusion is that the
  77. material meet one of the following requirements:
  78. <taglist compact="compact">
  79. <tag>Standard interfaces</tag>
  80. <item>
  81. The material presented represents an interface to
  82. the packaging system that is mandated for use, and
  83. is used by, a significant number of packages, and
  84. therefore should not be changed without peer
  85. review. Package maintainers can then rely on this
  86. interface not changing, and the package management
  87. software authors need to ensure compatibility with
  88. this interface definition. (Control file and
  89. changelog file formats are examples.)
  90. </item>
  91. <tag>Chosen Convention</tag>
  92. <item>
  93. If there are a number of technically viable choices
  94. that can be made, but one needs to select one of
  95. these options for inter-operability. The version
  96. number format is one example.
  97. </item>
  98. </taglist>
  99. Please note that these are not mutually exclusive;
  100. selected conventions often become parts of standard
  101. interfaces.
  102. </footnote>
  103. </p>
  104. <p>
  105. The footnotes present in this manual are
  106. merely informative, and are not part of Debian policy itself.
  107. </p>
  108. <p>
  109. The appendices to this manual are not necessarily normative,
  110. either. Please see <ref id="pkg-scope"> for more information.
  111. </p>
  112. <p>
  113. In the normative part of this manual,
  114. the words <em>must</em>, <em>should</em> and
  115. <em>may</em>, and the adjectives <em>required</em>,
  116. <em>recommended</em> and <em>optional</em>, are used to
  117. distinguish the significance of the various guidelines in
  118. this policy document. Packages that do not conform to the
  119. guidelines denoted by <em>must</em> (or <em>required</em>)
  120. will generally not be considered acceptable for the Debian
  121. distribution. Non-conformance with guidelines denoted by
  122. <em>should</em> (or <em>recommended</em>) will generally be
  123. considered a bug, but will not necessarily render a package
  124. unsuitable for distribution. Guidelines denoted by
  125. <em>may</em> (or <em>optional</em>) are truly optional and
  126. adherence is left to the maintainer's discretion.
  127. </p>
  128. <p>
  129. These classifications are roughly equivalent to the bug
  130. severities <em>serious</em> (for <em>must</em> or
  131. <em>required</em> directive violations), <em>minor</em>,
  132. <em>normal</em> or <em>important</em>
  133. (for <em>should</em> or <em>recommended</em> directive
  134. violations) and <em>wishlist</em> (for <em>optional</em>
  135. items).
  136. <footnote>
  137. Compare RFC 2119. Note, however, that these words are
  138. used in a different way in this document.
  139. </footnote>
  140. </p>
  141. <p>
  142. Much of the information presented in this manual will be
  143. useful even when building a package which is to be
  144. distributed in some other way or is intended for local use
  145. only.
  146. </p>
  147. <p>
  148. udebs (stripped-down binary packages used by the Debian Installer) do
  149. not comply with all of the requirements discussed here. See the
  150. <url name="Debian Installer internals manual"
  151. id="http://d-i.alioth.debian.org/doc/internals/ch03.html"> for more
  152. information about them.
  153. </p>
  154. </sect>
  155. <sect>
  156. <heading>New versions of this document</heading>
  157. <p>
  158. This manual is distributed via the Debian package
  159. <package><url name="debian-policy"
  160. id="http://packages.debian.org/debian-policy"></package>
  161. (<httpsite>packages.debian.org</httpsite>
  162. <httppath>/debian-policy</httppath>).
  163. </p>
  164. <p>
  165. The current version of this document is also available from
  166. the Debian web mirrors at
  167. <tt><url name="/doc/debian-policy/"
  168. id="http://www.debian.org/doc/debian-policy/"></tt>.
  169. (
  170. <httpsite>www.debian.org</httpsite>
  171. <httppath>/doc/debian-policy/</httppath>)
  172. Also available from the same directory are several other
  173. formats: <file>policy.html.tar.gz</file>
  174. (<httppath>/doc/debian-policy/policy.html.tar.gz</httppath>),
  175. <file>policy.pdf.gz</file>
  176. (<httppath>/doc/debian-policy/policy.pdf.gz</httppath>)
  177. and <file>policy.ps.gz</file>
  178. (<httppath>/doc/debian-policy/policy.ps.gz</httppath>).
  179. </p>
  180. <p>
  181. The <package>debian-policy</package> package also includes the file
  182. <file>upgrading-checklist.txt.gz</file> which indicates policy
  183. changes between versions of this document.
  184. </p>
  185. </sect>
  186. <sect id="authors">
  187. <heading>Authors and Maintainers</heading>
  188. <p>
  189. Originally called "Debian GNU/Linux Policy Manual", this
  190. manual was initially written in 1996 by Ian Jackson.
  191. It was revised on November 27th, 1996 by David A. Morris.
  192. Christian Schwarz added new sections on March 15th, 1997,
  193. and reworked/restructured it in April-July 1997.
  194. Christoph Lameter contributed the "Web Standard".
  195. Julian Gilbey largely restructured it in 2001.
  196. </p>
  197. <p>
  198. Since September 1998, the responsibility for the contents of
  199. this document lies on the <url name="debian-policy mailing list"
  200. id="mailto:debian-policy@lists.debian.org">. Proposals
  201. are discussed there and inserted into policy after a certain
  202. consensus is established.
  203. <!-- insert shameless policy-process plug here eventually -->
  204. The actual editing is done by a group of maintainers that have
  205. no editorial powers. These are the current maintainers:
  206. <enumlist>
  207. <item>Russ Allbery</item>
  208. <item>Bill Allombert</item>
  209. <item>Andreas Barth</item>
  210. <item>Jonathan Nieder</item>
  211. </enumlist>
  212. </p>
  213. <p>
  214. While the authors of this document have tried hard to avoid
  215. typos and other errors, these do still occur. If you discover
  216. an error in this manual or if you want to give any
  217. comments, suggestions, or criticisms please send an email to
  218. the Debian Policy List,
  219. <email>debian-policy@lists.debian.org</email>, or submit a
  220. bug report against the <tt>debian-policy</tt> package.
  221. </p>
  222. <p>
  223. Please do not try to reach the individual authors or maintainers
  224. of the Policy Manual regarding changes to the Policy.
  225. </p>
  226. </sect>
  227. <sect id="related">
  228. <heading>Related documents</heading>
  229. <p>
  230. There are several other documents other than this Policy Manual
  231. that are necessary to fully understand some Debian policies and
  232. procedures.
  233. </p>
  234. <p>
  235. The external "sub-policy" documents are referred to in:
  236. <list compact="compact">
  237. <item><ref id="fhs"></item>
  238. <item><ref id="virtual_pkg"></item>
  239. <item><ref id="menus"></item>
  240. <item><ref id="perl"></item>
  241. <item><ref id="maintscriptprompt"></item>
  242. <item><ref id="emacs"></item>
  243. </list>
  244. </p>
  245. <p>
  246. In addition to those, which carry the weight of policy, there
  247. is the Debian Developer's Reference. This document describes
  248. procedures and resources for Debian developers, but it is
  249. <em>not</em> normative; rather, it includes things that don't
  250. belong in the Policy, such as best practices for developers.
  251. </p>
  252. <p>
  253. The Developer's Reference is available in the
  254. <package>developers-reference</package> package.
  255. It's also available from the Debian web mirrors at
  256. <tt><url name="/doc/developers-reference/"
  257. id="http://www.debian.org/doc/developers-reference/"></tt>.
  258. </p>
  259. <p>
  260. Finally, a <qref id="copyrightformat">specification for
  261. machine-readable copyright files</qref> is maintained as part of
  262. the <package>debian-policy</package> package using the same
  263. procedure as the other policy documents. Use of this format is
  264. optional.
  265. </p>
  266. </sect>
  267. <sect id="definitions">
  268. <heading>Definitions</heading>
  269. <p>
  270. The following terms are used in this Policy Manual:
  271. <taglist>
  272. <tag>ASCII</tag>
  273. <item>
  274. The character encoding specified by ANSI X3.4-1986 and its
  275. predecessor standards, referred to in MIME as US-ASCII, and
  276. corresponding to an encoding in eight bits per character of
  277. the first 128 <url id="http://www.unicode.org/"
  278. name="Unicode"> characters, with the eighth bit always zero.
  279. </item>
  280. <tag>UTF-8</tag>
  281. <item>
  282. The transformation format (sometimes called encoding) of
  283. <url id="http://www.unicode.org/" name="Unicode"> defined by
  284. <url id="http://www.rfc-editor.org/rfc/rfc3629.txt"
  285. name="RFC 3629">. UTF-8 has the useful property of having
  286. ASCII as a subset, so any text encoded in ASCII is trivially
  287. also valid UTF-8.
  288. </item>
  289. </taglist>
  290. </p>
  291. </sect>
  292. </chapt>
  293. <chapt id="archive">
  294. <heading>The Debian Archive</heading>
  295. <p>
  296. The Debian system is maintained and distributed as a
  297. collection of <em>packages</em>. Since there are so many of
  298. them (currently well over 15000), they are split into
  299. <em>sections</em> and given <em>priorities</em> to simplify
  300. the handling of them.
  301. </p>
  302. <p>
  303. The effort of the Debian project is to build a free operating
  304. system, but not every package we want to make accessible is
  305. <em>free</em> in our sense (see the Debian Free Software
  306. Guidelines, below), or may be imported/exported without
  307. restrictions. Thus, the archive is split into areas<footnote>
  308. The Debian archive software uses the term "component" internally
  309. and in the Release file format to refer to the division of an
  310. archive. The Debian Social Contract simply refers to "areas."
  311. This document uses terminology similar to the Social Contract.
  312. </footnote> based on their licenses and other restrictions.
  313. </p>
  314. <p>
  315. The aims of this are:
  316. <list compact="compact">
  317. <item>to allow us to make as much software available as we can</item>
  318. <item>to allow us to encourage everyone to write free software,
  319. and</item>
  320. <item>to allow us to make it easy for people to produce
  321. CD-ROMs of our system without violating any licenses,
  322. import/export restrictions, or any other laws.</item>
  323. </list>
  324. </p>
  325. <p>
  326. The <em>main</em> archive area forms the <em>Debian distribution</em>.
  327. </p>
  328. <p>
  329. Packages in the other archive areas (<tt>contrib</tt>,
  330. <tt>non-free</tt>) are not considered to be part of the Debian
  331. distribution, although we support their use and provide
  332. infrastructure for them (such as our bug-tracking system and
  333. mailing lists). This Debian Policy Manual applies to these
  334. packages as well.
  335. </p>
  336. <sect id="dfsg">
  337. <heading>The Debian Free Software Guidelines</heading>
  338. <p>
  339. The Debian Free Software Guidelines (DFSG) form our
  340. definition of "free software". These are:
  341. <taglist>
  342. <tag>1. Free Redistribution
  343. </tag>
  344. <item>
  345. The license of a Debian component may not restrict any
  346. party from selling or giving away the software as a
  347. component of an aggregate software distribution
  348. containing programs from several different
  349. sources. The license may not require a royalty or
  350. other fee for such sale.
  351. </item>
  352. <tag>2. Source Code
  353. </tag>
  354. <item>
  355. The program must include source code, and must allow
  356. distribution in source code as well as compiled form.
  357. </item>
  358. <tag>3. Derived Works
  359. </tag>
  360. <item>
  361. The license must allow modifications and derived
  362. works, and must allow them to be distributed under the
  363. same terms as the license of the original software.
  364. </item>
  365. <tag>4. Integrity of The Author's Source Code
  366. </tag>
  367. <item>
  368. The license may restrict source-code from being
  369. distributed in modified form <em>only</em> if the
  370. license allows the distribution of "patch files"
  371. with the source code for the purpose of modifying the
  372. program at build time. The license must explicitly
  373. permit distribution of software built from modified
  374. source code. The license may require derived works to
  375. carry a different name or version number from the
  376. original software. (This is a compromise. The Debian
  377. Project encourages all authors to not restrict any
  378. files, source or binary, from being modified.)
  379. </item>
  380. <tag>5. No Discrimination Against Persons or Groups
  381. </tag>
  382. <item>
  383. The license must not discriminate against any person
  384. or group of persons.
  385. </item>
  386. <tag>6. No Discrimination Against Fields of Endeavor
  387. </tag>
  388. <item>
  389. The license must not restrict anyone from making use
  390. of the program in a specific field of endeavor. For
  391. example, it may not restrict the program from being
  392. used in a business, or from being used for genetic
  393. research.
  394. </item>
  395. <tag>7. Distribution of License
  396. </tag>
  397. <item>
  398. The rights attached to the program must apply to all
  399. to whom the program is redistributed without the need
  400. for execution of an additional license by those
  401. parties.
  402. </item>
  403. <tag>8. License Must Not Be Specific to Debian
  404. </tag>
  405. <item>
  406. The rights attached to the program must not depend on
  407. the program's being part of a Debian system. If the
  408. program is extracted from Debian and used or
  409. distributed without Debian but otherwise within the
  410. terms of the program's license, all parties to whom
  411. the program is redistributed must have the same
  412. rights as those that are granted in conjunction with
  413. the Debian system.
  414. </item>
  415. <tag>9. License Must Not Contaminate Other Software
  416. </tag>
  417. <item>
  418. The license must not place restrictions on other
  419. software that is distributed along with the licensed
  420. software. For example, the license must not insist
  421. that all other programs distributed on the same medium
  422. must be free software.
  423. </item>
  424. <tag>10. Example Licenses
  425. </tag>
  426. <item>
  427. The "GPL," "BSD," and "Artistic" licenses are examples of
  428. licenses that we consider <em>free</em>.
  429. </item>
  430. </taglist>
  431. </p>
  432. </sect>
  433. <sect id="sections">
  434. <heading>Archive areas</heading>
  435. <sect1 id="main">
  436. <heading>The main archive area</heading>
  437. <p>
  438. The <em>main</em> archive area comprises the Debian
  439. distribution. Only the packages in this area are considered
  440. part of the distribution. None of the packages in
  441. the <em>main</em> archive area require software outside of
  442. that area to function. Anyone may use, share, modify and
  443. redistribute the packages in this archive area
  444. freely<footnote>
  445. See <url id="http://www.debian.org/intro/free"
  446. name="What Does Free Mean?"> for
  447. more about what we mean by free software.
  448. </footnote>.
  449. </p>
  450. <p>
  451. Every package in <em>main</em> must comply with the DFSG
  452. (Debian Free Software Guidelines).
  453. </p>
  454. <p>
  455. In addition, the packages in <em>main</em>
  456. <list compact="compact">
  457. <item>
  458. must not require or recommend a package outside
  459. of <em>main</em> for compilation or execution (thus, the
  460. package must not declare a "Pre-Depends", "Depends",
  461. "Recommends", "Build-Depends", or "Build-Depends-Indep"
  462. relationship on a non-<em>main</em> package),
  463. </item>
  464. <item>
  465. must not be so buggy that we refuse to support them,
  466. and
  467. </item>
  468. <item>
  469. must meet all policy requirements presented in this
  470. manual.
  471. </item>
  472. </list>
  473. </p>
  474. </sect1>
  475. <sect1 id="contrib">
  476. <heading>The contrib archive area</heading>
  477. <p>
  478. The <em>contrib</em> archive area contains supplemental
  479. packages intended to work with the Debian distribution, but
  480. which require software outside of the distribution to either
  481. build or function.
  482. </p>
  483. <p>
  484. Every package in <em>contrib</em> must comply with the DFSG.
  485. </p>
  486. <p>
  487. In addition, the packages in <em>contrib</em>
  488. <list compact="compact">
  489. <item>
  490. must not be so buggy that we refuse to support them,
  491. and
  492. </item>
  493. <item>
  494. must meet all policy requirements presented in this
  495. manual.
  496. </item>
  497. </list>
  498. </p>
  499. <p>
  500. Examples of packages which would be included in
  501. <em>contrib</em> are:
  502. <list compact="compact">
  503. <item>
  504. free packages which require <em>contrib</em>,
  505. <em>non-free</em> packages or packages which are not
  506. in our archive at all for compilation or execution,
  507. and
  508. </item>
  509. <item>
  510. wrapper packages or other sorts of free accessories for
  511. non-free programs.
  512. </item>
  513. </list>
  514. </p>
  515. </sect1>
  516. <sect1 id="non-free">
  517. <heading>The non-free archive area</heading>
  518. <p>
  519. The <em>non-free</em> archive area contains supplemental
  520. packages intended to work with the Debian distribution that do
  521. not comply with the DFSG or have other problems that make
  522. their distribution problematic. They may not comply with all
  523. of the policy requirements in this manual due to restrictions
  524. on modifications or other limitations.
  525. </p>
  526. <p>
  527. Packages must be placed in <em>non-free</em> if they are
  528. not compliant with the DFSG or are encumbered by patents
  529. or other legal issues that make their distribution
  530. problematic.
  531. </p>
  532. <p>
  533. In addition, the packages in <em>non-free</em>
  534. <list compact="compact">
  535. <item>
  536. must not be so buggy that we refuse to support them,
  537. and
  538. </item>
  539. <item>
  540. must meet all policy requirements presented in this
  541. manual that it is possible for them to meet.
  542. <footnote>
  543. It is possible that there are policy
  544. requirements which the package is unable to
  545. meet, for example, if the source is
  546. unavailable. These situations will need to be
  547. handled on a case-by-case basis.
  548. </footnote>
  549. </item>
  550. </list>
  551. </p>
  552. </sect1>
  553. </sect>
  554. <sect id="pkgcopyright">
  555. <heading>Copyright considerations</heading>
  556. <p>
  557. Every package must be accompanied by a verbatim copy of its
  558. copyright information and distribution license in the file
  559. <file>/usr/share/doc/<var>package</var>/copyright</file>
  560. (see <ref id="copyrightfile"> for further details).
  561. </p>
  562. <p>
  563. We reserve the right to restrict files from being included
  564. anywhere in our archives if
  565. <list compact="compact">
  566. <item>
  567. their use or distribution would break a law,
  568. </item>
  569. <item>
  570. there is an ethical conflict in their distribution or
  571. use,
  572. </item>
  573. <item>
  574. we would have to sign a license for them, or
  575. </item>
  576. <item>
  577. their distribution would conflict with other project
  578. policies.
  579. </item>
  580. </list>
  581. </p>
  582. <p>
  583. Programs whose authors encourage the user to make
  584. donations are fine for the main distribution, provided
  585. that the authors do not claim that not donating is
  586. immoral, unethical, illegal or something similar; in such
  587. a case they must go in <em>non-free</em>.
  588. </p>
  589. <p>
  590. Packages whose copyright permission notices (or patent
  591. problems) do not even allow redistribution of binaries
  592. only, and where no special permission has been obtained,
  593. must not be placed on the Debian FTP site and its mirrors
  594. at all.
  595. </p>
  596. <p>
  597. Note that under international copyright law (this applies
  598. in the United States, too), <em>no</em> distribution or
  599. modification of a work is allowed without an explicit
  600. notice saying so. Therefore a program without a copyright
  601. notice <em>is</em> copyrighted and you may not do anything
  602. to it without risking being sued! Likewise if a program
  603. has a copyright notice but no statement saying what is
  604. permitted then nothing is permitted.
  605. </p>
  606. <p>
  607. Many authors are unaware of the problems that restrictive
  608. copyrights (or lack of copyright notices) can cause for
  609. the users of their supposedly-free software. It is often
  610. worthwhile contacting such authors diplomatically to ask
  611. them to modify their license terms. However, this can be a
  612. politically difficult thing to do and you should ask for
  613. advice on the <tt>debian-legal</tt> mailing list first, as
  614. explained below.
  615. </p>
  616. <p>
  617. When in doubt about a copyright, send mail to
  618. <email>debian-legal@lists.debian.org</email>. Be prepared
  619. to provide us with the copyright statement. Software
  620. covered by the GPL, public domain software and BSD-like
  621. copyrights are safe; be wary of the phrases "commercial
  622. use prohibited" and "distribution restricted".
  623. </p>
  624. </sect>
  625. <sect id="subsections">
  626. <heading>Sections</heading>
  627. <p>
  628. The packages in the archive areas <em>main</em>,
  629. <em>contrib</em> and <em>non-free</em> are grouped further into
  630. <em>sections</em> to simplify handling.
  631. </p>
  632. <p>
  633. The archive area and section for each package should be
  634. specified in the package's <tt>Section</tt> control record (see
  635. <ref id="f-Section">). However, the maintainer of the Debian
  636. archive may override this selection to ensure the consistency of
  637. the Debian distribution. The <tt>Section</tt> field should be
  638. of the form:
  639. <list compact="compact">
  640. <item>
  641. <em>section</em> if the package is in the
  642. <em>main</em> archive area,
  643. </item>
  644. <item>
  645. <em>area/section</em> if the package is in
  646. the <em>contrib</em> or <em>non-free</em>
  647. archive areas.
  648. </item>
  649. </list>
  650. </p>
  651. <p>
  652. The Debian archive maintainers provide the authoritative
  653. list of sections. At present, they are:
  654. admin,
  655. cli-mono,
  656. comm,
  657. database,
  658. debug,
  659. devel,
  660. doc,
  661. editors,
  662. education,
  663. electronics,
  664. embedded,
  665. fonts,
  666. games,
  667. gnome,
  668. gnu-r,
  669. gnustep,
  670. graphics,
  671. hamradio,
  672. haskell,
  673. httpd,
  674. interpreters,
  675. introspection,
  676. java,
  677. kde,
  678. kernel,
  679. libdevel,
  680. libs,
  681. lisp,
  682. localization,
  683. mail,
  684. math,
  685. metapackages,
  686. misc,
  687. net,
  688. news,
  689. ocaml,
  690. oldlibs,
  691. otherosfs,
  692. perl,
  693. php,
  694. python,
  695. ruby,
  696. science,
  697. shells,
  698. sound,
  699. tasks,
  700. tex,
  701. text,
  702. utils,
  703. vcs,
  704. video,
  705. web,
  706. x11,
  707. xfce,
  708. zope.
  709. The additional section <em>debian-installer</em>
  710. contains special packages used by the installer and is not used
  711. for normal Debian packages.
  712. </p>
  713. <p>
  714. For more information about the sections and their definitions,
  715. see the <url id="http://packages.debian.org/unstable/"
  716. name="list of sections in unstable">.
  717. </p>
  718. </sect>
  719. <sect id="priorities">
  720. <heading>Priorities</heading>
  721. <p>
  722. Each package should have a <em>priority</em> value, which is
  723. included in the package's <em>control record</em>
  724. (see <ref id="f-Priority">).
  725. This information is used by the Debian package management tools to
  726. separate high-priority packages from less-important packages.
  727. </p>
  728. <p>
  729. The following <em>priority levels</em> are recognized by the
  730. Debian package management tools.
  731. <taglist>
  732. <tag><tt>required</tt></tag>
  733. <item>
  734. Packages which are necessary for the proper
  735. functioning of the system (usually, this means that
  736. dpkg functionality depends on these packages).
  737. Removing a <tt>required</tt> package may cause your
  738. system to become totally broken and you may not even
  739. be able to use <prgn>dpkg</prgn> to put things back,
  740. so only do so if you know what you are doing. Systems
  741. with only the <tt>required</tt> packages are probably
  742. unusable, but they do have enough functionality to
  743. allow the sysadmin to boot and install more software.
  744. </item>
  745. <tag><tt>important</tt></tag>
  746. <item>
  747. Important programs, including those which one would
  748. expect to find on any Unix-like system. If the
  749. expectation is that an experienced Unix person who
  750. found it missing would say "What on earth is going on,
  751. where is <prgn>foo</prgn>?", it must be an
  752. <tt>important</tt> package.<footnote>
  753. This is an important criterion because we are
  754. trying to produce, amongst other things, a free
  755. Unix.
  756. </footnote>
  757. Other packages without which the system will not run
  758. well or be usable must also have priority
  759. <tt>important</tt>. This does
  760. <em>not</em> include Emacs, the X Window System, TeX
  761. or any other large applications. The
  762. <tt>important</tt> packages are just a bare minimum of
  763. commonly-expected and necessary tools.
  764. </item>
  765. <tag><tt>standard</tt></tag>
  766. <item>
  767. These packages provide a reasonably small but not too
  768. limited character-mode system. This is what will be
  769. installed by default if the user doesn't select anything
  770. else. It doesn't include many large applications.
  771. </item>
  772. <tag><tt>optional</tt></tag>
  773. <item>
  774. (In a sense everything that isn't required is
  775. optional, but that's not what is meant here.) This is
  776. all the software that you might reasonably want to
  777. install if you didn't know what it was and don't have
  778. specialized requirements. This is a much larger system
  779. and includes the X Window System, a full TeX
  780. distribution, and many applications. Note that
  781. optional packages should not conflict with each other.
  782. </item>
  783. <tag><tt>extra</tt></tag>
  784. <item>
  785. This contains all packages that conflict with others
  786. with required, important, standard or optional
  787. priorities, or are only likely to be useful if you
  788. already know what they are or have specialized
  789. requirements (such as packages containing only detached
  790. debugging symbols).
  791. </item>
  792. </taglist>
  793. </p>
  794. <p>
  795. Packages must not depend on packages with lower priority
  796. values (excluding build-time dependencies). In order to
  797. ensure this, the priorities of one or more packages may need
  798. to be adjusted.
  799. </p>
  800. </sect>
  801. </chapt>
  802. <chapt id="binary">
  803. <heading>Binary packages</heading>
  804. <p>
  805. The Debian distribution is based on the Debian
  806. package management system, called <prgn>dpkg</prgn>. Thus,
  807. all packages in the Debian distribution must be provided
  808. in the <tt>.deb</tt> file format.
  809. </p>
  810. <p>
  811. A <tt>.deb</tt> package contains two sets of files: a set of files
  812. to install on the system when the package is installed, and a set
  813. of files that provide additional metadata about the package or
  814. which are executed when the package is installed or removed. This
  815. second set of files is called <em>control information files</em>.
  816. Among those files are the package maintainer scripts
  817. and <file>control</file>, the <qref id="binarycontrolfiles">binary
  818. package control file</qref> that contains the control fields for
  819. the package. Other control information files include
  820. the <qref id="sharedlibs-symbols"><file>symbols</file> file</qref>
  821. or <qref id="sharedlibs-shlibdeps"><file>shlibs</file> file</qref>
  822. used to store shared library dependency information and
  823. the <file>conffiles</file> file that lists the package's
  824. configuration files (described in <ref id="config-files">).
  825. </p>
  826. <p>
  827. There is unfortunately a collision of terminology here between
  828. control information files and files in the Debian control file
  829. format. Throughout this document, a <em>control file</em> refers
  830. to a file in the Debian control file format. These files are
  831. documented in <ref id="controlfields">. Only files referred to
  832. specifically as <em>control information files</em> are the files
  833. included in the control information file member of
  834. the <file>.deb</file> file format used by binary packages. Most
  835. control information files are not in the Debian control file
  836. format.
  837. </p>
  838. <sect>
  839. <heading>The package name</heading>
  840. <p>
  841. Every package must have a name that's unique within the Debian
  842. archive.
  843. </p>
  844. <p>
  845. The package name is included in the control field
  846. <tt>Package</tt>, the format of which is described
  847. in <ref id="f-Package">.
  848. The package name is also included as a part of the file name
  849. of the <tt>.deb</tt> file.
  850. </p>
  851. </sect>
  852. <sect id="versions">
  853. <heading>The version of a package</heading>
  854. <p>
  855. Every package has a version number recorded in its
  856. <tt>Version</tt> control file field, described in
  857. <ref id="f-Version">.
  858. </p>
  859. <p>
  860. The package management system imposes an ordering on version
  861. numbers, so that it can tell whether packages are being up- or
  862. downgraded and so that package system front end applications
  863. can tell whether a package it finds available is newer than
  864. the one installed on the system. The version number format
  865. has the most significant parts (as far as comparison is
  866. concerned) at the beginning.
  867. </p>
  868. <p>
  869. If an upstream package has problematic version numbers they
  870. should be converted to a sane form for use in the
  871. <tt>Version</tt> field.
  872. </p>
  873. <sect1>
  874. <heading>Version numbers based on dates</heading>
  875. <p>
  876. In general, Debian packages should use the same version
  877. numbers as the upstream sources. However, upstream version
  878. numbers based on some date formats (sometimes used for
  879. development or "snapshot" releases) will not be ordered
  880. correctly by the package management software. For
  881. example, <prgn>dpkg</prgn> will consider "96May01" to be
  882. greater than "96Dec24".
  883. </p>
  884. <p>
  885. To prevent having to use epochs for every new upstream
  886. version, the date-based portion of any upstream version number
  887. should be given in a way that sorts correctly: four-digit year
  888. first, followed by a two-digit numeric month, followed by a
  889. two-digit numeric date, possibly with punctuation between the
  890. components.
  891. </p>
  892. <p>
  893. Native Debian packages (i.e., packages which have been written
  894. especially for Debian) whose version numbers include dates
  895. should also follow these rules. If punctuation is desired
  896. between the date components, remember that hyphen (<tt>-</tt>)
  897. cannot be used in native package versions. Period
  898. (<tt>.</tt>) is normally a good choice.
  899. </p>
  900. </sect1>
  901. </sect>
  902. <sect id="maintainer">
  903. <heading>The maintainer of a package</heading>
  904. <p>
  905. Every package must have a maintainer, except for orphaned
  906. packages as described below. The maintainer may be one person
  907. or a group of people reachable from a common email address, such
  908. as a mailing list. The maintainer is responsible for
  909. maintaining the Debian packaging files, evaluating and
  910. responding appropriately to reported bugs, uploading new
  911. versions of the package (either directly or through a sponsor),
  912. ensuring that the package is placed in the appropriate archive
  913. area and included in Debian releases as appropriate for the
  914. stability and utility of the package, and requesting removal of
  915. the package from the Debian distribution if it is no longer
  916. useful or maintainable.
  917. </p>
  918. <p>
  919. The maintainer must be specified in the <tt>Maintainer</tt>
  920. control field with their correct name and a working email
  921. address. The email address given in the <tt>Maintainer</tt>
  922. control field must accept mail from those role accounts in
  923. Debian used to send automated mails regarding the package. This
  924. includes non-spam mail from the bug-tracking system, all mail
  925. from the Debian archive maintenance software, and other role
  926. accounts or automated processes that are commonly agreed on by
  927. the project.<footnote>
  928. A sample implementation of such a whitelist written for the
  929. Mailman mailing list management software is used for mailing
  930. lists hosted by alioth.debian.org.
  931. </footnote>
  932. If one person or team maintains several packages, they should
  933. use the same form of their name and email address in
  934. the <tt>Maintainer</tt> fields of those packages.
  935. </p>
  936. <p>
  937. The format of the <tt>Maintainer</tt> control field is
  938. described in <ref id="f-Maintainer">.
  939. </p>
  940. <p>
  941. If the maintainer of the package is a team of people with a
  942. shared email address, the <tt>Uploaders</tt> control field must
  943. be present and must contain at least one human with their
  944. personal email address. See <ref id="f-Uploaders"> for the
  945. syntax of that field.
  946. </p>
  947. <p>
  948. An orphaned package is one with no current maintainer. Orphaned
  949. packages should have their <tt>Maintainer</tt> control field set
  950. to <tt>Debian QA Group &lt;packages@qa.debian.org&gt;</tt>.
  951. These packages are considered maintained by the Debian project
  952. as a whole until someone else volunteers to take over
  953. maintenance.<footnote>
  954. The detailed procedure for gracefully orphaning a package can
  955. be found in the Debian Developer's Reference
  956. (see <ref id="related">).
  957. </footnote>
  958. </p>
  959. </sect>
  960. <sect id="descriptions">
  961. <heading>The description of a package</heading>
  962. <p>
  963. Every Debian package must have a <tt>Description</tt> control
  964. field which contains a synopsis and extended description of the
  965. package. Technical information about the format of the
  966. <tt>Description</tt> field is in <ref id="f-Description">.
  967. </p>
  968. <p>
  969. The description should describe the package (the program) to a
  970. user (system administrator) who has never met it before so that
  971. they have enough information to decide whether they want to
  972. install it. This description should not just be copied verbatim
  973. from the program's documentation.
  974. </p>
  975. <p>
  976. Put important information first, both in the synopsis and
  977. extended description. Sometimes only the first part of the
  978. synopsis or of the description will be displayed. You can
  979. assume that there will usually be a way to see the whole
  980. extended description.
  981. </p>
  982. <p>
  983. The description should also give information about the
  984. significant dependencies and conflicts between this package
  985. and others, so that the user knows why these dependencies and
  986. conflicts have been declared.
  987. </p>
  988. <p>
  989. Instructions for configuring or using the package should
  990. not be included (that is what installation scripts,
  991. manual pages, info files, etc., are for). Copyright
  992. statements and other administrivia should not be included
  993. either (that is what the copyright file is for).
  994. </p>
  995. <sect1 id="synopsis"><heading>The single line synopsis</heading>
  996. <p>
  997. The single line synopsis should be kept brief - certainly
  998. under 80 characters.
  999. </p>
  1000. <p>
  1001. Do not include the package name in the synopsis line. The
  1002. display software knows how to display this already, and you
  1003. do not need to state it. Remember that in many situations
  1004. the user may only see the synopsis line - make it as
  1005. informative as you can.
  1006. </p>
  1007. </sect1>
  1008. <sect1 id="extendeddesc"><heading>The extended description</heading>
  1009. <p>
  1010. Do not try to continue the single line synopsis into the
  1011. extended description. This will not work correctly when
  1012. the full description is displayed, and makes no sense
  1013. where only the summary (the single line synopsis) is
  1014. available.
  1015. </p>
  1016. <p>
  1017. The extended description should describe what the package
  1018. does and how it relates to the rest of the system (in terms
  1019. of, for example, which subsystem it is which part of).
  1020. </p>
  1021. <p>
  1022. The description field needs to make sense to anyone, even
  1023. people who have no idea about any of the things the
  1024. package deals with.<footnote>
  1025. The blurb that comes with a program in its
  1026. announcements and/or <prgn>README</prgn> files is
  1027. rarely suitable for use in a description. It is
  1028. usually aimed at people who are already in the
  1029. community where the package is used.
  1030. </footnote>
  1031. </p>
  1032. </sect1>
  1033. </sect>
  1034. <sect id="dependencies">
  1035. <heading>Dependencies</heading>
  1036. <p>
  1037. Every package must specify the dependency information
  1038. about other packages that are required for the first to
  1039. work correctly.
  1040. </p>
  1041. <p>
  1042. For example, a dependency entry must be provided for any
  1043. shared libraries required by a dynamically-linked executable
  1044. binary in a package.
  1045. </p>
  1046. <p>
  1047. Packages are not required to declare any dependencies they
  1048. have on other packages which are marked <tt>Essential</tt>
  1049. (see below), and should not do so unless they depend on a
  1050. particular version of that package.<footnote>
  1051. <p>
  1052. Essential is needed in part to avoid unresolvable dependency
  1053. loops on upgrade. If packages add unnecessary dependencies
  1054. on packages in this set, the chances that there
  1055. <strong>will</strong> be an unresolvable dependency loop
  1056. caused by forcing these Essential packages to be configured
  1057. first before they need to be is greatly increased. It also
  1058. increases the chances that frontends will be unable to
  1059. <strong>calculate</strong> an upgrade path, even if one
  1060. exists.
  1061. </p>
  1062. <p>
  1063. Also, functionality is rarely ever removed from the
  1064. Essential set, but <em>packages</em> have been removed from
  1065. the Essential set when the functionality moved to a
  1066. different package. So depending on these packages <em>just
  1067. in case</em> they stop being essential does way more harm
  1068. than good.
  1069. </p>
  1070. </footnote>
  1071. </p>
  1072. <p>
  1073. Sometimes, unpacking one package requires that another package
  1074. be first unpacked <em>and</em> configured. In this case, the
  1075. depending package must specify this dependency in
  1076. the <tt>Pre-Depends</tt> control field.
  1077. </p>
  1078. <p>
  1079. You should not specify a <tt>Pre-Depends</tt> entry for a
  1080. package before this has been discussed on the
  1081. <tt>debian-devel</tt> mailing list and a consensus about
  1082. doing that has been reached.
  1083. </p>
  1084. <p>
  1085. The format of the package interrelationship control fields is
  1086. described in <ref id="relationships">.
  1087. </p>
  1088. </sect>
  1089. <sect id="virtual_pkg">
  1090. <heading>Virtual packages</heading>
  1091. <p>
  1092. Sometimes, there are several packages which offer
  1093. more-or-less the same functionality. In this case, it's
  1094. useful to define a <em>virtual package</em> whose name
  1095. describes that common functionality. (The virtual
  1096. packages only exist logically, not physically; that's why
  1097. they are called <em>virtual</em>.) The packages with this
  1098. particular function will then <em>provide</em> the virtual
  1099. package. Thus, any other package requiring that function
  1100. can simply depend on the virtual package without having to
  1101. specify all possible packages individually.
  1102. </p>
  1103. <p>
  1104. All packages should use virtual package names where
  1105. appropriate, and arrange to create new ones if necessary.
  1106. They should not use virtual package names (except privately,
  1107. amongst a cooperating group of packages) unless they have
  1108. been agreed upon and appear in the list of virtual package
  1109. names. (See also <ref id="virtual">)
  1110. </p>
  1111. <p>
  1112. The latest version of the authoritative list of virtual
  1113. package names can be found in the <tt>debian-policy</tt> package.
  1114. It is also available from the Debian web mirrors at
  1115. <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
  1116. id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>.
  1117. </p>
  1118. <p>
  1119. The procedure for updating the list is described in the preface
  1120. to the list.
  1121. </p>
  1122. </sect>
  1123. <sect>
  1124. <heading>Base system</heading>
  1125. <p>
  1126. The <tt>base system</tt> is a minimum subset of the Debian
  1127. system that is installed before everything else
  1128. on a new system. Only very few packages are allowed to form
  1129. part of the base system, in order to keep the required disk
  1130. usage very small.
  1131. </p>
  1132. <p>
  1133. The base system consists of all those packages with priority
  1134. <tt>required</tt> or <tt>important</tt>. Many of them will
  1135. be tagged <tt>essential</tt> (see below).
  1136. </p>
  1137. </sect>
  1138. <sect>
  1139. <heading>Essential packages</heading>
  1140. <p>
  1141. Essential is defined as the minimal set of functionality that
  1142. must be available and usable on the system at all times, even
  1143. when packages are in the "Unpacked" state.
  1144. Packages are tagged <tt>essential</tt> for a system using the
  1145. <tt>Essential</tt> control field. The format of the
  1146. <tt>Essential</tt> control field is described in <ref
  1147. id="f-Essential">.
  1148. </p>
  1149. <p>
  1150. Since these packages cannot be easily removed (one has to
  1151. specify an extra <em>force option</em> to
  1152. <prgn>dpkg</prgn> to do so), this flag must not be used
  1153. unless absolutely necessary. A shared library package
  1154. must not be tagged <tt>essential</tt>; dependencies will
  1155. prevent its premature removal, and we need to be able to
  1156. remove it when it has been superseded.
  1157. </p>
  1158. <p>
  1159. Since dpkg will not prevent upgrading of other packages
  1160. while an <tt>essential</tt> package is in an unconfigured
  1161. state, all <tt>essential</tt> packages must supply all of
  1162. their core functionality even when unconfigured. If the
  1163. package cannot satisfy this requirement it must not be
  1164. tagged as essential, and any packages depending on this
  1165. package must instead have explicit dependency fields as
  1166. appropriate.
  1167. </p>
  1168. <p>
  1169. Maintainers should take great care in adding any programs,
  1170. interfaces, or functionality to <tt>essential</tt> packages.
  1171. Packages may assume that functionality provided by
  1172. <tt>essential</tt> packages is always available without
  1173. declaring explicit dependencies, which means that removing
  1174. functionality from the Essential set is very difficult and is
  1175. almost never done. Any capability added to an
  1176. <tt>essential</tt> package therefore creates an obligation to
  1177. support that capability as part of the Essential set in
  1178. perpetuity.
  1179. </p>
  1180. <p>
  1181. You must not tag any packages <tt>essential</tt> before
  1182. this has been discussed on the <tt>debian-devel</tt>
  1183. mailing list and a consensus about doing that has been
  1184. reached.
  1185. </p>
  1186. </sect>
  1187. <sect id="maintscripts">
  1188. <heading>Maintainer Scripts</heading>
  1189. <p>
  1190. The package installation scripts should avoid producing
  1191. output which is unnecessary for the user to see and
  1192. should rely on <prgn>dpkg</prgn> to stave off boredom on
  1193. the part of a user installing many packages. This means,
  1194. amongst other things, not passing the <tt>--verbose</tt>
  1195. option to <prgn>update-alternatives</prgn>.
  1196. </p>
  1197. <p>
  1198. Errors which occur during the execution of an installation
  1199. script must be checked and the installation must not
  1200. continue after an error.
  1201. </p>
  1202. <p>
  1203. Note that in general <ref id="scripts"> applies to package
  1204. maintainer scripts, too.
  1205. </p>
  1206. <p>
  1207. You should not use <prgn>dpkg-divert</prgn> on a file belonging
  1208. to another package without consulting the maintainer of that
  1209. package first. When adding or removing diversions, package
  1210. maintainer scripts must provide the <tt>--package</tt> flag
  1211. to <prgn>dpkg-divert</prgn> and must not use <tt>--local</tt>.
  1212. </p>
  1213. <p>
  1214. All packages which supply an instance of a common command
  1215. name (or, in general, filename) should generally use
  1216. <prgn>update-alternatives</prgn>, so that they may be
  1217. installed together. If <prgn>update-alternatives</prgn>
  1218. is not used, then each package must use
  1219. <tt>Conflicts</tt> to ensure that other packages are
  1220. removed. (In this case, it may be appropriate to
  1221. specify a conflict against earlier versions of something
  1222. that previously did not use
  1223. <prgn>update-alternatives</prgn>; this is an exception to
  1224. the usual rule that versioned conflicts should be
  1225. avoided.)
  1226. </p>
  1227. <sect1 id="maintscriptprompt">
  1228. <heading>Prompting in maintainer scripts</heading>
  1229. <p>
  1230. Package maintainer scripts may prompt the user if
  1231. necessary. Prompting must be done by communicating
  1232. through a program, such as <prgn>debconf</prgn>, which
  1233. conforms to the Debian Configuration Management
  1234. Specification, version 2 or higher.
  1235. </p>
  1236. <p>
  1237. Packages which are essential, or which are dependencies of
  1238. essential packages, may fall back on another prompting method
  1239. if no such interface is available when they are executed.
  1240. </p>
  1241. <p>
  1242. The Debian Configuration Management Specification is included
  1243. in the <file>debconf_specification</file> files in the
  1244. <package>debian-policy</package> package.
  1245. It is also available from the Debian web mirrors at
  1246. <tt><url name="/doc/packaging-manuals/debconf_specification.html"
  1247. id="http://www.debian.org/doc/packaging-manuals/debconf_specification.html"></tt>.
  1248. </p>
  1249. <p>
  1250. Packages which use the Debian Configuration Management
  1251. Specification may contain the additional control information
  1252. files <file>config</file>
  1253. and <file>templates</file>. <file>config</file> is an
  1254. additional maintainer script used for package configuration,
  1255. and <file>templates</file> contains templates used for user
  1256. prompting. The <prgn>config</prgn> script might be run before
  1257. the <prgn>preinst</prgn> script and before the package is
  1258. unpacked or any of its dependencies or pre-dependencies are
  1259. satisfied. Therefore it must work using only the tools
  1260. present in <em>essential</em> packages.<footnote>
  1261. <package>Debconf</package> or another tool that
  1262. implements the Debian Configuration Management
  1263. Specification will also be installed, and any
  1264. versioned dependencies on it will be satisfied
  1265. before preconfiguration begins.
  1266. </footnote>
  1267. </p>
  1268. <p>
  1269. Packages which use the Debian Configuration Management
  1270. Specification must allow for translation of their user-visible
  1271. messages by using a gettext-based system such as the one
  1272. provided by the <package>po-debconf</package> package.
  1273. </p>
  1274. <p>
  1275. Packages should try to minimize the amount of prompting
  1276. they need to do, and they should ensure that the user
  1277. will only ever be asked each question once. This means
  1278. that packages should try to use appropriate shared
  1279. configuration files (such as <file>/etc/papersize</file> and
  1280. <file>/etc/news/server</file>), and shared
  1281. <package>debconf</package> variables rather than each
  1282. prompting for their own list of required pieces of
  1283. information.
  1284. </p>
  1285. <p>
  1286. It also means that an upgrade should not ask the same
  1287. questions again, unless the user has used
  1288. <tt>dpkg --purge</tt> to remove the package's configuration.
  1289. The answers to configuration questions should be stored in an
  1290. appropriate place in <file>/etc</file> so that the user can
  1291. modify them, and how this has been done should be
  1292. documented.
  1293. </p>
  1294. <p>
  1295. If a package has a vitally important piece of
  1296. information to pass to the user (such as "don't run me
  1297. as I am, you must edit the following configuration files
  1298. first or you risk your system emitting badly-formatted
  1299. messages"), it should display this in the
  1300. <prgn>config</prgn> or <prgn>postinst</prgn> script and
  1301. prompt the user to hit return to acknowledge the
  1302. message. Copyright messages do not count as vitally
  1303. important (they belong in
  1304. <file>/usr/share/doc/<var>package</var>/copyright</file>);
  1305. neither do instructions on how to use a program (these
  1306. should be in on-line documentation, where all the users
  1307. can see them).
  1308. </p>
  1309. <p>
  1310. Any necessary prompting should almost always be confined
  1311. to the <prgn>config</prgn> or <prgn>postinst</prgn>
  1312. script. If it is done in the <prgn>postinst</prgn>, it
  1313. should be protected with a conditional so that
  1314. unnecessary prompting doesn't happen if a package's
  1315. installation fails and the <prgn>postinst</prgn> is
  1316. called with <tt>abort-upgrade</tt>,
  1317. <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.
  1318. </p>
  1319. </sect1>
  1320. </sect>
  1321. </chapt>
  1322. <chapt id="source">
  1323. <heading>Source packages</heading>
  1324. <sect id="standardsversion">
  1325. <heading>Standards conformance</heading>
  1326. <p>
  1327. Source packages should specify the most recent version number
  1328. of this policy document with which your package complied
  1329. when it was last updated.
  1330. </p>
  1331. <p>
  1332. This information may be used to file bug reports
  1333. automatically if your package becomes too much out of date.
  1334. </p>
  1335. <p>
  1336. The version is specified in the <tt>Standards-Version</tt>
  1337. control field.
  1338. The format of the <tt>Standards-Version</tt> field is
  1339. described in <ref id="f-Standards-Version">.
  1340. </p>
  1341. <p>
  1342. You should regularly, and especially if your package has
  1343. become out of date, check for the newest Policy Manual
  1344. available and update your package, if necessary. When your
  1345. package complies with the new standards you should update the
  1346. <tt>Standards-Version</tt> source package field and
  1347. release it.<footnote>
  1348. See the file <file>upgrading-checklist</file> for
  1349. information about policy which has changed between
  1350. different versions of this document.
  1351. </footnote>
  1352. </p>
  1353. </sect>
  1354. <sect id="pkg-relations">
  1355. <heading>Package relationships</heading>
  1356. <p>
  1357. Source packages should specify which binary packages they
  1358. require to be installed or not to be installed in order to
  1359. build correctly. For example, if building a package
  1360. requires a certain compiler, then the compiler should be
  1361. specified as a build-time dependency.
  1362. </p>
  1363. <p>
  1364. It is not necessary to explicitly specify build-time
  1365. relationships on a minimal set of packages that are always
  1366. needed to compile, link and put in a Debian package a
  1367. standard "Hello World!" program written in C or C++. The
  1368. required packages are called <em>build-essential</em>, and
  1369. an informational list can be found in
  1370. <file>/usr/share/doc/build-essential/list</file> (which is
  1371. contained in the <tt>build-essential</tt>
  1372. package).<footnote>
  1373. Rationale:
  1374. <list compact="compact">
  1375. <item>
  1376. This allows maintaining the list separately
  1377. from the policy documents (the list does not
  1378. need the kind of control that the policy
  1379. documents do).
  1380. </item>
  1381. <item>
  1382. Having a separate package allows one to install
  1383. the build-essential packages on a machine, as
  1384. well as allowing other packages such as tasks to
  1385. require installation of the build-essential
  1386. packages using the depends relation.
  1387. </item>
  1388. <item>
  1389. The separate package allows bug reports against
  1390. the list to be categorized separately from
  1391. the policy management process in the BTS.
  1392. </item>
  1393. </list>
  1394. </footnote>
  1395. </p>
  1396. <p>
  1397. When specifying the set of build-time dependencies, one
  1398. should list only those packages explicitly required by the
  1399. build. It is not necessary to list packages which are
  1400. required merely because some other package in the list of
  1401. build-time dependencies depends on them.<footnote>
  1402. The reason for this is that dependencies change, and
  1403. you should list all those packages, and <em>only</em>
  1404. those packages that <em>you</em> need directly. What
  1405. others need is their business. For example, if you
  1406. only link against <file>libimlib</file>, you will need to
  1407. build-depend on <package>libimlib2-dev</package> but
  1408. not against any <tt>libjpeg*</tt> packages, even
  1409. though <tt>libimlib2-dev</tt> currently depends on
  1410. them: installation of <package>libimlib2-dev</package>
  1411. will automatically ensure that all of its run-time
  1412. dependencies are satisfied.
  1413. </footnote>
  1414. </p>
  1415. <p>
  1416. If build-time dependencies are specified, it must be
  1417. possible to build the package and produce working binaries
  1418. on a system with only essential and build-essential
  1419. packages installed and also those required to satisfy the
  1420. build-time relationships (including any implied
  1421. relationships). In particular, this means that version
  1422. clauses should be used rigorously in build-time
  1423. relationships so that one cannot produce bad or
  1424. inconsistently configured packages when the relationships
  1425. are properly satisfied.
  1426. </p>
  1427. <p>
  1428. <ref id="relationships"> explains the technical details.
  1429. </p>
  1430. </sect>
  1431. <sect>
  1432. <heading>Changes to the upstream sources</heading>
  1433. <p>
  1434. If changes to the source code are made that are not
  1435. specific to the needs of the Debian system, they should be
  1436. sent to the upstream authors in whatever form they prefer
  1437. so as to be included in the upstream version of the
  1438. package.
  1439. </p>
  1440. <p>
  1441. If you need to configure the package differently for
  1442. Debian or for Linux, and the upstream source doesn't
  1443. provide a way to do so, you should add such configuration
  1444. facilities (for example, a new <prgn>autoconf</prgn> test
  1445. or <tt>#define</tt>) and send the patch to the upstream
  1446. authors, with the default set to the way they originally
  1447. had it. You can then easily override the default in your
  1448. <file>debian/rules</file> or wherever is appropriate.
  1449. </p>
  1450. <p>
  1451. You should make sure that the <prgn>configure</prgn> utility
  1452. detects the correct architecture specification string
  1453. (refer to <ref id="arch-spec"> for details).
  1454. </p>
  1455. <p>
  1456. If you need to edit a <prgn>Makefile</prgn> where GNU-style
  1457. <prgn>configure</prgn> scripts are used, you should edit the
  1458. <file>.in</file> files rather than editing the
  1459. <prgn>Makefile</prgn> directly. This allows the user to
  1460. reconfigure the package if necessary. You should
  1461. <em>not</em> configure the package and edit the generated
  1462. <prgn>Makefile</prgn>! This makes it impossible for someone
  1463. else to later reconfigure the package without losing the
  1464. changes you made.
  1465. </p>
  1466. </sect>
  1467. <sect id="dpkgchangelog">
  1468. <heading>Debian changelog: <file>debian/changelog</file></heading>
  1469. <p>
  1470. Changes in the Debian version of the package should be
  1471. briefly explained in the Debian changelog file
  1472. <file>debian/changelog</file>.<footnote>
  1473. <p>
  1474. Mistakes in changelogs are usually best rectified by
  1475. making a new changelog entry rather than "rewriting
  1476. history" by editing old changelog entries.
  1477. </p>
  1478. </footnote>
  1479. This includes modifications
  1480. made in the Debian package compared to the upstream one
  1481. as well as other changes and updates to the package.
  1482. <footnote>
  1483. Although there is nothing stopping an author who is also
  1484. the Debian maintainer from using this changelog for all
  1485. their changes, it will have to be renamed if the Debian
  1486. and upstream maintainers become different people. In such
  1487. a case, however, it might be better to maintain the package
  1488. as a non-native package.
  1489. </footnote>
  1490. </p>
  1491. <p>
  1492. The format of the <file>debian/changelog</file> allows the
  1493. package building tools to discover which version of the package
  1494. is being built and find out other release-specific information.
  1495. </p>
  1496. <p>
  1497. That format is a series of entries like this:
  1498. <example compact="compact">
  1499. <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
  1500. <var>
  1501. [optional blank line(s), stripped]
  1502. </var>
  1503. * <var>change details</var>
  1504. <var>more change details</var>
  1505. <var>
  1506. [blank line(s), included in output of dpkg-parsechangelog]
  1507. </var>
  1508. * <var>even more change details</var>
  1509. <var>
  1510. [optional blank line(s), stripped]
  1511. </var>
  1512. -- <var>maintainer name</var> &lt;<var>email address</var>&gt;<var>[two spaces]</var> <var>date</var>
  1513. </example>
  1514. </p>
  1515. <p>
  1516. <var>package</var> and <var>version</var> are the source
  1517. package name and version number.
  1518. </p>
  1519. <p>
  1520. <var>distribution(s)</var> lists the distributions where
  1521. this version should be installed when it is uploaded - it
  1522. is copied to the <tt>Distribution</tt> field in the
  1523. <file>.changes</file> file. See <ref id="f-Distribution">.
  1524. </p>
  1525. <p>
  1526. <var>urgency</var> is the value for the <tt>Urgency</tt>
  1527. field in the <file>.changes</file> file for the upload
  1528. (see <ref id="f-Urgency">). It is not possible to specify
  1529. an urgency containing commas; commas are used to separate
  1530. <tt><var>keyword</var>=<var>value</var></tt> settings in the
  1531. <prgn>dpkg</prgn> changelog format (though there is
  1532. currently only one useful <var>keyword</var>,
  1533. <tt>urgency</tt>).
  1534. </p>
  1535. <p>
  1536. The change details may in fact be any series of lines
  1537. starting with at least two spaces, but conventionally each
  1538. change starts with an asterisk and a separating space and
  1539. continuation lines are indented so as to bring them in
  1540. line with the start of the text above. Blank lines may be
  1541. used here to separate groups of changes, if desired.
  1542. </p>
  1543. <p>
  1544. If this upload resolves bugs recorded in the Bug Tracking
  1545. System (BTS), they may be automatically closed on the
  1546. inclusion of this package into the Debian archive by
  1547. including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
  1548. in the change details.<footnote>
  1549. To be precise, the string should match the following
  1550. Perl regular expression:
  1551. <example>
  1552. /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
  1553. </example>
  1554. Then all of the bug numbers listed will be closed by the
  1555. archive maintenance software (<prgn>dak</prgn>) using the
  1556. <var>version</var> of the changelog entry.
  1557. </footnote>
  1558. This information is conveyed via the <tt>Closes</tt> field
  1559. in the <tt>.changes</tt> file (see <ref id="f-Closes">).
  1560. </p>
  1561. <p>
  1562. The maintainer name and email address used in the changelog
  1563. should be the details of the person who prepared this release of
  1564. the package. They are <em>not</em> necessarily those of the
  1565. uploader or usual package maintainer.<footnote>
  1566. In the case of a sponsored upload, the uploader signs the
  1567. files, but the changelog maintainer name and address are those
  1568. of the person who prepared this release. If the preparer of
  1569. the release is not one of the usual maintainers of the package
  1570. (as listed in
  1571. the <qref id="f-Maintainer"><tt>Maintainer</tt></qref>
  1572. or <qref id="f-Uploaders"><tt>Uploaders</tt></qref> control
  1573. fields of the package), the first line of the changelog is
  1574. conventionally used to explain why a non-maintainer is
  1575. uploading the package. The Debian Developer's Reference
  1576. (see <ref id="related">) documents the conventions
  1577. used.</footnote>
  1578. The information here will be copied to the <tt>Changed-By</tt>
  1579. field in the <tt>.changes</tt> file
  1580. (see <ref id="f-Changed-By">), and then later used to send an
  1581. acknowledgement when the upload has been installed.
  1582. </p>
  1583. <p>
  1584. The <var>date</var> has the following format<footnote>
  1585. This is the same as the format generated by <tt>date
  1586. -R</tt>.
  1587. </footnote> (compatible and with the same semantics of
  1588. RFC 2822 and RFC 5322):
  1589. <example>day-of-week, dd month yyyy hh:mm:ss +zzzz</example>
  1590. where:
  1591. <list compact="compact">
  1592. <item>
  1593. day-of week is one of: Mon, Tue, Wed, Thu, Fri, Sat, Sun
  1594. </item>
  1595. <item>
  1596. dd is a one- or two-digit day of the month (01-31)
  1597. </item>
  1598. <item>
  1599. month is one of: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug,
  1600. Sep, Oct, Nov, Dec
  1601. </item>
  1602. <item>yyyy is the four-digit year (e.g. 2010)</item>
  1603. <item>hh is the two-digit hour (00-23)</item>
  1604. <item>mm is the two-digit minutes (00-59)</item>
  1605. <item>ss is the two-digit seconds (00-60)</item>
  1606. <item>
  1607. +zzzz or -zzzz is the the time zone offset from Coordinated
  1608. Universal Time (UTC). "+" indicates that the time is ahead
  1609. of (i.e., east of) UTC and "-" indicates that the time is
  1610. behind (i.e., west of) UTC. The first two digits indicate
  1611. the hour difference from UTC and the last two digits
  1612. indicate the number of additional minutes difference from
  1613. UTC. The last two digits must be in the range 00-59.
  1614. </item>
  1615. </list>
  1616. </p>
  1617. <p>
  1618. The first "title" line with the package name must start
  1619. at the left hand margin. The "trailer" line with the
  1620. maintainer and date details must be preceded by exactly
  1621. one space. The maintainer details and the date must be
  1622. separated by exactly two spaces.
  1623. </p>
  1624. <p>
  1625. The entire changelog must be encoded in UTF-8.
  1626. </p>
  1627. <p>
  1628. For more information on placement of the changelog files
  1629. within binary packages, please see <ref id="changelogs">.
  1630. </p>
  1631. </sect>
  1632. <sect id="dpkgcopyright">
  1633. <heading>Copyright: <file>debian/copyright</file></heading>
  1634. <p>
  1635. Every package must be accompanied by a verbatim copy of its
  1636. copyright information and distribution license in the file
  1637. <file>/usr/share/doc/<var>package</var>/copyright</file>
  1638. (see <ref id="copyrightfile"> for further details). Also see
  1639. <ref id="pkgcopyright"> for further considerations related
  1640. to copyrights for packages.
  1641. </p>
  1642. </sect>
  1643. <sect>
  1644. <heading>Error trapping in makefiles</heading>
  1645. <p>
  1646. When <prgn>make</prgn> invokes a command in a makefile
  1647. (including your package's upstream makefiles and
  1648. <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
  1649. means that <prgn>sh</prgn>'s usual bad error handling
  1650. properties apply: if you include a miniature script as one
  1651. of the commands in your makefile you'll find that if you
  1652. don't do anything about it then errors are not detected
  1653. and <prgn>make</prgn> will blithely continue after
  1654. problems.
  1655. </p>
  1656. <p>
  1657. Every time you put more than one shell command (this
  1658. includes using a loop) in a makefile command you
  1659. must make sure that errors are trapped. For
  1660. simple compound commands, such as changing directory and
  1661. then running a program, using <tt>&amp;&amp;</tt> rather
  1662. than semicolon as a command separator is sufficient. For
  1663. more complex commands including most loops and
  1664. conditionals you should include a separate <tt>set -e</tt>
  1665. command at the start of every makefile command that's
  1666. actually one of these miniature shell scripts.
  1667. </p>
  1668. </sect>
  1669. <sect id="timestamps">
  1670. <heading>Time Stamps</heading>
  1671. <p>
  1672. Maintainers should preserve the modification times of the
  1673. upstream source files in a package, as far as is reasonably
  1674. possible.<footnote>
  1675. The rationale is that there is some information conveyed
  1676. by knowing the age of the file, for example, you could
  1677. recognize that some documentation is very old by looking
  1678. at the modification time, so it would be nice if the
  1679. modification time of the upstream source would be
  1680. preserved.
  1681. </footnote>
  1682. </p>
  1683. </sect>
  1684. <sect id="restrictions">
  1685. <heading>Restrictions on objects in source packages</heading>
  1686. <p>
  1687. The source package may not contain any hard links<footnote>
  1688. <p>
  1689. This is not currently detected when building source
  1690. packages, but only when extracting
  1691. them.
  1692. </p>
  1693. <p>
  1694. Hard links may be permitted at some point in the
  1695. future, but would require a fair amount of
  1696. work.
  1697. </p>
  1698. </footnote>, device special files, sockets or setuid or
  1699. setgid files.<footnote>
  1700. Setgid directories are allowed.
  1701. </footnote>
  1702. </p>
  1703. </sect>
  1704. <sect id="debianrules">
  1705. <heading>Main building script: <file>debian/rules</file></heading>
  1706. <p>
  1707. This file must be an executable makefile, and contains the
  1708. package-specific recipes for compiling the package and
  1709. building binary package(s) from the source.
  1710. </p>
  1711. <p>
  1712. It must start with the line <tt>#!/usr/bin/make -f</tt>,
  1713. so that it can be invoked by saying its name rather than
  1714. invoking <prgn>make</prgn> explicitly. That is, invoking
  1715. either of <tt>make -f debian/rules <em>args...</em></tt>
  1716. or <tt>./debian/rules <em>args...</em></tt> must result in
  1717. identical behavior.
  1718. </p>
  1719. <p>
  1720. The following targets are required and must be implemented
  1721. by <file>debian/rules</file>: <tt>clean</tt>, <tt>binary</tt>,
  1722. <tt>binary-arch</tt>, <tt>binary-indep</tt>, <tt>build</tt>,
  1723. <tt>build-arch</tt> and <tt>build-indep</tt>.
  1724. These are the targets called by <prgn>dpkg-buildpackage</prgn>.
  1725. </p>
  1726. <p>
  1727. Since an interactive <file>debian/rules</file> script makes it
  1728. impossible to auto-compile that package and also makes it hard
  1729. for other people to reproduce the same binary package, all
  1730. required targets must be non-interactive. It also follows that
  1731. any target that these targets depend on must also be
  1732. non-interactive.
  1733. </p>
  1734. <p>
  1735. For packages in the main archive, no required targets
  1736. may attempt network access.
  1737. </p>
  1738. <p>
  1739. The targets are as follows:
  1740. <taglist>
  1741. <tag><tt>build</tt> (required)</tag>
  1742. <item>
  1743. <p>
  1744. The <tt>build</tt> target should perform all the
  1745. configuration and compilation of the package.
  1746. If a package has an interactive pre-build
  1747. configuration routine, the Debian source package
  1748. must either be built after this has taken place (so
  1749. that the binary package can be built without rerunning
  1750. the configuration) or the configuration routine
  1751. modified to become non-interactive. (The latter is
  1752. preferable if there are architecture-specific features
  1753. detected by the configuration routine.)
  1754. </p>
  1755. <p>
  1756. For some packages, notably ones where the same
  1757. source tree is compiled in different ways to produce
  1758. two binary packages, the <tt>build</tt> target
  1759. does not make much sense. For these packages it is
  1760. good enough to provide two (or more) targets
  1761. (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
  1762. for each of the ways of building the package, and a
  1763. <tt>build</tt> target that does nothing. The
  1764. <tt>binary</tt> target will have to build the
  1765. package in each of the possible ways and make the
  1766. binary package out of each.
  1767. </p>
  1768. <p>
  1769. The <tt>build</tt> target must not do anything
  1770. that might require root privilege.
  1771. </p>
  1772. <p>
  1773. The <tt>build</tt> target may need to run the
  1774. <tt>clean</tt> target first - see below.
  1775. </p>
  1776. <p>
  1777. When a package has a configuration and build routine
  1778. which takes a long time, or when the makefiles are
  1779. poorly designed, or when <tt>build</tt> needs to
  1780. run <tt>clean</tt> first, it is a good idea to
  1781. <tt>touch build</tt> when the build process is
  1782. complete. This will ensure that if <tt>debian/rules
  1783. build</tt> is run again it will not rebuild the whole
  1784. program.<footnote>
  1785. Another common way to do this is for <tt>build</tt>
  1786. to depend on <prgn>build-stamp</prgn> and to do
  1787. nothing else, and for the <prgn>build-stamp</prgn>
  1788. target to do the building and to <tt>touch
  1789. build-stamp</tt> on completion. This is
  1790. especially useful if the build routine creates a
  1791. file or directory called <tt>build</tt>; in such a
  1792. case, <tt>build</tt> will need to be listed as
  1793. a phony target (i.e., as a dependency of the
  1794. <tt>.PHONY</tt> target). See the documentation of
  1795. <prgn>make</prgn> for more information on phony
  1796. targets.
  1797. </footnote>
  1798. </p>
  1799. </item>
  1800. <tag><tt>build-arch</tt> (required),
  1801. <tt>build-indep</tt> (required)
  1802. </tag>
  1803. <item>
  1804. <p>
  1805. The <tt>build-arch</tt> target must
  1806. perform all the configuration and compilation required for
  1807. producing all architecture-dependant binary packages
  1808. (those packages for which the body of the
  1809. <tt>Architecture</tt> field in <tt>debian/control</tt> is
  1810. not <tt>all</tt>). Similarly, the <tt>build-indep</tt>
  1811. target must perform all the configuration
  1812. and compilation required for producing all
  1813. architecture-independent binary packages (those packages
  1814. for which the body of the <tt>Architecture</tt> field
  1815. in <tt>debian/control</tt> is <tt>all</tt>).
  1816. The <tt>build</tt> target
  1817. should either depend on those targets or take the same
  1818. actions as invoking those targets would perform.<footnote>
  1819. This split allows binary-only builds to not install the
  1820. dependencies required for the <tt>build-indep</tt>
  1821. target and skip any resource-intensive build tasks that
  1822. are only required when building architecture-independent
  1823. binary packages.
  1824. </footnote>
  1825. </p>
  1826. <p>
  1827. The <tt>build-arch</tt> and <tt>build-indep</tt> targets
  1828. must not do anything that might require root privilege.
  1829. </p>
  1830. </item>
  1831. <tag><tt>binary</tt> (required), <tt>binary-arch</tt>
  1832. (required), <tt>binary-indep</tt> (required)
  1833. </tag>
  1834. <item>
  1835. <p>
  1836. The <tt>binary</tt> target must be all that is
  1837. necessary for the user to build the binary package(s)
  1838. produced from this source package. It is
  1839. split into two parts: <prgn>binary-arch</prgn> builds
  1840. the binary packages which are specific to a particular
  1841. architecture, and <tt>binary-indep</tt> builds
  1842. those which are not.
  1843. </p>
  1844. <p>
  1845. <tt>binary</tt> may be (and commonly is) a target with
  1846. no commands which simply depends on
  1847. <tt>binary-arch</tt> and <tt>binary-indep</tt>.
  1848. </p>
  1849. <p>
  1850. Both <tt>binary-*</tt> targets should depend on the
  1851. <tt>build</tt> target, or on the appropriate
  1852. <tt>build-arch</tt> or <tt>build-indep</tt> target, if
  1853. provided, so that the package is built if it has not
  1854. been already. It should then create the relevant
  1855. binary package(s), using <prgn>dpkg-gencontrol</prgn> to
  1856. make their control files and <prgn>dpkg-deb</prgn> to
  1857. build them and place them in the parent of the top
  1858. level directory.
  1859. </p>
  1860. <p>
  1861. Both the <tt>binary-arch</tt> and
  1862. <tt>binary-indep</tt> targets <em>must</em> exist.
  1863. If one of them has nothing to do (which will always be
  1864. the case if the source generates only a single binary
  1865. package, whether architecture-dependent or not), it
  1866. must still exist and must always succeed.
  1867. </p>
  1868. <p>
  1869. The <tt>binary</tt> targets must be invoked as
  1870. root.<footnote>
  1871. The <prgn>fakeroot</prgn> package often allows one
  1872. to build a package correctly even without being
  1873. root.
  1874. </footnote>
  1875. </p>
  1876. </item>
  1877. <tag><tt>clean</tt> (required)</tag>
  1878. <item>
  1879. <p>
  1880. This must undo any effects that the <tt>build</tt>
  1881. and <tt>binary</tt> targets may have had, except
  1882. that it should leave alone any output files created in
  1883. the parent directory by a run of a <tt>binary</tt>
  1884. target.
  1885. </p>
  1886. <p>
  1887. If a <tt>build</tt> file is touched at the end of
  1888. the <tt>build</tt> target, as suggested above, it
  1889. should be removed as the first action that
  1890. <tt>clean</tt> performs, so that running
  1891. <tt>build</tt> again after an interrupted
  1892. <tt>clean</tt> doesn't think that everything is
  1893. already done.
  1894. </p>
  1895. <p>
  1896. The <tt>clean</tt> target may need to be
  1897. invoked as root if <tt>binary</tt> has been
  1898. invoked since the last <tt>clean</tt>, or if
  1899. <tt>build</tt> has been invoked as root (since
  1900. <tt>build</tt> may create directories, for
  1901. example).
  1902. </p>
  1903. </item>
  1904. <tag><tt>get-orig-source</tt> (optional)</tag>
  1905. <item>
  1906. <p>
  1907. This target fetches the most recent version of the
  1908. original source package from a canonical archive site
  1909. (via FTP or WWW, for example), does any necessary
  1910. rearrangement to turn it into the original source
  1911. tar file format described below, and leaves it in the
  1912. current directory.
  1913. </p>
  1914. <p>
  1915. This target may be invoked in any directory, and
  1916. should take care to clean up any temporary files it
  1917. may have left.
  1918. </p>
  1919. <p>
  1920. This target is optional, but providing it if
  1921. possible is a good idea.
  1922. </p>
  1923. </item>
  1924. <tag><tt>patch</tt> (optional)</tag>
  1925. <item>
  1926. <p>
  1927. This target performs whatever additional actions are
  1928. required to make the source ready for editing (unpacking
  1929. additional upstream archives, applying patches, etc.).
  1930. It is recommended to be implemented for any package where
  1931. <tt>dpkg-source -x</tt> does not result in source ready
  1932. for additional modification. See
  1933. <ref id="readmesource">.
  1934. </p>
  1935. </item>
  1936. </taglist>
  1937. <p>
  1938. The <tt>build</tt>, <tt>binary</tt> and
  1939. <tt>clean</tt> targets must be invoked with the current
  1940. directory being the package's top-level directory.
  1941. </p>
  1942. <p>
  1943. Additional targets may exist in <file>debian/rules</file>,
  1944. either as published or undocumented interfaces or for the
  1945. package's internal use.
  1946. </p>
  1947. <p>
  1948. The architectures we build on and build for are determined
  1949. by <prgn>make</prgn> variables using the
  1950. utility <prgn>dpkg-architecture</prgn>.
  1951. You can determine the Debian architecture and the GNU style
  1952. architecture specification string for the build architecture as
  1953. well as for the host architecture. The build architecture is
  1954. the architecture on which <file>debian/rules</file> is run and
  1955. the package build is performed. The host architecture is the
  1956. architecture on which the resulting package will be installed
  1957. and run. These are normally the same, but may be different in
  1958. the case of cross-compilation (building packages for one
  1959. architecture on machines of a different architecture).
  1960. </p>
  1961. <p>
  1962. Here is a list of supported <prgn>make</prgn> variables:
  1963. <list compact="compact">
  1964. <item>
  1965. <tt>DEB_*_ARCH</tt> (the Debian architecture)
  1966. </item>
  1967. <item>
  1968. <tt>DEB_*_ARCH_CPU</tt> (the Debian CPU name)
  1969. </item>
  1970. <item>
  1971. <tt>DEB_*_ARCH_OS</tt> (the Debian System name)
  1972. </item>
  1973. <item>
  1974. <tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
  1975. specification string)
  1976. </item>
  1977. <item>
  1978. <tt>DEB_*_GNU_CPU</tt> (the CPU part of
  1979. <tt>DEB_*_GNU_TYPE</tt>)
  1980. </item>
  1981. <item>
  1982. <tt>DEB_*_GNU_SYSTEM</tt> (the System part of
  1983. <tt>DEB_*_GNU_TYPE</tt>)
  1984. </list>
  1985. where <tt>*</tt> is either <tt>BUILD</tt> for specification of
  1986. the build architecture or <tt>HOST</tt> for specification of the
  1987. host architecture.
  1988. </p>
  1989. <p>
  1990. Backward compatibility can be provided in the rules file
  1991. by setting the needed variables to suitable default
  1992. values; please refer to the documentation of
  1993. <prgn>dpkg-architecture</prgn> for details.
  1994. </p>
  1995. <p>
  1996. It is important to understand that the <tt>DEB_*_ARCH</tt>
  1997. string only determines which Debian architecture we are
  1998. building on or for. It should not be used to get the CPU
  1999. or system information; the <tt>DEB_*_ARCH_CPU</tt> and
  2000. <tt>DEB_*_ARCH_OS</tt> variables should be used for that.
  2001. GNU style variables should generally only be used with upstream
  2002. build systems.
  2003. </p>
  2004. <sect1 id="debianrules-options">
  2005. <heading><file>debian/rules</file> and
  2006. <tt>DEB_BUILD_OPTIONS</tt></heading>
  2007. <p>
  2008. Supporting the standardized environment variable
  2009. <tt>DEB_BUILD_OPTIONS</tt> is recommended. This variable can
  2010. contain several flags to change how a package is compiled and
  2011. built. Each flag must be in the form <var>flag</var> or
  2012. <var>flag</var>=<var>options</var>. If multiple flags are
  2013. given, they must be separated by whitespace.<footnote>
  2014. Some packages support any delimiter, but whitespace is the
  2015. easiest to parse inside a makefile and avoids ambiguity with
  2016. flag values that contain commas.
  2017. </footnote>
  2018. <var>flag</var> must start with a lowercase letter
  2019. (<tt>a-z</tt>) and consist only of lowercase letters,
  2020. numbers (<tt>0-9</tt>), and the characters
  2021. <tt>-</tt> and <tt>_</tt> (hyphen and underscore).
  2022. <var>options</var> must not contain whitespace. The same
  2023. tag should not be given multiple times with conflicting
  2024. values. Package maintainers may assume that
  2025. <tt>DEB_BUILD_OPTIONS</tt> will not contain conflicting tags.
  2026. </p>
  2027. <p>
  2028. The meaning of the following tags has been standardized:
  2029. <taglist>
  2030. <tag>nocheck</tag>
  2031. <item>
  2032. This tag says to not run any build-time test suite
  2033. provided by the package.
  2034. </item>
  2035. <tag>noopt</tag>
  2036. <item>
  2037. The presence of this tag means that the package should
  2038. be compiled with a minimum of optimization. For C
  2039. programs, it is best to add <tt>-O0</tt> to
  2040. <tt>CFLAGS</tt> (although this is usually the default).
  2041. Some programs might fail to build or run at this level
  2042. of optimization; it may be necessary to use
  2043. <tt>-O1</tt>, for example.
  2044. </item>
  2045. <tag>nostrip</tag>
  2046. <item>
  2047. This tag means that the debugging symbols should not be
  2048. stripped from the binary during installation, so that
  2049. debugging information may be included in the package.
  2050. </item>
  2051. <tag>parallel=n</tag>
  2052. <item>
  2053. This tag means that the package should be built using up
  2054. to <tt>n</tt> parallel processes if the package build
  2055. system supports this.<footnote>
  2056. Packages built with <tt>make</tt> can often implement
  2057. this by passing the <tt>-j</tt><var>n</var> option to
  2058. <tt>make</tt>.
  2059. </footnote>
  2060. If the package build system does not support parallel
  2061. builds, this string must be ignored. If the package
  2062. build system only supports a lower level of concurrency
  2063. than <var>n</var>, the package should be built using as
  2064. many parallel processes as the package build system
  2065. supports. It is up to the package maintainer to decide
  2066. whether the package build times are long enough and the
  2067. package build system is robust enough to make supporting
  2068. parallel builds worthwhile.
  2069. </item>
  2070. </taglist>
  2071. </p>
  2072. <p>
  2073. Unknown flags must be ignored by <file>debian/rules</file>.
  2074. </p>
  2075. <p>
  2076. The following makefile snippet is an example of how one may
  2077. implement the build options; you will probably have to
  2078. massage this example in order to make it work for your
  2079. package.
  2080. <example compact="compact">
  2081. CFLAGS = -Wall -g
  2082. INSTALL = install
  2083. INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
  2084. INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
  2085. INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
  2086. INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
  2087. ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
  2088. CFLAGS += -O0
  2089. else
  2090. CFLAGS += -O2
  2091. endif
  2092. ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
  2093. INSTALL_PROGRAM += -s
  2094. endif
  2095. ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  2096. NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  2097. MAKEFLAGS += -j$(NUMJOBS)
  2098. endif
  2099. build:
  2100. # ...
  2101. ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
  2102. # Code to run the package test suite.
  2103. endif
  2104. </example>
  2105. </p>
  2106. </sect1>
  2107. </sect>
  2108. <!-- FIXME: section pkg-srcsubstvars is the same as substvars -->
  2109. <sect id="substvars">
  2110. <heading>Variable substitutions: <file>debian/substvars</file></heading>
  2111. <p>
  2112. When <prgn>dpkg-gencontrol</prgn>
  2113. generates <qref id="binarycontrolfiles">binary package control
  2114. files</qref> (<file>DEBIAN/control</file>), it performs variable
  2115. substitutions on its output just before writing it. Variable
  2116. substitutions have the form <tt>${<var>variable</var>}</tt>.
  2117. The optional file <file>debian/substvars</file> contains
  2118. variable substitutions to be used; variables can also be set
  2119. directly from <file>debian/rules</file> using the <tt>-V</tt>
  2120. option to the source packaging commands, and certain predefined
  2121. variables are also available.
  2122. </p>
  2123. <p>
  2124. The <file>debian/substvars</file> file is usually generated and
  2125. modified dynamically by <file>debian/rules</file> targets, in
  2126. which case it must be removed by the <tt>clean</tt> target.
  2127. </p>
  2128. <p>
  2129. See <manref name="deb-substvars" section="5"> for full
  2130. details about source variable substitutions, including the
  2131. format of <file>debian/substvars</file>.</p>
  2132. </sect>
  2133. <sect id="debianwatch">
  2134. <heading>Optional upstream source location: <file>debian/watch</file></heading>
  2135. <p>
  2136. This is an optional, recommended configuration file for the
  2137. <tt>uscan</tt> utility which defines how to automatically scan
  2138. ftp or http sites for newly available updates of the
  2139. package. This is used Debian QA
  2140. tools to help with quality control and maintenance of the
  2141. distribution as a whole.
  2142. </p>
  2143. </sect>
  2144. <sect id="debianfiles">
  2145. <heading>Generated files list: <file>debian/files</file></heading>
  2146. <p>
  2147. This file is not a permanent part of the source tree; it
  2148. is used while building packages to record which files are
  2149. being generated. <prgn>dpkg-genchanges</prgn> uses it
  2150. when it generates a <file>.changes</file> file.
  2151. </p>
  2152. <p>
  2153. It should not exist in a shipped source package, and so it
  2154. (and any backup files or temporary files such as
  2155. <file>files.new</file><footnote>
  2156. <file>files.new</file> is used as a temporary file by
  2157. <prgn>dpkg-gencontrol</prgn> and
  2158. <prgn>dpkg-distaddfile</prgn> - they write a new
  2159. version of <tt>files</tt> here before renaming it,
  2160. to avoid leaving a corrupted copy if an error
  2161. occurs.
  2162. </footnote>) should be removed by the
  2163. <tt>clean</tt> target. It may also be wise to
  2164. ensure a fresh start by emptying or removing it at the
  2165. start of the <tt>binary</tt> target.
  2166. </p>
  2167. <p>
  2168. When <prgn>dpkg-gencontrol</prgn> is run for a binary
  2169. package, it adds an entry to <file>debian/files</file> for the
  2170. <file>.deb</file> file that will be created when <tt>dpkg-deb
  2171. --build</tt> is run for that binary package. So for most
  2172. packages all that needs to be done with this file is to
  2173. delete it in the <tt>clean</tt> target.
  2174. </p>
  2175. <p>
  2176. If a package upload includes files besides the source
  2177. package and any binary packages whose control files were
  2178. made with <prgn>dpkg-gencontrol</prgn> then they should be
  2179. placed in the parent of the package's top-level directory
  2180. and <prgn>dpkg-distaddfile</prgn> should be called to add
  2181. the file to the list in <file>debian/files</file>.</p>
  2182. </sect>
  2183. <sect id="embeddedfiles">
  2184. <heading>Convenience copies of code</heading>
  2185. <p>
  2186. Some software packages include in their distribution convenience
  2187. copies of code from other software packages, generally so that
  2188. users compiling from source don't have to download multiple
  2189. packages. Debian packages should not make use of these
  2190. convenience copies unless the included package is explicitly
  2191. intended to be used in this way.<footnote>
  2192. For example, parts of the GNU build system work like this.
  2193. </footnote>
  2194. If the included code is already in the Debian archive in the
  2195. form of a library, the Debian packaging should ensure that
  2196. binary packages reference the libraries already in Debian and
  2197. the convenience copy is not used. If the included code is not
  2198. already in Debian, it should be packaged separately as a
  2199. prerequisite if possible.
  2200. <footnote>
  2201. Having multiple copies of the same code in Debian is
  2202. inefficient, often creates either static linking or shared
  2203. library conflicts, and, most importantly, increases the
  2204. difficulty of handling security vulnerabilities in the
  2205. duplicated code.
  2206. </footnote>
  2207. </p>
  2208. </sect>
  2209. <sect id="readmesource">
  2210. <heading>Source package handling:
  2211. <file>debian/README.source</file></heading>
  2212. <p>
  2213. If running <prgn>dpkg-source -x</prgn> on a source package
  2214. doesn't produce the source of the package, ready for editing,
  2215. and allow one to make changes and run
  2216. <prgn>dpkg-buildpackage</prgn> to produce a modified package
  2217. without taking any additional steps, creating a
  2218. <file>debian/README.source</file> documentation file is
  2219. recommended. This file should explain how to do all of the
  2220. following:
  2221. <enumlist>
  2222. <item>Generate the fully patched source, in a form ready for
  2223. editing, that would be built to create Debian
  2224. packages. Doing this with a <tt>patch</tt> target in
  2225. <file>debian/rules</file> is recommended; see
  2226. <ref id="debianrules">.</item>
  2227. <item>Modify the source and save those modifications so that
  2228. they will be applied when building the package.</item>
  2229. <item>Remove source modifications that are currently being
  2230. applied when building the package.</item>
  2231. <item>Optionally, document what steps are necessary to
  2232. upgrade the Debian source package to a new upstream version,
  2233. if applicable.</item>
  2234. </enumlist>
  2235. This explanation should include specific commands and mention
  2236. any additional required Debian packages. It should not assume
  2237. familiarity with any specific Debian packaging system or patch
  2238. management tools.
  2239. </p>
  2240. <p>
  2241. This explanation may refer to a documentation file installed by
  2242. one of the package's build dependencies provided that the
  2243. referenced documentation clearly explains these tasks and is not
  2244. a general reference manual.
  2245. </p>
  2246. <p>
  2247. <file>debian/README.source</file> may also include any other
  2248. information that would be helpful to someone modifying the
  2249. source package. Even if the package doesn't fit the above
  2250. description, maintainers are encouraged to document in a
  2251. <file>debian/README.source</file> file any source package with a
  2252. particularly complex or unintuitive source layout or build
  2253. system (for example, a package that builds the same source
  2254. multiple times to generate different binary packages).
  2255. </p>
  2256. </sect>
  2257. </chapt>
  2258. <chapt id="controlfields">
  2259. <heading>Control files and their fields</heading>
  2260. <p>
  2261. The package management system manipulates data represented in
  2262. a common format, known as <em>control data</em>, stored in
  2263. <em>control files</em>.
  2264. Control files are used for source packages, binary packages and
  2265. the <file>.changes</file> files which control the installation
  2266. of uploaded files<footnote>
  2267. <prgn>dpkg</prgn>'s internal databases are in a similar
  2268. format.
  2269. </footnote>.
  2270. </p>
  2271. <sect id="controlsyntax">
  2272. <heading>Syntax of control files</heading>
  2273. <p>
  2274. A control file consists of one or more paragraphs of
  2275. fields<footnote>
  2276. The paragraphs are also sometimes referred to as stanzas.
  2277. </footnote>.
  2278. The paragraphs are separated by empty lines. Parsers may accept
  2279. lines consisting solely of spaces and tabs as paragraph
  2280. separators, but control files should use empty lines. Some control
  2281. files allow only one paragraph; others allow several, in
  2282. which case each paragraph usually refers to a different
  2283. package. (For example, in source packages, the first
  2284. paragraph refers to the source package, and later paragraphs
  2285. refer to binary packages generated from the source.) The
  2286. ordering of the paragraphs in control files is significant.
  2287. </p>
  2288. <p>
  2289. Each paragraph consists of a series of data fields. Each field
  2290. consists of the field name followed by a colon and then the
  2291. data/value associated with that field. The field name is
  2292. composed of US-ASCII characters excluding control characters,
  2293. space, and colon (i.e., characters in the ranges 33-57 and
  2294. 59-126, inclusive). Field names must not begin with the comment
  2295. character, <tt>#</tt>, nor with the hyphen character, <tt>-</tt>.
  2296. </p>
  2297. <p>
  2298. The field ends at the end of the line or at the end of the last
  2299. continuation line (see below). Horizontal whitespace (spaces
  2300. and tabs) may occur immediately before or after the value and is
  2301. ignored there; it is conventional to put a single space after
  2302. the colon. For example, a field might be:
  2303. <example compact="compact">
  2304. Package: libc6
  2305. </example>
  2306. the field name is <tt>Package</tt> and the field value
  2307. <tt>libc6</tt>.
  2308. </p>
  2309. <p> Empty field values are only permitted in source package control files
  2310. (<file>debian/control</file>). Such fields are ignored.
  2311. </p>
  2312. <p>
  2313. A paragraph must not contain more than one instance of a
  2314. particular field name.
  2315. </p>
  2316. <p>
  2317. There are three types of fields:
  2318. <taglist>
  2319. <tag>simple</tag>
  2320. <item>
  2321. The field, including its value, must be a single line. Folding
  2322. of the field is not permitted. This is the default field type
  2323. if the definition of the field does not specify a different
  2324. type.
  2325. </item>
  2326. <tag>folded</tag>
  2327. <item>
  2328. The value of a folded field is a logical line that may span
  2329. several lines. The lines after the first are called
  2330. continuation lines and must start with a space or a tab.
  2331. Whitespace, including any newlines, is not significant in the
  2332. field values of folded fields.<footnote>
  2333. This folding method is similar to RFC 5322, allowing control
  2334. files that contain only one paragraph and no multiline fields
  2335. to be read by parsers written for RFC 5322.
  2336. </footnote>
  2337. </item>
  2338. <tag>multiline</tag>
  2339. <item>
  2340. The value of a multiline field may comprise multiple continuation
  2341. lines. The first line of the value, the part on the same line as
  2342. the field name, often has special significance or may have to be
  2343. empty. Other lines are added following the same syntax as the
  2344. continuation lines of the folded fields. Whitespace, including newlines,
  2345. is significant in the values of multiline fields.
  2346. </item>
  2347. </taglist>
  2348. </p>
  2349. <p>
  2350. Whitespace must not appear
  2351. inside names (of packages, architectures, files or anything
  2352. else) or version numbers, or between the characters of
  2353. multi-character version relationships.
  2354. </p>
  2355. <p>
  2356. The presence and purpose of a field, and the syntax of its
  2357. value may differ between types of control files.
  2358. </p>
  2359. <p>
  2360. Field names are not case-sensitive, but it is usual to
  2361. capitalize the field names using mixed case as shown below.
  2362. Field values are case-sensitive unless the description of the
  2363. field says otherwise.
  2364. </p>
  2365. <p>
  2366. Paragraph separators (empty lines) and lines consisting only of
  2367. spaces and tabs are not allowed within field values or between
  2368. fields. Empty lines in field values are usually escaped by
  2369. representing them by a space followed by a dot.
  2370. </p>
  2371. <p>
  2372. Lines starting with # without any preceding whitespace are comments
  2373. lines that are only permitted in source package control files
  2374. (<file>debian/control</file>). These comment lines are ignored, even
  2375. between two continuation lines. They do not end logical lines.
  2376. </p>
  2377. <p>
  2378. All control files must be encoded in UTF-8.
  2379. </p>
  2380. </sect>
  2381. <sect id="sourcecontrolfiles">
  2382. <heading>Source package control files -- <file>debian/control</file></heading>
  2383. <p>
  2384. The <file>debian/control</file> file contains the most vital
  2385. (and version-independent) information about the source package
  2386. and about the binary packages it creates.
  2387. </p>
  2388. <p>
  2389. The first paragraph of the control file contains information about
  2390. the source package in general. The subsequent sets each describe a
  2391. binary package that the source tree builds.
  2392. </p>
  2393. <p>
  2394. The fields in the general paragraph (the first one, for the source
  2395. package) are:
  2396. <list compact="compact">
  2397. <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
  2398. <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
  2399. <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
  2400. <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
  2401. <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
  2402. <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
  2403. <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
  2404. <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
  2405. <item><qref id="f-VCS-fields"><tt>Vcs-Browser</tt>, <tt>Vcs-Git</tt>, et al.</qref></item>
  2406. </list>
  2407. </p>
  2408. <p>
  2409. The fields in the binary package paragraphs are:
  2410. <list compact="compact">
  2411. <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
  2412. <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
  2413. <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
  2414. <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
  2415. <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
  2416. <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
  2417. <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
  2418. <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
  2419. <item><qref id="built-using"><tt>Built-Using</tt></qref></item>
  2420. <item><qref id="f-Package-Type"><tt>Package-Type</tt></qref></item>
  2421. </list>
  2422. </p>
  2423. <p>
  2424. The syntax and semantics of the fields are described below.
  2425. </p>
  2426. <p>
  2427. These fields are used by <prgn>dpkg-gencontrol</prgn> to
  2428. generate control files for binary packages (see below), by
  2429. <prgn>dpkg-genchanges</prgn> to generate the
  2430. <file>.changes</file> file to accompany the upload, and by
  2431. <prgn>dpkg-source</prgn> when it creates the
  2432. <file>.dsc</file> source control file as part of a source
  2433. archive. Some fields are folded in <file>debian/control</file>,
  2434. but not in any other control
  2435. file. These tools are responsible for removing the line
  2436. breaks from such fields when using fields from
  2437. <file>debian/control</file> to generate other control files.
  2438. They are also responsible for discarding empty fields.
  2439. </p>
  2440. <p>
  2441. The fields here may contain variable references - their
  2442. values will be substituted by <prgn>dpkg-gencontrol</prgn>,
  2443. <prgn>dpkg-genchanges</prgn> or <prgn>dpkg-source</prgn>
  2444. when they generate output control files.
  2445. See <ref id="substvars"> for details.
  2446. </p>
  2447. </sect>
  2448. <sect id="binarycontrolfiles">
  2449. <heading>Binary package control files -- <file>DEBIAN/control</file></heading>
  2450. <p>
  2451. The <file>DEBIAN/control</file> file contains the most vital
  2452. (and version-dependent) information about a binary package. It
  2453. consists of a single paragraph.
  2454. </p>
  2455. <p>
  2456. The fields in this file are:
  2457. <list compact="compact">
  2458. <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
  2459. <item><qref id="f-Source"><tt>Source</tt></qref></item>
  2460. <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
  2461. <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
  2462. <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
  2463. <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
  2464. <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
  2465. <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
  2466. <item><qref id="f-Installed-Size"><tt>Installed-Size</tt></qref></item>
  2467. <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
  2468. <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
  2469. <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
  2470. <item><qref id="built-using"><tt>Built-Using</tt></qref></item>
  2471. </list>
  2472. </p>
  2473. </sect>
  2474. <sect id="debiansourcecontrolfiles">
  2475. <heading>Debian source control files -- <tt>.dsc</tt></heading>
  2476. <p>
  2477. This file consists of a single paragraph, possibly surrounded by
  2478. a PGP signature. The fields of that paragraph are listed below.
  2479. Their syntax is described above, in <ref id="controlsyntax">.
  2480. <list compact="compact">
  2481. <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
  2482. <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
  2483. <item><qref id="f-Binary"><tt>Binary</tt></qref></item>
  2484. <item><qref id="f-Architecture"><tt>Architecture</tt></qref></item>
  2485. <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
  2486. <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
  2487. <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
  2488. <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
  2489. <item><qref id="f-VCS-fields"><tt>Vcs-Browser</tt>, <tt>Vcs-Git</tt>, et al.</qref></item>
  2490. <item><qref id="f-Dgit"><tt>Dgit</tt></qref></item>
  2491. <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
  2492. <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
  2493. <item><qref id="f-Package-List"><tt>Package-List</tt></qref> (recommended)</item>
  2494. <item><qref id="f-Checksums"><tt>Checksums-Sha1</tt>
  2495. and <tt>Checksums-Sha256</tt></qref> (mandatory)</item>
  2496. <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
  2497. </list>
  2498. </p>
  2499. <p>
  2500. The Debian source control file is generated by
  2501. <prgn>dpkg-source</prgn> when it builds the source
  2502. archive, from other files in the source package,
  2503. described above. When unpacking, it is checked against
  2504. the files and directories in the other parts of the
  2505. source package.
  2506. </p>
  2507. </sect>
  2508. <sect id="debianchangesfiles">
  2509. <heading>Debian changes files -- <file>.changes</file></heading>
  2510. <p>
  2511. The <file>.changes</file> files are used by the Debian archive
  2512. maintenance software to process updates to packages. They
  2513. consist of a single paragraph, possibly surrounded by a PGP
  2514. signature. That paragraph contains information from the
  2515. <file>debian/control</file> file and other data about the
  2516. source package gathered via <file>debian/changelog</file>
  2517. and <file>debian/rules</file>.
  2518. </p>
  2519. <p>
  2520. <file>.changes</file> files have a format version that is
  2521. incremented whenever the documented fields or their meaning
  2522. change. This document describes format &changesversion;.
  2523. </p>
  2524. <p>
  2525. The fields in this file are:
  2526. <list compact="compact">
  2527. <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
  2528. <item><qref id="f-Date"><tt>Date</tt></qref> (mandatory)</item>
  2529. <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
  2530. <item><qref id="f-Binary"><tt>Binary</tt></qref> (mandatory)</item>
  2531. <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
  2532. <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
  2533. <item><qref id="f-Distribution"><tt>Distribution</tt></qref> (mandatory)</item>
  2534. <item><qref id="f-Urgency"><tt>Urgency</tt></qref> (recommended)</item>
  2535. <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
  2536. <item><qref id="f-Changed-By"><tt>Changed-By</tt></qref></item>
  2537. <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
  2538. <item><qref id="f-Closes"><tt>Closes</tt></qref></item>
  2539. <item><qref id="f-Changes"><tt>Changes</tt></qref> (mandatory)</item>
  2540. <item><qref id="f-Checksums"><tt>Checksums-Sha1</tt>
  2541. and <tt>Checksums-Sha256</tt></qref> (mandatory)</item>
  2542. <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
  2543. </list>
  2544. </p>
  2545. </sect>
  2546. <sect id="controlfieldslist">
  2547. <heading>List of fields</heading>
  2548. <sect1 id="f-Source">
  2549. <heading><tt>Source</tt></heading>
  2550. <p>
  2551. This field identifies the source package name.
  2552. </p>
  2553. <p>
  2554. In <file>debian/control</file> or a <file>.dsc</file> file,
  2555. this field must contain only the name of the source package.
  2556. </p>
  2557. <p>
  2558. In a binary package control file or a <file>.changes</file>
  2559. file, the source package name may be followed by a version
  2560. number in parentheses<footnote>
  2561. It is customary to leave a space after the package name
  2562. if a version number is specified.
  2563. </footnote>.
  2564. This version number may be omitted (and is, by
  2565. <prgn>dpkg-gencontrol</prgn>) if it has the same value as
  2566. the <tt>Version</tt> field of the binary package in
  2567. question. The field itself may be omitted from a binary
  2568. package control file when the source package has the same
  2569. name and version as the binary package.
  2570. </p>
  2571. <p>
  2572. Package names (both source and binary,
  2573. see <ref id="f-Package">) must consist only of lower case
  2574. letters (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus
  2575. (<tt>+</tt>) and minus (<tt>-</tt>) signs, and periods
  2576. (<tt>.</tt>). They must be at least two characters long and
  2577. must start with an alphanumeric character.
  2578. </p>
  2579. </sect1>
  2580. <sect1 id="f-Maintainer">
  2581. <heading><tt>Maintainer</tt></heading>
  2582. <p>
  2583. The package maintainer's name and email address. The name
  2584. must come first, then the email address inside angle
  2585. brackets <tt>&lt;&gt;</tt> (in RFC822 format).
  2586. </p>
  2587. <p>
  2588. If the maintainer's name contains a full stop then the
  2589. whole field will not work directly as an email address due
  2590. to a misfeature in the syntax specified in RFC822; a
  2591. program using this field as an address must check for this
  2592. and correct the problem if necessary (for example by
  2593. putting the name in round brackets and moving it to the
  2594. end, and bringing the email address forward).
  2595. </p>
  2596. <p>
  2597. See <ref id="maintainer"> for additional requirements and
  2598. information about package maintainers.
  2599. </p>
  2600. </sect1>
  2601. <sect1 id="f-Uploaders">
  2602. <heading><tt>Uploaders</tt></heading>
  2603. <p>
  2604. List of the names and email addresses of co-maintainers of the
  2605. package, if any. If the package has other maintainers besides
  2606. the one named in the <qref id="f-Maintainer">Maintainer
  2607. field</qref>, their names and email addresses should be listed
  2608. here. The format of each entry is the same as that of the
  2609. Maintainer field, and multiple entries must be comma
  2610. separated.
  2611. </p>
  2612. <p>
  2613. This is normally an optional field, but if
  2614. the <tt>Maintainer</tt> control field names a group of people
  2615. and a shared email address, the <tt>Uploaders</tt> field must
  2616. be present and must contain at least one human with their
  2617. personal email address.
  2618. </p>
  2619. <p>
  2620. The Uploaders field in <file>debian/control</file> can be folded.
  2621. </p>
  2622. </sect1>
  2623. <sect1 id="f-Changed-By">
  2624. <heading><tt>Changed-By</tt></heading>
  2625. <p>
  2626. The name and email address of the person who prepared this
  2627. version of the package, usually a maintainer. The syntax is
  2628. the same as for the <qref id="f-Maintainer">Maintainer
  2629. field</qref>.
  2630. </p>
  2631. </sect1>
  2632. <sect1 id="f-Section">
  2633. <heading><tt>Section</tt></heading>
  2634. <p>
  2635. This field specifies an application area into which the package
  2636. has been classified. See <ref id="subsections">.
  2637. </p>
  2638. <p>
  2639. When it appears in the <file>debian/control</file> file,
  2640. it gives the value for the subfield of the same name in
  2641. the <tt>Files</tt> field of the <file>.changes</file> file.
  2642. It also gives the default for the same field in the binary
  2643. packages.
  2644. </p>
  2645. </sect1>
  2646. <sect1 id="f-Priority">
  2647. <heading><tt>Priority</tt></heading>
  2648. <p>
  2649. This field represents how important it is that the user
  2650. have the package installed. See <ref id="priorities">.
  2651. </p>
  2652. <p>
  2653. When it appears in the <file>debian/control</file> file,
  2654. it gives the value for the subfield of the same name in
  2655. the <tt>Files</tt> field of the <file>.changes</file> file.
  2656. It also gives the default for the same field in the binary
  2657. packages.
  2658. </p>
  2659. </sect1>
  2660. <sect1 id="f-Package">
  2661. <heading><tt>Package</tt></heading>
  2662. <p>
  2663. The name of the binary package.
  2664. </p>
  2665. <p>
  2666. Binary package names must follow the same syntax and
  2667. restrictions as source package names. See <ref id="f-Source">
  2668. for the details.
  2669. </p>
  2670. </sect1>
  2671. <sect1 id="f-Architecture">
  2672. <heading><tt>Architecture</tt></heading>
  2673. <p>
  2674. Depending on context and the control file used, the
  2675. <tt>Architecture</tt> field can include the following sets of
  2676. values:
  2677. <list>
  2678. <item>
  2679. A unique single word identifying a Debian machine
  2680. architecture as described in <ref id="arch-spec">.
  2681. </item>
  2682. <item>
  2683. An architecture wildcard identifying a set of Debian
  2684. machine architectures, see <ref id="arch-wildcard-spec">.
  2685. <tt>any</tt> matches all Debian machine architectures
  2686. and is the most frequently used.
  2687. </item>
  2688. <item>
  2689. <tt>all</tt>, which indicates an
  2690. architecture-independent package.
  2691. </item>
  2692. <item>
  2693. <tt>source</tt>, which indicates a source package.
  2694. </item>
  2695. </list>
  2696. </p>
  2697. <p>
  2698. In the main <file>debian/control</file> file in the source
  2699. package, this field may contain the special
  2700. value <tt>all</tt>, the special architecture
  2701. wildcard <tt>any</tt>, or a list of specific and wildcard
  2702. architectures separated by spaces. If <tt>all</tt>
  2703. or <tt>any</tt> appears, that value must be the entire
  2704. contents of the field. Most packages will use
  2705. either <tt>all</tt> or <tt>any</tt>.
  2706. </p>
  2707. <p>
  2708. Specifying a specific list of architectures indicates that the
  2709. source will build an architecture-dependent package only on
  2710. architectures included in the list. Specifying a list of
  2711. architecture wildcards indicates that the source will build an
  2712. architecture-dependent package on only those architectures
  2713. that match any of the specified architecture wildcards.
  2714. Specifying a list of architectures or architecture wildcards
  2715. other than <tt>any</tt> is for the minority of cases where a
  2716. program is not portable or is not useful on some
  2717. architectures. Where possible, the program should be made
  2718. portable instead.
  2719. </p>
  2720. <p>
  2721. In the Debian source control file <file>.dsc</file>, this
  2722. field contains a list of architectures and architecture
  2723. wildcards separated by spaces. When the list contains the
  2724. architecture wildcard <tt>any</tt>, the only other value
  2725. allowed in the list is <tt>all</tt>.
  2726. </p>
  2727. <p>
  2728. The list may include (or consist solely of) the special
  2729. value <tt>all</tt>. In other words, in <file>.dsc</file>
  2730. files unlike the <file>debian/control</file>, <tt>all</tt> may
  2731. occur in combination with specific architectures.
  2732. The <tt>Architecture</tt> field in the Debian source control
  2733. file <file>.dsc</file> is generally constructed from
  2734. the <tt>Architecture</tt> fields in
  2735. the <file>debian/control</file> in the source package.
  2736. </p>
  2737. <p>
  2738. Specifying only <tt>any</tt> indicates that the source package
  2739. isn't dependent on any particular architecture and should
  2740. compile fine on any one. The produced binary package(s)
  2741. will be specific to whatever the current build architecture is.
  2742. </p>
  2743. <p>
  2744. Specifying only <tt>all</tt> indicates that the source package
  2745. will only build architecture-independent packages.
  2746. </p>
  2747. <p>
  2748. Specifying <tt>any all</tt> indicates that the source package
  2749. isn't dependent on any particular architecture. The set of
  2750. produced binary packages will include at least one
  2751. architecture-dependant package and one architecture-independent
  2752. package.
  2753. </p>
  2754. <p>
  2755. Specifying a list of architectures or architecture wildcards
  2756. indicates that the source will build an architecture-dependent
  2757. package, and will only work correctly on the listed or
  2758. matching architectures. If the source package also builds at
  2759. least one architecture-independent package, <tt>all</tt> will
  2760. also be included in the list.
  2761. </p>
  2762. <p>
  2763. In a <file>.changes</file> file, the <tt>Architecture</tt>
  2764. field lists the architecture(s) of the package(s) currently
  2765. being uploaded. This will be a list; if the source for the
  2766. package is also being uploaded, the special
  2767. entry <tt>source</tt> is also present. <tt>all</tt> will be
  2768. present if any architecture-independent packages are being
  2769. uploaded. Architecture wildcards such as <tt>any</tt> must
  2770. never occur in the <tt>Architecture</tt> field in
  2771. the <file>.changes</file> file.
  2772. </p>
  2773. <p>
  2774. See <ref id="debianrules"> for information on how to get
  2775. the architecture for the build process.
  2776. </p>
  2777. </sect1>
  2778. <sect1 id="f-Essential">
  2779. <heading><tt>Essential</tt></heading>
  2780. <p>
  2781. This is a boolean field which may occur only in the
  2782. control file of a binary package or in a per-package fields
  2783. paragraph of a source package control file.
  2784. </p>
  2785. <p>
  2786. If set to <tt>yes</tt> then the package management system
  2787. will refuse to remove the package (upgrading and replacing
  2788. it is still possible). The other possible value is <tt>no</tt>,
  2789. which is the same as not having the field at all.
  2790. </p>
  2791. </sect1>
  2792. <sect1>
  2793. <heading>Package interrelationship fields:
  2794. <tt>Depends</tt>, <tt>Pre-Depends</tt>,
  2795. <tt>Recommends</tt>, <tt>Suggests</tt>,
  2796. <tt>Breaks</tt>, <tt>Conflicts</tt>,
  2797. <tt>Provides</tt>, <tt>Replaces</tt>, <tt>Enhances</tt>
  2798. </heading>
  2799. <p>
  2800. These fields describe the package's relationships with
  2801. other packages. Their syntax and semantics are described
  2802. in <ref id="relationships">.</p>
  2803. </sect1>
  2804. <sect1 id="f-Standards-Version">
  2805. <heading><tt>Standards-Version</tt></heading>
  2806. <p>
  2807. The most recent version of the standards (the policy
  2808. manual and associated texts) with which the package
  2809. complies.
  2810. </p>
  2811. <p>
  2812. The version number has four components: major and minor
  2813. version number and major and minor patch level. When the
  2814. standards change in a way that requires every package to
  2815. change the major number will be changed. Significant
  2816. changes that will require work in many packages will be
  2817. signaled by a change to the minor number. The major patch
  2818. level will be changed for any change to the meaning of the
  2819. standards, however small; the minor patch level will be
  2820. changed when only cosmetic, typographical or other edits
  2821. are made which neither change the meaning of the document
  2822. nor affect the contents of packages.
  2823. </p>
  2824. <p>
  2825. Thus only the first three components of the policy version
  2826. are significant in the <em>Standards-Version</em> control
  2827. field, and so either these three components or all four
  2828. components may be specified.<footnote>
  2829. In the past, people specified the full version number
  2830. in the Standards-Version field, for example "2.3.0.0".
  2831. Since minor patch-level changes don't introduce new
  2832. policy, it was thought it would be better to relax
  2833. policy and only require the first 3 components to be
  2834. specified, in this example "2.3.0". All four
  2835. components may still be used if someone wishes to do so.
  2836. </footnote>
  2837. </p>
  2838. </sect1>
  2839. <sect1 id="f-Version">
  2840. <heading><tt>Version</tt></heading>
  2841. <p>
  2842. The version number of a package. The format is:
  2843. [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
  2844. </p>
  2845. <p>
  2846. The three components here are:
  2847. <taglist>
  2848. <tag><var>epoch</var></tag>
  2849. <item>
  2850. <p>
  2851. This is a single (generally small) unsigned integer. It
  2852. may be omitted, in which case zero is assumed. If it is
  2853. omitted then the <var>upstream_version</var> may not
  2854. contain any colons.
  2855. </p>
  2856. <p>
  2857. It is provided to allow mistakes in the version numbers
  2858. of older versions of a package, and also a package's
  2859. previous version numbering schemes, to be left behind.
  2860. </p>
  2861. </item>
  2862. <tag><var>upstream_version</var></tag>
  2863. <item>
  2864. <p>
  2865. This is the main part of the version number. It is
  2866. usually the version number of the original ("upstream")
  2867. package from which the <file>.deb</file> file has been made,
  2868. if this is applicable. Usually this will be in the same
  2869. format as that specified by the upstream author(s);
  2870. however, it may need to be reformatted to fit into the
  2871. package management system's format and comparison
  2872. scheme.
  2873. </p>
  2874. <p>
  2875. The comparison behavior of the package management system
  2876. with respect to the <var>upstream_version</var> is
  2877. described below. The <var>upstream_version</var>
  2878. portion of the version number is mandatory.
  2879. </p>
  2880. <p>
  2881. The <var>upstream_version</var> may contain only
  2882. alphanumerics<footnote>
  2883. Alphanumerics are <tt>A-Za-z0-9</tt> only.
  2884. </footnote>
  2885. and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
  2886. <tt>:</tt> <tt>~</tt> (full stop, plus, hyphen, colon,
  2887. tilde) and should start with a digit. If there is no
  2888. <var>debian_revision</var> then hyphens are not allowed;
  2889. if there is no <var>epoch</var> then colons are not
  2890. allowed.
  2891. </p>
  2892. </item>
  2893. <tag><var>debian_revision</var></tag>
  2894. <item>
  2895. <p>
  2896. This part of the version number specifies the version of
  2897. the Debian package based on the upstream version. It
  2898. may contain only alphanumerics and the characters
  2899. <tt>+</tt> <tt>.</tt> <tt>~</tt> (plus, full stop,
  2900. tilde) and is compared in the same way as the
  2901. <var>upstream_version</var> is.
  2902. </p>
  2903. <p>
  2904. It is optional; if it isn't present then the
  2905. <var>upstream_version</var> may not contain a hyphen.
  2906. This format represents the case where a piece of
  2907. software was written specifically to be a Debian
  2908. package, where the Debian package source must always
  2909. be identical to the pristine source and therefore no
  2910. revision indication is required.
  2911. </p>
  2912. <p>
  2913. It is conventional to restart the
  2914. <var>debian_revision</var> at <tt>1</tt> each time the
  2915. <var>upstream_version</var> is increased.
  2916. </p>
  2917. <p>
  2918. The package management system will break the version
  2919. number apart at the last hyphen in the string (if there
  2920. is one) to determine the <var>upstream_version</var> and
  2921. <var>debian_revision</var>. The absence of a
  2922. <var>debian_revision</var> is equivalent to a
  2923. <var>debian_revision</var> of <tt>0</tt>.
  2924. </p>
  2925. </item>
  2926. </taglist>
  2927. </p>
  2928. <p>
  2929. When comparing two version numbers, first the <var>epoch</var>
  2930. of each are compared, then the <var>upstream_version</var> if
  2931. <var>epoch</var> is equal, and then <var>debian_revision</var>
  2932. if <var>upstream_version</var> is also equal.
  2933. <var>epoch</var> is compared numerically. The
  2934. <var>upstream_version</var> and <var>debian_revision</var>
  2935. parts are compared by the package management system using the
  2936. following algorithm:
  2937. </p>
  2938. <p>
  2939. The strings are compared from left to right.
  2940. </p>
  2941. <p>
  2942. First the initial part of each string consisting entirely of
  2943. non-digit characters is determined. These two parts (one of
  2944. which may be empty) are compared lexically. If a difference
  2945. is found it is returned. The lexical comparison is a
  2946. comparison of ASCII values modified so that all the letters
  2947. sort earlier than all the non-letters and so that a tilde
  2948. sorts before anything, even the end of a part. For example,
  2949. the following parts are in sorted order from earliest to
  2950. latest: <tt>~~</tt>, <tt>~~a</tt>, <tt>~</tt>, the empty part,
  2951. <tt>a</tt>.<footnote>
  2952. One common use of <tt>~</tt> is for upstream pre-releases.
  2953. For example, <tt>1.0~beta1~svn1245</tt> sorts earlier than
  2954. <tt>1.0~beta1</tt>, which sorts earlier than <tt>1.0</tt>.
  2955. </footnote>
  2956. </p>
  2957. <p>
  2958. Then the initial part of the remainder of each string which
  2959. consists entirely of digit characters is determined. The
  2960. numerical values of these two parts are compared, and any
  2961. difference found is returned as the result of the comparison.
  2962. For these purposes an empty string (which can only occur at
  2963. the end of one or both version strings being compared) counts
  2964. as zero.
  2965. </p>
  2966. <p>
  2967. These two steps (comparing and removing initial non-digit
  2968. strings and initial digit strings) are repeated until a
  2969. difference is found or both strings are exhausted.
  2970. </p>
  2971. <p>
  2972. Note that the purpose of epochs is to allow us to leave behind
  2973. mistakes in version numbering, and to cope with situations
  2974. where the version numbering scheme changes. It is
  2975. <em>not</em> intended to cope with version numbers containing
  2976. strings of letters which the package management system cannot
  2977. interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
  2978. silly orderings.<footnote>
  2979. The author of this manual has heard of a package whose
  2980. versions went <tt>1.1</tt>, <tt>1.2</tt>, <tt>1.3</tt>,
  2981. <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>, <tt>2</tt> and so
  2982. forth.
  2983. </footnote>
  2984. </p>
  2985. </sect1>
  2986. <sect1 id="f-Description">
  2987. <heading><tt>Description</tt></heading>
  2988. <p>
  2989. In a source or binary control file, the <tt>Description</tt>
  2990. field contains a description of the binary package, consisting
  2991. of two parts, the synopsis or the short description, and the
  2992. long description. It is a multiline field with the following
  2993. format:
  2994. </p>
  2995. <p>
  2996. <example>
  2997. Description: &lt;single line synopsis&gt;
  2998. &lt;extended description over several lines&gt;
  2999. </example>
  3000. </p>
  3001. <p>
  3002. The lines in the extended description can have these formats:
  3003. </p>
  3004. <p><list>
  3005. <item>
  3006. Those starting with a single space are part of a paragraph.
  3007. Successive lines of this form will be word-wrapped when
  3008. displayed. The leading space will usually be stripped off.
  3009. The line must contain at least one non-whitespace character.
  3010. </item>
  3011. <item>
  3012. Those starting with two or more spaces. These will be
  3013. displayed verbatim. If the display cannot be panned
  3014. horizontally, the displaying program will line wrap them "hard"
  3015. (i.e., without taking account of word breaks). If it can they
  3016. will be allowed to trail off to the right. None, one or two
  3017. initial spaces may be deleted, but the number of spaces
  3018. deleted from each line will be the same (so that you can have
  3019. indenting work correctly, for example). The line must
  3020. contain at least one non-whitespace character.
  3021. </item>
  3022. <item>
  3023. Those containing a single space followed by a single full stop
  3024. character. These are rendered as blank lines. This is the
  3025. <em>only</em> way to get a blank line<footnote>
  3026. Completely empty lines will not be rendered as blank lines.
  3027. Instead, they will cause the parser to think you're starting
  3028. a whole new record in the control file, and will therefore
  3029. likely abort with an error.
  3030. </footnote>.
  3031. </item>
  3032. <item>
  3033. Those containing a space, a full stop and some more characters.
  3034. These are for future expansion. Do not use them.
  3035. </item>
  3036. </list></p>
  3037. <p>
  3038. Do not use tab characters. Their effect is not predictable.
  3039. </p>
  3040. <p>
  3041. See <ref id="descriptions"> for further information on this.
  3042. </p>
  3043. <p>
  3044. In a <file>.changes</file> file, the <tt>Description</tt>
  3045. field contains a summary of the descriptions for the packages
  3046. being uploaded. For this case, the first line of the field
  3047. value (the part on the same line as <tt>Description:</tt>) is
  3048. always empty. It is a multiline field, with one
  3049. line per package. Each line is
  3050. indented by one space and contains the name of a binary
  3051. package, a space, a hyphen (<tt>-</tt>), a space, and the
  3052. short description line from that package.
  3053. </p>
  3054. </sect1>
  3055. <sect1 id="f-Distribution">
  3056. <heading><tt>Distribution</tt></heading>
  3057. <p>
  3058. In a <file>.changes</file> file or parsed changelog output
  3059. this contains the (space-separated) name(s) of the
  3060. distribution(s) where this version of the package should
  3061. be installed. Valid distributions are determined by the
  3062. archive maintainers.<footnote>
  3063. Example distribution names in the Debian archive used in
  3064. <file>.changes</file> files are:
  3065. <taglist compact="compact">
  3066. <tag><em>unstable</em></tag>
  3067. <item>
  3068. This distribution value refers to the
  3069. <em>developmental</em> part of the Debian distribution
  3070. tree. Most new packages, new upstream versions of
  3071. packages and bug fixes go into the <em>unstable</em>
  3072. directory tree.
  3073. </item>
  3074. <tag><em>experimental</em></tag>
  3075. <item>
  3076. The packages with this distribution value are deemed
  3077. by their maintainers to be high risk. Oftentimes they
  3078. represent early beta or developmental packages from
  3079. various sources that the maintainers want people to
  3080. try, but are not ready to be a part of the other parts
  3081. of the Debian distribution tree.
  3082. </item>
  3083. </taglist>
  3084. <p>
  3085. Others are used for updating stable releases or for
  3086. security uploads. More information is available in the
  3087. Debian Developer's Reference, section "The Debian
  3088. archive".
  3089. </p>
  3090. </footnote>
  3091. The Debian archive software only supports listing a single
  3092. distribution. Migration of packages to other distributions is
  3093. handled outside of the upload process.
  3094. </p>
  3095. </sect1>
  3096. <sect1 id="f-Date">
  3097. <heading><tt>Date</tt></heading>
  3098. <p>
  3099. This field includes the date the package was built or last
  3100. edited. It must be in the same format as the <var>date</var>
  3101. in a <file>debian/changelog</file> entry.
  3102. </p>
  3103. <p>
  3104. The value of this field is usually extracted from the
  3105. <file>debian/changelog</file> file - see
  3106. <ref id="dpkgchangelog">).
  3107. </p>
  3108. </sect1>
  3109. <sect1 id="f-Format">
  3110. <heading><tt>Format</tt></heading>
  3111. <p>
  3112. In <qref id="debianchangesfiles"><file>.changes</file></qref>
  3113. files, this field declares the format version of that file.
  3114. The syntax of the field value is the same as that of
  3115. a <qref id="f-Version">package version number</qref> except
  3116. that no epoch or Debian revision is allowed. The format
  3117. described in this document is <tt>&changesversion;</tt>.
  3118. </p>
  3119. <p>
  3120. In <qref id="debiansourcecontrolfiles"><file>.dsc</file>
  3121. Debian source control</qref> files, this field declares the
  3122. format of the source package. The field value is used by
  3123. programs acting on a source package to interpret the list of
  3124. files in the source package and determine how to unpack it.
  3125. The syntax of the field value is a numeric major revision, a
  3126. period, a numeric minor revision, and then an optional subtype
  3127. after whitespace, which if specified is an alphanumeric word
  3128. in parentheses. The subtype is optional in the syntax but may
  3129. be mandatory for particular source format revisions.
  3130. <footnote>
  3131. The source formats currently supported by the Debian archive
  3132. software are <tt>1.0</tt>, <tt>3.0 (native)</tt>,
  3133. and <tt>3.0 (quilt)</tt>.
  3134. </footnote>
  3135. </p>
  3136. </sect1>
  3137. <sect1 id="f-Urgency">
  3138. <heading><tt>Urgency</tt></heading>
  3139. <p>
  3140. This is a description of how important it is to upgrade to
  3141. this version from previous ones. It consists of a single
  3142. keyword taking one of the values <tt>low</tt>,
  3143. <tt>medium</tt>, <tt>high</tt>, <tt>emergency</tt>, or
  3144. <tt>critical</tt><footnote>
  3145. Other urgency values are supported with configuration
  3146. changes in the archive software but are not used in Debian.
  3147. The urgency affects how quickly a package will be considered
  3148. for inclusion into the <tt>testing</tt> distribution and
  3149. gives an indication of the importance of any fixes included
  3150. in the upload. <tt>Emergency</tt> and <tt>critical</tt> are
  3151. treated as synonymous.
  3152. </footnote> (not case-sensitive) followed by an optional
  3153. commentary (separated by a space) which is usually in
  3154. parentheses. For example:
  3155. <example>
  3156. Urgency: low (HIGH for users of diversions)
  3157. </example>
  3158. </p>
  3159. <p>
  3160. The value of this field is usually extracted from the
  3161. <file>debian/changelog</file> file - see
  3162. <ref id="dpkgchangelog">.
  3163. </p>
  3164. </sect1>
  3165. <sect1 id="f-Changes">
  3166. <heading><tt>Changes</tt></heading>
  3167. <p>
  3168. This multiline field contains the human-readable changes data, describing
  3169. the differences between the last version and the current one.
  3170. </p>
  3171. <p>
  3172. The first line of the field value (the part on the same line
  3173. as <tt>Changes:</tt>) is always empty. The content of the
  3174. field is expressed as continuation lines, with each line
  3175. indented by at least one space. Blank lines must be
  3176. represented by a line consisting only of a space and a full
  3177. stop (<tt>.</tt>).
  3178. </p>
  3179. <p>
  3180. The value of this field is usually extracted from the
  3181. <file>debian/changelog</file> file - see
  3182. <ref id="dpkgchangelog">).
  3183. </p>
  3184. <p>
  3185. Each version's change information should be preceded by a
  3186. "title" line giving at least the version, distribution(s)
  3187. and urgency, in a human-readable way.
  3188. </p>
  3189. <p>
  3190. If data from several versions is being returned the entry
  3191. for the most recent version should be returned first, and
  3192. entries should be separated by the representation of a
  3193. blank line (the "title" line may also be followed by the
  3194. representation of a blank line).
  3195. </p>
  3196. </sect1>
  3197. <sect1 id="f-Binary">
  3198. <heading><tt>Binary</tt></heading>
  3199. <p>
  3200. This folded field is a list of binary packages. Its syntax and
  3201. meaning varies depending on the control file in which it
  3202. appears.
  3203. </p>
  3204. <p>
  3205. When it appears in the <file>.dsc</file> file, it lists binary
  3206. packages which a source package can produce, separated by
  3207. commas<footnote>
  3208. A space after each comma is conventional.
  3209. </footnote>. The source package
  3210. does not necessarily produce all of these binary packages for
  3211. every architecture. The source control file doesn't contain
  3212. details of which architectures are appropriate for which of
  3213. the binary packages.
  3214. </p>
  3215. <p>
  3216. When it appears in a <file>.changes</file> file, it lists the
  3217. names of the binary packages being uploaded, separated by
  3218. whitespace (not commas).
  3219. </p>
  3220. </sect1>
  3221. <sect1 id="f-Installed-Size">
  3222. <heading><tt>Installed-Size</tt></heading>
  3223. <p>
  3224. This field appears in the control files of binary packages,
  3225. and in the <file>Packages</file> files. It gives an estimate
  3226. of the total amount of disk space required to install the
  3227. named package. Actual installed size may vary based on block
  3228. size, file system properties, or actions taken by package
  3229. maintainer scripts.
  3230. </p>
  3231. <p>
  3232. The disk space is given as the integer value of the estimated
  3233. installed size in bytes, divided by 1024 and rounded up.
  3234. </p>
  3235. </sect1>
  3236. <sect1 id="f-Files">
  3237. <heading><tt>Files</tt></heading>
  3238. <p>
  3239. This field contains a list of files with information about
  3240. each one. The exact information and syntax varies with
  3241. the context.
  3242. </p>
  3243. <p>
  3244. In all cases, Files is a multiline field. The first line of
  3245. the field value (the part on the same line as <tt>Files:</tt>)
  3246. is always empty. The content of the field is expressed as
  3247. continuation lines, one line per file. Each line must be
  3248. indented by one space and contain a number of sub-fields,
  3249. separated by spaces, as described below.
  3250. </p>
  3251. <p>
  3252. In the <file>.dsc</file> file, each line contains the MD5
  3253. checksum, size and filename of the tar file and (if
  3254. applicable) diff file which make up the remainder of the
  3255. source package<footnote>
  3256. That is, the parts which are not the <tt>.dsc</tt>.
  3257. </footnote>. For example:
  3258. <example>
  3259. Files:
  3260. c6f698f19f2a2aa07dbb9bbda90a2754 571925 example_1.2.orig.tar.gz
  3261. 938512f08422f3509ff36f125f5873ba 6220 example_1.2-1.diff.gz
  3262. </example>
  3263. The exact forms of the filenames are described
  3264. in <ref id="pkg-sourcearchives">.
  3265. </p>
  3266. <p>
  3267. In the <file>.changes</file> file this contains one line per
  3268. file being uploaded. Each line contains the MD5 checksum,
  3269. size, section and priority and the filename. For example:
  3270. <example>
  3271. Files:
  3272. 4c31ab7bfc40d3cf49d7811987390357 1428 text extra example_1.2-1.dsc
  3273. c6f698f19f2a2aa07dbb9bbda90a2754 571925 text extra example_1.2.orig.tar.gz
  3274. 938512f08422f3509ff36f125f5873ba 6220 text extra example_1.2-1.diff.gz
  3275. 7c98fe853b3bbb47a00e5cd129b6cb56 703542 text extra example_1.2-1_i386.deb
  3276. </example>
  3277. The <qref id="f-Section">section</qref>
  3278. and <qref id="f-Priority">priority</qref> are the values of
  3279. the corresponding fields in the main source control file. If
  3280. no section or priority is specified then <tt>-</tt> should be
  3281. used, though section and priority values must be specified for
  3282. new packages to be installed properly.
  3283. </p>
  3284. <p>
  3285. The special value <tt>byhand</tt> for the section in a
  3286. <tt>.changes</tt> file indicates that the file in question
  3287. is not an ordinary package file and must be installed by
  3288. hand by the distribution maintainers. If the section is
  3289. <tt>byhand</tt> the priority should be <tt>-</tt>.
  3290. </p>
  3291. <p>
  3292. If a new Debian revision of a package is being shipped and
  3293. no new original source archive is being distributed the
  3294. <tt>.dsc</tt> must still contain the <tt>Files</tt> field
  3295. entry for the original source archive
  3296. <file><var>package</var>_<var>upstream-version</var>.orig.tar.gz</file>,
  3297. but the <file>.changes</file> file should leave it out. In
  3298. this case the original source archive on the distribution
  3299. site must match exactly, byte-for-byte, the original
  3300. source archive which was used to generate the
  3301. <file>.dsc</file> file and diff which are being uploaded.</p>
  3302. </sect1>
  3303. <sect1 id="f-Closes">
  3304. <heading><tt>Closes</tt></heading>
  3305. <p>
  3306. A space-separated list of bug report numbers that the upload
  3307. governed by the .changes file closes.
  3308. </p>
  3309. </sect1>
  3310. <sect1 id="f-Homepage">
  3311. <heading><tt>Homepage</tt></heading>
  3312. <p>
  3313. The URL of the web site for this package, preferably (when
  3314. applicable) the site from which the original source can be
  3315. obtained and any additional upstream documentation or
  3316. information may be found. The content of this field is a
  3317. simple URL without any surrounding characters such as
  3318. <tt>&lt;&gt;</tt>.
  3319. </p>
  3320. </sect1>
  3321. <sect1 id="f-Checksums">
  3322. <heading><tt>Checksums-Sha1</tt>
  3323. and <tt>Checksums-Sha256</tt></heading>
  3324. <p>
  3325. These multiline fields contain a list of files with a checksum and size
  3326. for each one. Both <tt>Checksums-Sha1</tt>
  3327. and <tt>Checksums-Sha256</tt> have the same syntax and differ
  3328. only in the checksum algorithm used: SHA-1
  3329. for <tt>Checksums-Sha1</tt> and SHA-256
  3330. for <tt>Checksums-Sha256</tt>.
  3331. </p>
  3332. <p>
  3333. <tt>Checksums-Sha1</tt> and <tt>Checksums-Sha256</tt> are
  3334. multiline fields. The first line of the field value (the part
  3335. on the same line as <tt>Checksums-Sha1:</tt>
  3336. or <tt>Checksums-Sha256:</tt>) is always empty. The content
  3337. of the field is expressed as continuation lines, one line per
  3338. file. Each line consists of the checksum, a space, the file
  3339. size, a space, and the file name. For example (from
  3340. a <file>.changes</file> file):
  3341. <example>
  3342. Checksums-Sha1:
  3343. 1f418afaa01464e63cc1ee8a66a05f0848bd155c 1276 example_1.0-1.dsc
  3344. a0ed1456fad61116f868b1855530dbe948e20f06 171602 example_1.0.orig.tar.gz
  3345. 5e86ecf0671e113b63388dac81dd8d00e00ef298 6137 example_1.0-1.debian.tar.gz
  3346. 71a0ff7da0faaf608481195f9cf30974b142c183 548402 example_1.0-1_i386.deb
  3347. Checksums-Sha256:
  3348. ac9d57254f7e835bed299926fd51bf6f534597cc3fcc52db01c4bffedae81272 1276 example_1.0-1.dsc
  3349. 0d123be7f51e61c4bf15e5c492b484054be7e90f3081608a5517007bfb1fd128 171602 example_1.0.orig.tar.gz
  3350. f54ae966a5f580571ae7d9ef5e1df0bd42d63e27cb505b27957351a495bc6288 6137 example_1.0-1.debian.tar.gz
  3351. 3bec05c03974fdecd11d020fc2e8250de8404867a8a2ce865160c250eb723664 548402 example_1.0-1_i386.deb
  3352. </example>
  3353. </p>
  3354. <p>
  3355. In the <file>.dsc</file> file, these fields list all
  3356. files that make up the source package. In
  3357. the <file>.changes</file> file, these fields list all
  3358. files being uploaded. The list of files in these fields
  3359. must match the list of files in the <tt>Files</tt> field.
  3360. </p>
  3361. </sect1>
  3362. <sect1>
  3363. <heading><tt>DM-Upload-Allowed</tt></heading>
  3364. <p>
  3365. Obsolete, see <qref id="f-DM-Upload-Allowed">below</qref>.
  3366. </p>
  3367. </sect1>
  3368. <sect1 id="f-VCS-fields">
  3369. <heading>Version Control System (VCS) fields</heading>
  3370. <p>
  3371. Debian source packages are increasingly developed using VCSs. The
  3372. purpose of the following fields is to indicate a publicly accessible
  3373. repository where the Debian source package is developed.
  3374. <taglist>
  3375. <tag><tt>Vcs-Browser</tt></tag>
  3376. <item>
  3377. <p>
  3378. URL of a web interface for browsing the repository.
  3379. </p>
  3380. </item>
  3381. <tag>
  3382. <tt>Vcs-Arch</tt>, <tt>Vcs-Bzr</tt> (Bazaar), <tt>Vcs-Cvs</tt>,
  3383. <tt>Vcs-Darcs</tt>, <tt>Vcs-Git</tt>, <tt>Vcs-Hg</tt>
  3384. (Mercurial), <tt>Vcs-Mtn</tt> (Monotone), <tt>Vcs-Svn</tt>
  3385. (Subversion)
  3386. </tag>
  3387. <item>
  3388. <p>
  3389. The field name identifies the VCS. The field's value uses the
  3390. version control system's conventional syntax for describing
  3391. repository locations and should be sufficient to locate the
  3392. repository used for packaging. Ideally, it also locates the
  3393. branch used for development of new versions of the Debian
  3394. package.
  3395. </p>
  3396. <p>
  3397. In the case of Git, the value consists of a URL, optionally
  3398. followed by the word <tt>-b</tt> and the name of a branch in
  3399. the indicated repository, following the syntax of the
  3400. <tt>git clone</tt> command. If no branch is specified, the
  3401. packaging should be on the default branch.
  3402. </p>
  3403. <p>
  3404. More than one different VCS may be specified for the same
  3405. package.
  3406. </p>
  3407. </item>
  3408. </taglist>
  3409. </p>
  3410. </sect1>
  3411. <sect1 id="f-Package-List">
  3412. <heading><tt>Package-List</tt></heading>
  3413. <p>
  3414. Multiline field listing all the packages that can be built from
  3415. the source package, considering every architecture. The first line
  3416. of the field value is empty. Each one of the next lines describes
  3417. one binary package, by listing its name, type, section and priority
  3418. separated by spaces. Fifth and subsequent space-separated items
  3419. may be present and parsers must allow them. See the
  3420. <qref id="f-Package-Type">Package-Type</qref> field for a list of
  3421. package types.
  3422. </p>
  3423. </sect1>
  3424. <sect1 id="f-Package-Type">
  3425. <heading><tt>Package-Type</tt></heading>
  3426. <p>
  3427. Simple field containing a word indicating the type of package:
  3428. <tt>deb</tt> for binary packages and <tt>udeb</tt> for micro binary
  3429. packages. Other types not defined here may be indicated. In
  3430. source package control files, the <tt>Package-Type</tt> field
  3431. should be omitted instead of giving it a value of <tt>deb</tt>, as
  3432. this value is assumed for paragraphs lacking this field.
  3433. </p>
  3434. </sect1>
  3435. <sect1 id="f-Dgit">
  3436. <heading><tt>Dgit</tt></heading>
  3437. <p>
  3438. Folded field containing a single git commit hash, presented in
  3439. full, followed optionally by whitespace and other data to be
  3440. defined in future extensions.
  3441. </p>
  3442. <p>
  3443. Declares that the source package corresponds exactly to a
  3444. referenced commit in a Git repository available at the canonical
  3445. location called <em>dgit-repos</em>, used by <prgn>dgit</prgn>, a
  3446. bidirectional gateway between the Debian archive and Git. The
  3447. commit is reachable from at least one reference whose name matches
  3448. <tt>refs/dgit/*</tt>. See the manual page of <prgn>dgit</prgn> for
  3449. further details.
  3450. </p>
  3451. </sect1>
  3452. </sect>
  3453. <sect>
  3454. <heading>User-defined fields</heading>
  3455. <p>
  3456. Additional user-defined fields may be added to the
  3457. source package control file. Such fields will be
  3458. ignored, and not copied to (for example) binary or
  3459. Debian source control files or upload control files.
  3460. </p>
  3461. <p>
  3462. If you wish to add additional unsupported fields to
  3463. these output files you should use the mechanism
  3464. described here.
  3465. </p>
  3466. <p>
  3467. Fields in the main source control information file with
  3468. names starting <tt>X</tt>, followed by one or more of
  3469. the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
  3470. be copied to the output files. Only the part of the
  3471. field name after the hyphen will be used in the output
  3472. file. Where the letter <tt>B</tt> is used the field
  3473. will appear in binary package control files, where the
  3474. letter <tt>S</tt> is used in Debian source control
  3475. files and where <tt>C</tt> is used in upload control
  3476. (<tt>.changes</tt>) files.
  3477. </p>
  3478. <p>
  3479. For example, if the main source information control file
  3480. contains the field
  3481. <example>
  3482. XBS-Comment: I stand between the candle and the star.
  3483. </example>
  3484. then the binary and Debian source control files will contain the
  3485. field
  3486. <example>
  3487. Comment: I stand between the candle and the star.
  3488. </example>
  3489. </p>
  3490. </sect>
  3491. <sect id="obsolete-control-data-fields">
  3492. <heading>Obsolete fields</heading>
  3493. <p>
  3494. The following fields have been obsoleted and may be found in packages
  3495. conforming with previous versions of the Policy.
  3496. </p>
  3497. <sect1 id="f-DM-Upload-Allowed">
  3498. <heading><tt>DM-Upload-Allowed</tt></heading>
  3499. <p>
  3500. Indicates that Debian Maintainers may upload this package to
  3501. the Debian archive. The only valid value is <tt>yes</tt>. This
  3502. field was used to regulate uploads by Debian Maintainers, See the
  3503. General Resolution <url id="http://www.debian.org/vote/2007/vote_003"
  3504. name="Endorse the concept of Debian Maintainers"> for more details.
  3505. </p>
  3506. </sect1>
  3507. </sect>
  3508. </chapt>
  3509. <chapt id="maintainerscripts">
  3510. <heading>Package maintainer scripts and installation procedure</heading>
  3511. <sect>
  3512. <heading>Introduction to package maintainer scripts</heading>
  3513. <p>
  3514. It is possible to supply scripts as part of a package which
  3515. the package management system will run for you when your
  3516. package is installed, upgraded or removed.
  3517. </p>
  3518. <p>
  3519. These scripts are the control information
  3520. files <prgn>preinst</prgn>, <prgn>postinst</prgn>, <prgn>prerm</prgn>
  3521. and <prgn>postrm</prgn>. They must be proper executable files;
  3522. if they are scripts (which is recommended), they must start with
  3523. the usual <tt>#!</tt> convention. They should be readable and
  3524. executable by anyone, and must not be world-writable.
  3525. </p>
  3526. <p>
  3527. The package management system looks at the exit status from
  3528. these scripts. It is important that they exit with a
  3529. non-zero status if there is an error, so that the package
  3530. management system can stop its processing. For shell
  3531. scripts this means that you <em>almost always</em> need to
  3532. use <tt>set -e</tt> (this is usually true when writing shell
  3533. scripts, in fact). It is also important, of course, that
  3534. they exit with a zero status if everything went well.
  3535. </p>
  3536. <p>
  3537. Additionally, packages interacting with users
  3538. using <prgn>debconf</prgn> in the <prgn>postinst</prgn> script
  3539. should install a <prgn>config</prgn> script as a control
  3540. information file. See <ref id="maintscriptprompt"> for details.
  3541. </p>
  3542. <p>
  3543. When a package is upgraded a combination of the scripts from
  3544. the old and new packages is called during the upgrade
  3545. procedure. If your scripts are going to be at all
  3546. complicated you need to be aware of this, and may need to
  3547. check the arguments to your scripts.
  3548. </p>
  3549. <p>
  3550. Broadly speaking the <prgn>preinst</prgn> is called before
  3551. (a particular version of) a package is unpacked, and the
  3552. <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
  3553. before (a version of) a package is removed and the
  3554. <prgn>postrm</prgn> afterwards.
  3555. </p>
  3556. <p>
  3557. Programs called from maintainer scripts should not normally
  3558. have a path prepended to them. Before installation is
  3559. started, the package management system checks to see if the
  3560. programs <prgn>ldconfig</prgn>, <prgn>start-stop-daemon</prgn>,
  3561. and <prgn>update-rc.d</prgn> can be found via the
  3562. <tt>PATH</tt> environment variable. Those programs, and any
  3563. other program that one would expect to be in the
  3564. <tt>PATH</tt>, should thus be invoked without an absolute
  3565. pathname. Maintainer scripts should also not reset the
  3566. <tt>PATH</tt>, though they might choose to modify it by
  3567. prepending or appending package-specific directories. These
  3568. considerations really apply to all shell scripts.</p>
  3569. </sect>
  3570. <sect id="idempotency">
  3571. <heading>Maintainer scripts idempotency</heading>
  3572. <p>
  3573. It is necessary for the error recovery procedures that the
  3574. scripts be idempotent. This means that if it is run
  3575. successfully, and then it is called again, it doesn't bomb
  3576. out or cause any harm, but just ensures that everything is
  3577. the way it ought to be. If the first call failed, or
  3578. aborted half way through for some reason, the second call
  3579. should merely do the things that were left undone the first
  3580. time, if any, and exit with a success status if everything
  3581. is OK.<footnote>
  3582. This is so that if an error occurs, the user interrupts
  3583. <prgn>dpkg</prgn> or some other unforeseen circumstance
  3584. happens you don't leave the user with a badly-broken
  3585. package when <prgn>dpkg</prgn> attempts to repeat the
  3586. action.
  3587. </footnote>
  3588. </p>
  3589. </sect>
  3590. <sect id="controllingterminal">
  3591. <heading>Controlling terminal for maintainer scripts</heading>
  3592. <p>
  3593. Maintainer scripts are not guaranteed to run with a controlling
  3594. terminal and may not be able to interact with the user. They
  3595. must be able to fall back to noninteractive behavior if no
  3596. controlling terminal is available. Maintainer scripts that
  3597. prompt via a program conforming to the Debian Configuration
  3598. Management Specification (see <ref id="maintscriptprompt">) may
  3599. assume that program will handle falling back to noninteractive
  3600. behavior.
  3601. </p>
  3602. <p>
  3603. For high-priority prompts without a reasonable default answer,
  3604. maintainer scripts may abort if there is no controlling
  3605. terminal. However, this situation should be avoided if at all
  3606. possible, since it prevents automated or unattended installs.
  3607. In most cases, users will consider this to be a bug in the
  3608. package.
  3609. </p>
  3610. </sect>
  3611. <sect id="exitstatus">
  3612. <heading>Exit status</heading>
  3613. <p>
  3614. Each script must return a zero exit status for
  3615. success, or a nonzero one for failure, since the package
  3616. management system looks for the exit status of these scripts
  3617. and determines what action to take next based on that datum.
  3618. </p>
  3619. </sect>
  3620. <sect id="mscriptsinstact"><heading>Summary of ways maintainer
  3621. scripts are called
  3622. </heading>
  3623. <p>
  3624. What follows is a summary of all the ways in which maintainer
  3625. scripts may be called along with what facilities those scripts
  3626. may rely on being available at that time. Script names preceded
  3627. by <var>new-</var> are the scripts from the new version of a
  3628. package being installed, upgraded to, or downgraded to. Script
  3629. names preceded by <var>old-</var> are the scripts from the old
  3630. version of a package that is being upgraded from or downgraded
  3631. from.
  3632. </p>
  3633. <p>
  3634. The <prgn>preinst</prgn> script may be called in the following
  3635. ways:
  3636. <taglist>
  3637. <tag><var>new-preinst</var> <tt>install</tt></tag>
  3638. <tag><var>new-preinst</var> <tt>install</tt>
  3639. <var>old-version</var></tag>
  3640. <tag><var>new-preinst</var> <tt>upgrade</tt>
  3641. <var>old-version</var></tag>
  3642. <item>
  3643. The package will not yet be unpacked, so
  3644. the <prgn>preinst</prgn> script cannot rely on any files
  3645. included in its package. Only essential packages and
  3646. pre-dependencies (<tt>Pre-Depends</tt>) may be assumed to be
  3647. available. Pre-dependencies will have been configured at
  3648. least once, but at the time the <prgn>preinst</prgn> is
  3649. called they may only be in an "Unpacked" or "Half-Configured"
  3650. state if a previous version of the pre-dependency was
  3651. completely configured and has not been removed since then.
  3652. </item>
  3653. <tag><var>old-preinst</var> <tt>abort-upgrade</tt>
  3654. <var>new-version</var></tag>
  3655. <item>
  3656. Called during error handling of an upgrade that failed after
  3657. unpacking the new package because the <tt>postrm
  3658. upgrade</tt> action failed. The unpacked files may be
  3659. partly from the new version or partly missing, so the script
  3660. cannot rely on files included in the package. Package
  3661. dependencies may not be available. Pre-dependencies will be
  3662. at least "Unpacked" following the same rules as above, except
  3663. they may be only "Half-Installed" if an upgrade of the
  3664. pre-dependency failed.<footnote>
  3665. This can happen if the new version of the package no
  3666. longer pre-depends on a package that had been partially
  3667. upgraded.
  3668. </footnote>
  3669. </item>
  3670. </taglist>
  3671. </p>
  3672. <p>
  3673. The <prgn>postinst</prgn> script may be called in the following
  3674. ways:
  3675. <taglist>
  3676. <tag><var>postinst</var> <tt>configure</tt>
  3677. <var>most-recently-configured-version</var></tag>
  3678. <item>
  3679. The files contained in the package will be unpacked. All
  3680. package dependencies will at least be "Unpacked". If there
  3681. are no circular dependencies involved, all package
  3682. dependencies will be configured. For behavior in the case
  3683. of circular dependencies, see the discussion
  3684. in <ref id="binarydeps">.
  3685. </item>
  3686. <tag><var>old-postinst</var> <tt>abort-upgrade</tt>
  3687. <var>new-version</var></tag>
  3688. <tag><var>conflictor's-postinst</var> <tt>abort-remove</tt>
  3689. <tt>in-favour</tt> <var>package</var>
  3690. <var>new-version</var></tag>
  3691. <tag><var>postinst</var> <tt>abort-remove</tt></tag>
  3692. <tag><var>deconfigured's-postinst</var>
  3693. <tt>abort-deconfigure</tt> <tt>in-favour</tt>
  3694. <var>failed-install-package</var> <var>version</var>
  3695. [<tt>removing</tt> <var>conflicting-package</var>
  3696. <var>version</var>]</tag>
  3697. <item>
  3698. The files contained in the package will be unpacked. All
  3699. package dependencies will at least be "Half-Installed" and
  3700. will have previously been configured and not removed.
  3701. However, dependencies may not be configured or even fully
  3702. unpacked in some error situations.<footnote>
  3703. For example, suppose packages foo and bar are "Installed"
  3704. with foo depending on bar. If an upgrade of bar were
  3705. started and then aborted, and then an attempt to remove
  3706. foo failed because its <prgn>prerm</prgn> script failed,
  3707. foo's <tt>postinst abort-remove</tt> would be called with
  3708. bar only "Half-Installed".
  3709. </footnote>
  3710. The <prgn>postinst</prgn> should still attempt any actions
  3711. for which its dependencies are required, since they will
  3712. normally be available, but consider the correct error
  3713. handling approach if those actions fail. Aborting
  3714. the <prgn>postinst</prgn> action if commands or facilities
  3715. from the package dependencies are not available is often the
  3716. best approach.
  3717. </item>
  3718. </taglist>
  3719. </p>
  3720. <p>
  3721. The <prgn>prerm</prgn> script may be called in the following
  3722. ways:
  3723. <taglist>
  3724. <tag><var>prerm</var> <tt>remove</tt></tag>
  3725. <tag><var>old-prerm</var>
  3726. <tt>upgrade</tt><var>new-version</var></tag>
  3727. <tag><var>conflictor's-prerm</var> <tt>remove</tt>
  3728. <tt>in-favour</tt> <var>package</var>
  3729. <var>new-version</var></tag>
  3730. <tag><var>deconfigured's-prerm</var> <tt>deconfigure</tt>
  3731. <tt>in-favour</tt> <var>package-being-installed</var>
  3732. <var>version</var> [<tt>removing</tt>
  3733. <var>conflicting-package</var> <var>version</var>]</tag>
  3734. <item>
  3735. The package whose <prgn>prerm</prgn> is being called will be
  3736. at least "Half-Installed". All package dependencies will at
  3737. least be "Half-Installed" and will have previously been
  3738. configured and not removed. If there was no error, all
  3739. dependencies will at least be "Unpacked", but these actions
  3740. may be called in various error states where dependencies are
  3741. only "Half-Installed" due to a partial upgrade.
  3742. </item>
  3743. <tag><var>new-prerm</var> <tt>failed-upgrade</tt>
  3744. <var>old-version</var></tag>
  3745. <item>
  3746. Called during error handling when <tt>prerm upgrade</tt>
  3747. fails. The new package will not yet be unpacked, and all
  3748. the same constraints as for <tt>preinst upgrade</tt> apply.
  3749. </item>
  3750. </taglist>
  3751. </p>
  3752. <p>
  3753. The <prgn>postrm</prgn> script may be called in the following
  3754. ways:
  3755. <taglist>
  3756. <tag><var>postrm</var> <tt>remove</tt></tag>
  3757. <tag><var>postrm</var> <tt>purge</tt></tag>
  3758. <tag><var>old-postrm</var> <tt>upgrade</tt>
  3759. <var>new-version</var></tag>
  3760. <tag><var>disappearer's-postrm</var> <tt>disappear</tt>
  3761. <var>overwriter</var> <var>overwriter-version</var></tag>
  3762. <item>
  3763. The <prgn>postrm</prgn> script is called after the package's
  3764. files have been removed or replaced. The package
  3765. whose <prgn>postrm</prgn> is being called may have
  3766. previously been deconfigured and only be "Unpacked", at which
  3767. point subsequent package changes do not consider its
  3768. dependencies. Therefore, all <prgn>postrm</prgn> actions
  3769. may only rely on essential packages and must gracefully skip
  3770. any actions that require the package's dependencies if those
  3771. dependencies are unavailable.<footnote>
  3772. This is often done by checking whether the command or
  3773. facility the <prgn>postrm</prgn> intends to call is
  3774. available before calling it. For example:
  3775. <example>
  3776. if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
  3777. . /usr/share/debconf/confmodule
  3778. db_purge
  3779. fi
  3780. </example>
  3781. in <prgn>postrm</prgn> purges the <prgn>debconf</prgn>
  3782. configuration for the package
  3783. if <package>debconf</package> is installed.
  3784. </footnote>
  3785. </item>
  3786. <tag><var>new-postrm</var> <tt>failed-upgrade</tt>
  3787. <var>old-version</var></tag>
  3788. <item>
  3789. Called when the old <tt>postrm upgrade</tt> action fails.
  3790. The new package will be unpacked, but only essential
  3791. packages and pre-dependencies can be relied on.
  3792. Pre-dependencies will either be configured or will be
  3793. "Unpacked" or "Half-Configured" but previously had been
  3794. configured and was never removed.
  3795. </item>
  3796. <tag><var>new-postrm</var> <tt>abort-install</tt></tag>
  3797. <tag><var>new-postrm</var> <tt>abort-install</tt>
  3798. <var>old-version</var></tag>
  3799. <tag><var>new-postrm</var> <tt>abort-upgrade</tt>
  3800. <var>old-version</var></tag>
  3801. <item>
  3802. Called before unpacking the new package as part of the
  3803. error handling of <prgn>preinst</prgn> failures. May assume
  3804. the same state as <prgn>preinst</prgn> can assume.
  3805. </item>
  3806. </taglist>
  3807. </p>
  3808. </sect>
  3809. <sect id="unpackphase">
  3810. <heading>Details of unpack phase of installation or upgrade</heading>
  3811. <p>
  3812. The procedure on installation/upgrade/overwrite/disappear
  3813. (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
  3814. stage of <tt>dpkg --install</tt>) is as follows. In each
  3815. case, if a major error occurs (unless listed below) the
  3816. actions are, in general, run backwards - this means that the
  3817. maintainer scripts are run with different arguments in
  3818. reverse order. These are the "error unwind" calls listed
  3819. below.
  3820. <enumlist>
  3821. <item>
  3822. <enumlist>
  3823. <item>
  3824. If a version of the package is already "Installed", call
  3825. <example compact="compact">
  3826. <var>old-prerm</var> upgrade <var>new-version</var>
  3827. </example>
  3828. </item>
  3829. <item>
  3830. If the script runs but exits with a non-zero
  3831. exit status, <prgn>dpkg</prgn> will attempt:
  3832. <example compact="compact">
  3833. <var>new-prerm</var> failed-upgrade <var>old-version</var>
  3834. </example>
  3835. If this works, the upgrade continues. If this
  3836. does not work, the error unwind:
  3837. <example compact="compact">
  3838. <var>old-postinst</var> abort-upgrade <var>new-version</var>
  3839. </example>
  3840. If this works, then the old-version is
  3841. "Installed", if not, the old version is in a
  3842. "Half-Configured" state.
  3843. </item>
  3844. </enumlist>
  3845. </item>
  3846. <item>
  3847. If a "conflicting" package is being removed at the same time,
  3848. or if any package will be broken (due to <tt>Breaks</tt>):
  3849. <enumlist>
  3850. <item>
  3851. If <tt>--auto-deconfigure</tt> is
  3852. specified, call, for each package to be deconfigured
  3853. due to <tt>Breaks</tt>:
  3854. <example compact="compact">
  3855. <var>deconfigured's-prerm</var> deconfigure \
  3856. in-favour <var>package-being-installed</var> <var>version</var>
  3857. </example>
  3858. Error unwind:
  3859. <example compact="compact">
  3860. <var>deconfigured's-postinst</var> abort-deconfigure \
  3861. in-favour <var>package-being-installed-but-failed</var> <var>version</var>
  3862. </example>
  3863. The deconfigured packages are marked as
  3864. requiring configuration, so that if
  3865. <tt>--install</tt> is used they will be
  3866. configured again if possible.
  3867. </item>
  3868. <item>
  3869. If any packages depended on a conflicting
  3870. package being removed and <tt>--auto-deconfigure</tt> is
  3871. specified, call, for each such package:
  3872. <example compact="compact">
  3873. <var>deconfigured's-prerm</var> deconfigure \
  3874. in-favour <var>package-being-installed</var> <var>version</var> \
  3875. removing <var>conflicting-package</var> <var>version</var>
  3876. </example>
  3877. Error unwind:
  3878. <example compact="compact">
  3879. <var>deconfigured's-postinst</var> abort-deconfigure \
  3880. in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
  3881. removing <var>conflicting-package</var> <var>version</var>
  3882. </example>
  3883. The deconfigured packages are marked as
  3884. requiring configuration, so that if
  3885. <tt>--install</tt> is used they will be
  3886. configured again if possible.
  3887. </item>
  3888. <item>
  3889. To prepare for removal of each conflicting package, call:
  3890. <example compact="compact">
  3891. <var>conflictor's-prerm</var> remove \
  3892. in-favour <var>package</var> <var>new-version</var>
  3893. </example>
  3894. Error unwind:
  3895. <example compact="compact">
  3896. <var>conflictor's-postinst</var> abort-remove \
  3897. in-favour <var>package</var> <var>new-version</var>
  3898. </example>
  3899. </item>
  3900. </enumlist>
  3901. </item>
  3902. <item>
  3903. <enumlist>
  3904. <item>
  3905. If the package is being upgraded, call:
  3906. <example compact="compact">
  3907. <var>new-preinst</var> upgrade <var>old-version</var>
  3908. </example>
  3909. If this fails, we call:
  3910. <example>
  3911. <var>new-postrm</var> abort-upgrade <var>old-version</var>
  3912. </example>
  3913. <enumlist>
  3914. <item>
  3915. <p>
  3916. If that works, then
  3917. <example>
  3918. <var>old-postinst</var> abort-upgrade <var>new-version</var>
  3919. </example>
  3920. is called. If this works, then the old version
  3921. is in an "Installed" state, or else it is left
  3922. in an "Unpacked" state.
  3923. </p>
  3924. </item>
  3925. <item>
  3926. <p>
  3927. If it fails, then the old version is left
  3928. in an "Half-Installed" state.
  3929. </p>
  3930. </item>
  3931. </enumlist>
  3932. </item>
  3933. <item>
  3934. Otherwise, if the package had some configuration
  3935. files from a previous version installed (i.e., it
  3936. is in the "Config-Files" state):
  3937. <example compact="compact">
  3938. <var>new-preinst</var> install <var>old-version</var>
  3939. </example>
  3940. Error unwind:
  3941. <example>
  3942. <var>new-postrm</var> abort-install <var>old-version</var>
  3943. </example>
  3944. If this fails, the package is left in a
  3945. "Half-Installed" state, which requires a
  3946. reinstall. If it works, the packages is left in
  3947. a "Config-Files" state.
  3948. </item>
  3949. <item>
  3950. Otherwise (i.e., the package was completely purged):
  3951. <example compact="compact">
  3952. <var>new-preinst</var> install
  3953. </example>
  3954. Error unwind:
  3955. <example compact="compact">
  3956. <var>new-postrm</var> abort-install
  3957. </example>
  3958. If the error-unwind fails, the package is in a
  3959. "Half-Installed" phase, and requires a
  3960. reinstall. If the error unwind works, the
  3961. package is in the "Not-Installed" state.
  3962. </item>
  3963. </enumlist>
  3964. </item>
  3965. <item>
  3966. <p>
  3967. The new package's files are unpacked, overwriting any
  3968. that may be on the system already, for example any
  3969. from the old version of the same package or from
  3970. another package. Backups of the old files are kept
  3971. temporarily, and if anything goes wrong the package
  3972. management system will attempt to put them back as
  3973. part of the error unwind.
  3974. </p>
  3975. <p>
  3976. It is an error for a package to contain files which
  3977. are on the system in another package, unless
  3978. <tt>Replaces</tt> is used (see <ref id="replaces">).
  3979. <!--
  3980. The following paragraph is not currently the case:
  3981. Currently the <tt>- - force-overwrite</tt> flag is
  3982. enabled, downgrading it to a warning, but this may not
  3983. always be the case.
  3984. -->
  3985. </p>
  3986. <p>
  3987. It is a more serious error for a package to contain a
  3988. plain file or other kind of non-directory where another
  3989. package has a directory (again, unless
  3990. <tt>Replaces</tt> is used). This error can be
  3991. overridden if desired using
  3992. <tt>--force-overwrite-dir</tt>, but this is not
  3993. advisable.
  3994. </p>
  3995. <p>
  3996. Packages which overwrite each other's files produce
  3997. behavior which, though deterministic, is hard for the
  3998. system administrator to understand. It can easily
  3999. lead to "missing" programs if, for example, a package
  4000. is unpacked which overwrites a file from another
  4001. package, and is then removed again.<footnote>
  4002. Part of the problem is due to what is arguably a
  4003. bug in <prgn>dpkg</prgn>.
  4004. </footnote>
  4005. </p>
  4006. <p>
  4007. A directory will never be replaced by a symbolic link
  4008. to a directory or vice versa; instead, the existing
  4009. state (symlink or not) will be left alone and
  4010. <prgn>dpkg</prgn> will follow the symlink if there is
  4011. one.
  4012. </p>
  4013. </item>
  4014. <item>
  4015. <p>
  4016. <enumlist>
  4017. <item>
  4018. If the package is being upgraded, call
  4019. <example compact="compact">
  4020. <var>old-postrm</var> upgrade <var>new-version</var>
  4021. </example>
  4022. </item>
  4023. <item>
  4024. If this fails, <prgn>dpkg</prgn> will attempt:
  4025. <example compact="compact">
  4026. <var>new-postrm</var> failed-upgrade <var>old-version</var>
  4027. </example>
  4028. If this works, installation continues. If not,
  4029. Error unwind:
  4030. <example compact="compact">
  4031. <var>old-preinst</var> abort-upgrade <var>new-version</var>
  4032. </example>
  4033. If this fails, the old version is left in a
  4034. "Half-Installed" state. If it works, dpkg now
  4035. calls:
  4036. <example compact="compact">
  4037. <var>new-postrm</var> abort-upgrade <var>old-version</var>
  4038. </example>
  4039. If this fails, the old version is left in a
  4040. "Half-Installed" state. If it works, dpkg now
  4041. calls:
  4042. <example compact="compact">
  4043. <var>old-postinst</var> abort-upgrade <var>new-version</var>
  4044. </example>
  4045. If this fails, the old version is in an
  4046. "Unpacked" state.
  4047. </item>
  4048. </enumlist>
  4049. </p>
  4050. <p>
  4051. This is the point of no return - if
  4052. <prgn>dpkg</prgn> gets this far, it won't back off
  4053. past this point if an error occurs. This will
  4054. leave the package in a fairly bad state, which
  4055. will require a successful re-installation to clear
  4056. up, but it's when <prgn>dpkg</prgn> starts doing
  4057. things that are irreversible.
  4058. </p>
  4059. </item>
  4060. <item>
  4061. Any files which were in the old version of the package
  4062. but not in the new are removed.
  4063. </item>
  4064. <item>
  4065. The new file list replaces the old.
  4066. </item>
  4067. <item>
  4068. The new maintainer scripts replace the old.
  4069. </item>
  4070. <item>
  4071. Any packages all of whose files have been overwritten
  4072. during the installation, and which aren't required for
  4073. dependencies, are considered to have been removed.
  4074. For each such package
  4075. <enumlist>
  4076. <item>
  4077. <prgn>dpkg</prgn> calls:
  4078. <example compact="compact">
  4079. <var>disappearer's-postrm</var> disappear \
  4080. <var>overwriter</var> <var>overwriter-version</var>
  4081. </example>
  4082. </item>
  4083. <item>
  4084. The package's maintainer scripts are removed.
  4085. </item>
  4086. <item>
  4087. It is noted in the status database as being in a
  4088. sane state, namely "Not-Installed" (any conffiles
  4089. it may have are ignored, rather than being
  4090. removed by <prgn>dpkg</prgn>). Note that
  4091. disappearing packages do not have their prerm
  4092. called, because <prgn>dpkg</prgn> doesn't know
  4093. in advance that the package is going to
  4094. vanish.
  4095. </item>
  4096. </enumlist>
  4097. </item>
  4098. <item>
  4099. Any files in the package we're unpacking that are also
  4100. listed in the file lists of other packages are removed
  4101. from those lists. (This will lobotomize the file list
  4102. of the "conflicting" package if there is one.)
  4103. </item>
  4104. <item>
  4105. The backup files made during installation, above, are
  4106. deleted.
  4107. </item>
  4108. <item>
  4109. <p>
  4110. The new package's status is now sane, and recorded as
  4111. "Unpacked".
  4112. </p>
  4113. <p>
  4114. Here is another point of no return - if the
  4115. conflicting package's removal fails we do not unwind
  4116. the rest of the installation; the conflicting package
  4117. is left in a half-removed limbo.
  4118. </p>
  4119. </item>
  4120. <item>
  4121. If there was a conflicting package we go and do the
  4122. removal actions (described below), starting with the
  4123. removal of the conflicting package's files (any that
  4124. are also in the package being unpacked have already
  4125. been removed from the conflicting package's file list,
  4126. and so do not get removed now).
  4127. </item>
  4128. </enumlist>
  4129. </p>
  4130. </sect>
  4131. <sect id="configdetails"><heading>Details of configuration</heading>
  4132. <p>
  4133. When we configure a package (this happens with <tt>dpkg
  4134. --install</tt> and <tt>dpkg --configure</tt>), we first
  4135. update any <tt>conffile</tt>s and then call:
  4136. <example compact="compact">
  4137. <var>postinst</var> configure <var>most-recently-configured-version</var>
  4138. </example>
  4139. </p>
  4140. <p>
  4141. No attempt is made to unwind after errors during
  4142. configuration. If the configuration fails, the package is in
  4143. a "Half-Configured" state, and an error message is generated.
  4144. </p>
  4145. <p>
  4146. If there is no most recently configured version
  4147. <prgn>dpkg</prgn> will pass a null argument.
  4148. <footnote>
  4149. <p>
  4150. Historical note: Truly ancient (pre-1997) versions of
  4151. <prgn>dpkg</prgn> passed <tt>&lt;unknown&gt;</tt>
  4152. (including the angle brackets) in this case. Even older
  4153. ones did not pass a second argument at all, under any
  4154. circumstance. Note that upgrades using such an old dpkg
  4155. version are unlikely to work for other reasons, even if
  4156. this old argument behavior is handled by your postinst script.
  4157. </p>
  4158. </footnote>
  4159. </p>
  4160. </sect>
  4161. <sect id="removedetails"><heading>Details of removal and/or
  4162. configuration purging</heading>
  4163. <p>
  4164. <enumlist>
  4165. <item>
  4166. <p>
  4167. <example compact="compact">
  4168. <var>prerm</var> remove
  4169. </example>
  4170. </p>
  4171. <p>
  4172. If prerm fails during replacement due to conflict
  4173. <example>
  4174. <var>conflictor's-postinst</var> abort-remove \
  4175. in-favour <var>package</var> <var>new-version</var>
  4176. </example>
  4177. Or else we call:
  4178. <example>
  4179. <var>postinst</var> abort-remove
  4180. </example>
  4181. </p>
  4182. <p>
  4183. If this fails, the package is in a "Half-Configured"
  4184. state, or else it remains "Installed".
  4185. </p>
  4186. </item>
  4187. <item>
  4188. The package's files are removed (except <tt>conffile</tt>s).
  4189. </item>
  4190. <item>
  4191. <example compact="compact">
  4192. <var>postrm</var> remove
  4193. </example>
  4194. <p>
  4195. If it fails, there's no error unwind, and the package is in
  4196. an "Half-Installed" state.
  4197. </p>
  4198. </item>
  4199. <item>
  4200. <p>
  4201. All the maintainer scripts except the <prgn>postrm</prgn>
  4202. are removed.
  4203. </p>
  4204. <p>
  4205. If we aren't purging the package we stop here. Note
  4206. that packages which have no <prgn>postrm</prgn> and no
  4207. <tt>conffile</tt>s are automatically purged when
  4208. removed, as there is no difference except for the
  4209. <prgn>dpkg</prgn> status.
  4210. </p>
  4211. </item>
  4212. <item>
  4213. The <tt>conffile</tt>s and any backup files
  4214. (<tt>~</tt>-files, <tt>#*#</tt> files,
  4215. <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
  4216. are removed.
  4217. </item>
  4218. <item>
  4219. <p>
  4220. <example compact="compact">
  4221. <var>postrm</var> purge
  4222. </example>
  4223. </p>
  4224. <p>
  4225. If this fails, the package remains in a "Config-Files"
  4226. state.
  4227. </p>
  4228. </item>
  4229. <item>
  4230. The package's file list is removed.
  4231. </item>
  4232. </enumlist>
  4233. </p>
  4234. </sect>
  4235. </chapt>
  4236. <chapt id="relationships">
  4237. <heading>Declaring relationships between packages</heading>
  4238. <sect id="depsyntax">
  4239. <heading>Syntax of relationship fields</heading>
  4240. <p>
  4241. These fields all have a uniform syntax. They are a list of
  4242. package names separated by commas.
  4243. </p>
  4244. <p>
  4245. In the <tt>Depends</tt>, <tt>Recommends</tt>,
  4246. <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
  4247. <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
  4248. control fields of the package, which declare
  4249. dependencies on other packages, the package names listed may
  4250. also include lists of alternative package names, separated
  4251. by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
  4252. that part of the dependency can be satisfied by any one of
  4253. the alternative packages.
  4254. </p>
  4255. <p>
  4256. All of the fields except for <tt>Provides</tt> may restrict
  4257. their applicability to particular versions of each named
  4258. package. This is done in parentheses after each individual
  4259. package name; the parentheses should contain a relation from
  4260. the list below followed by a version number, in the format
  4261. described in <ref id="f-Version">.
  4262. </p>
  4263. <p>
  4264. The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
  4265. <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for strictly
  4266. earlier, earlier or equal, exactly equal, later or equal and
  4267. strictly later, respectively. The deprecated
  4268. forms <tt>&lt;</tt> and <tt>&gt;</tt> were confusingly used to
  4269. mean earlier/later or equal, rather than strictly earlier/later,
  4270. and must not appear in new packages (though <prgn>dpkg</prgn>
  4271. still supports them with a warning).
  4272. </p>
  4273. <p>
  4274. Whitespace may appear at any point in the version
  4275. specification subject to the rules in <ref
  4276. id="controlsyntax">, and must appear where it's necessary to
  4277. disambiguate; it is not otherwise significant. All of the
  4278. relationship fields can only be folded in source package control files. For
  4279. consistency and in case of future changes to
  4280. <prgn>dpkg</prgn> it is recommended that a single space be
  4281. used after a version relationship and before a version
  4282. number; it is also conventional to put a single space after
  4283. each comma, on either side of each vertical bar, and before
  4284. each open parenthesis. When opening a continuation line in a relationship field, it
  4285. is conventional to do so after a comma and before the space
  4286. following that comma.
  4287. </p>
  4288. <p>
  4289. For example, a list of dependencies might appear as:
  4290. <example compact="compact">
  4291. Package: mutt
  4292. Version: 1.3.17-1
  4293. Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
  4294. </example>
  4295. </p>
  4296. <p>
  4297. Relationships may be restricted to a certain set of
  4298. architectures. This is indicated in brackets after each
  4299. individual package name and the optional version specification.
  4300. The brackets enclose a non-empty list of Debian architecture names
  4301. in the format described in <ref id="arch-spec">,
  4302. separated by whitespace. Exclamation marks may be prepended to
  4303. each of the names. (It is not permitted for some names to be
  4304. prepended with exclamation marks while others aren't.)
  4305. </p>
  4306. <p>
  4307. For build relationship fields
  4308. (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
  4309. <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>), if
  4310. the current Debian host architecture is not in this list and
  4311. there are no exclamation marks in the list, or it is in the list
  4312. with a prepended exclamation mark, the package name and the
  4313. associated version specification are ignored completely for the
  4314. purposes of defining the relationships.
  4315. </p>
  4316. <p>
  4317. For example:
  4318. <example compact="compact">
  4319. Source: glibc
  4320. Build-Depends-Indep: texinfo
  4321. Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
  4322. hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
  4323. </example>
  4324. requires <tt>kernel-headers-2.2.10</tt> on all architectures
  4325. other than hurd-i386 and requires <tt>hurd-dev</tt> and
  4326. <tt>gnumach-dev</tt> only on hurd-i386.
  4327. </p>
  4328. <p>
  4329. For binary relationship fields and the <tt>Built-Using</tt>
  4330. field, the architecture restriction
  4331. syntax is only supported in the source package control
  4332. file <file>debian/control</file>. When the corresponding binary
  4333. package control file is generated, the relationship will either
  4334. be omitted or included without the architecture restriction
  4335. based on the architecture of the binary package. This means
  4336. that architecture restrictions must not be used in binary
  4337. relationship fields for architecture-independent packages
  4338. (<tt>Architecture: all</tt>).
  4339. </p>
  4340. <p>
  4341. For example:
  4342. <example compact="compact">
  4343. Depends: foo [i386], bar [amd64]
  4344. </example>
  4345. becomes <tt>Depends: foo</tt> when the package is built on
  4346. the <tt>i386</tt> architecture, <tt>Depends: bar</tt> when the
  4347. package is built on the <tt>amd64</tt> architecture, and omitted
  4348. entirely in binary packages built on all other architectures.
  4349. </p>
  4350. <p>
  4351. If the architecture-restricted dependency is part of a set of
  4352. alternatives using <tt>|</tt>, that alternative is ignored
  4353. completely on architectures that do not match the restriction.
  4354. For example:
  4355. <example compact="compact">
  4356. Build-Depends: foo [!i386] | bar [!amd64]
  4357. </example>
  4358. is equivalent to <tt>bar</tt> on the i386 architecture, to
  4359. <tt>foo</tt> on the amd64 architecture, and to <tt>foo |
  4360. bar</tt> on all other architectures.
  4361. </p>
  4362. <p>
  4363. Relationships may also be restricted to a certain set of
  4364. architectures using architecture wildcards in the format
  4365. described in <ref id="arch-wildcard-spec">. The syntax for
  4366. declaring such restrictions is the same as declaring
  4367. restrictions using a certain set of architectures without
  4368. architecture wildcards. For example:
  4369. <example compact="compact">
  4370. Build-Depends: foo [linux-any], bar [any-i386], baz [!linux-any]
  4371. </example>
  4372. is equivalent to <tt>foo</tt> on architectures using the Linux
  4373. kernel and any cpu, <tt>bar</tt> on architectures using any
  4374. kernel and an i386 cpu, and <tt>baz</tt> on any architecture
  4375. using a kernel other than Linux.
  4376. </p>
  4377. <p>
  4378. Note that the binary package relationship fields such as
  4379. <tt>Depends</tt> appear in one of the binary package
  4380. sections of the control file, whereas the build-time
  4381. relationships such as <tt>Build-Depends</tt> appear in the
  4382. source package section of the control file (which is the
  4383. first section).
  4384. </p>
  4385. </sect>
  4386. <sect id="binarydeps">
  4387. <heading>Binary Dependencies - <tt>Depends</tt>,
  4388. <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
  4389. <tt>Pre-Depends</tt>
  4390. </heading>
  4391. <p>
  4392. Packages can declare in their control file that they have
  4393. certain relationships to other packages - for example, that
  4394. they may not be installed at the same time as certain other
  4395. packages, and/or that they depend on the presence of others.
  4396. </p>
  4397. <p>
  4398. This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
  4399. <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
  4400. <tt>Breaks</tt> and <tt>Conflicts</tt> control fields.
  4401. <tt>Breaks</tt> is described in <ref id="breaks">, and
  4402. <tt>Conflicts</tt> is described in <ref id="conflicts">. The
  4403. rest are described below.
  4404. </p>
  4405. <p>
  4406. These seven fields are used to declare a dependency
  4407. relationship by one package on another. Except for
  4408. <tt>Enhances</tt> and <tt>Breaks</tt>, they appear in the
  4409. depending (binary) package's control file.
  4410. (<tt>Enhances</tt> appears in the recommending package's
  4411. control file, and <tt>Breaks</tt> appears in the version of
  4412. depended-on package which causes the named package to
  4413. break).
  4414. </p>
  4415. <p>
  4416. A <tt>Depends</tt> field takes effect <em>only</em> when a
  4417. package is to be configured. It does not prevent a package
  4418. being on the system in an unconfigured state while its
  4419. dependencies are unsatisfied, and it is possible to replace
  4420. a package whose dependencies are satisfied and which is
  4421. properly installed with a different version whose
  4422. dependencies are not and cannot be satisfied; when this is
  4423. done the depending package will be left unconfigured (since
  4424. attempts to configure it will give errors) and will not
  4425. function properly. If it is necessary, a
  4426. <tt>Pre-Depends</tt> field can be used, which has a partial
  4427. effect even when a package is being unpacked, as explained
  4428. in detail below. (The other three dependency fields,
  4429. <tt>Recommends</tt>, <tt>Suggests</tt> and
  4430. <tt>Enhances</tt>, are only used by the various front-ends
  4431. to <prgn>dpkg</prgn> such as <prgn>apt-get</prgn>,
  4432. <prgn>aptitude</prgn>, and <prgn>dselect</prgn>.)
  4433. </p>
  4434. <p>
  4435. Since <tt>Depends</tt> only places requirements on the order in
  4436. which packages are configured, packages in an installation run
  4437. are usually all unpacked first and all configured later.
  4438. <footnote>
  4439. This approach makes dependency resolution easier. If two
  4440. packages A and B are being upgraded, the installed package A
  4441. depends on exactly the installed package B, and the new
  4442. package A depends on exactly the new package B (a common
  4443. situation when upgrading shared libraries and their
  4444. corresponding development packages), satisfying the
  4445. dependencies at every stage of the upgrade would be
  4446. impossible. This relaxed restriction means that both new
  4447. packages can be unpacked together and then configured in their
  4448. dependency order.
  4449. </footnote>
  4450. </p>
  4451. <p>
  4452. If there is a circular dependency among packages being installed
  4453. or removed, installation or removal order honoring the
  4454. dependency order is impossible, requiring the dependency loop be
  4455. broken at some point and the dependency requirements violated
  4456. for at least one package. Packages involved in circular
  4457. dependencies may not be able to rely on their dependencies being
  4458. configured before they themselves are configured, depending on
  4459. which side of the break of the circular dependency loop they
  4460. happen to be on. If one of the packages in the loop has
  4461. no <prgn>postinst</prgn> script, then the cycle will be broken
  4462. at that package; this ensures that all <prgn>postinst</prgn>
  4463. scripts are run with their dependencies properly configured if
  4464. this is possible. Otherwise the breaking point is arbitrary.
  4465. Packages should therefore avoid circular dependencies where
  4466. possible, particularly if they have <prgn>postinst</prgn>
  4467. scripts.
  4468. </p>
  4469. <p>
  4470. The meaning of the five dependency fields is as follows:
  4471. <taglist>
  4472. <tag><tt>Depends</tt></tag>
  4473. <item>
  4474. <p>
  4475. This declares an absolute dependency. A package will
  4476. not be configured unless all of the packages listed in
  4477. its <tt>Depends</tt> field have been correctly
  4478. configured (unless there is a circular dependency as
  4479. described above).
  4480. </p>
  4481. <p>
  4482. The <tt>Depends</tt> field should be used if the
  4483. depended-on package is required for the depending
  4484. package to provide a significant amount of
  4485. functionality.
  4486. </p>
  4487. <p>
  4488. The <tt>Depends</tt> field should also be used if the
  4489. <prgn>postinst</prgn> or <prgn>prerm</prgn> scripts
  4490. require the depended-on package to be unpacked or
  4491. configured in order to run. In the case of <tt>postinst
  4492. configure</tt>, the depended-on packages will be unpacked
  4493. and configured first. (If both packages are involved in a
  4494. dependency loop, this might not work as expected; see the
  4495. explanation a few paragraphs back.) In the case
  4496. of <prgn>prerm</prgn> or other <prgn>postinst</prgn>
  4497. actions, the package dependencies will normally be at
  4498. least unpacked, but they may be only "Half-Installed" if a
  4499. previous upgrade of the dependency failed.
  4500. </p>
  4501. <p>
  4502. Finally, the <tt>Depends</tt> field should be used if the
  4503. depended-on package is needed by the <prgn>postrm</prgn>
  4504. script to fully clean up after the package removal. There
  4505. is no guarantee that package dependencies will be
  4506. available when <prgn>postrm</prgn> is run, but the
  4507. depended-on package is more likely to be available if the
  4508. package declares a dependency (particularly in the case
  4509. of <tt>postrm remove</tt>). The <prgn>postrm</prgn>
  4510. script must gracefully skip actions that require a
  4511. dependency if that dependency isn't available.
  4512. </p>
  4513. </item>
  4514. <tag><tt>Recommends</tt></tag>
  4515. <item>
  4516. <p>
  4517. This declares a strong, but not absolute, dependency.
  4518. </p>
  4519. <p>
  4520. The <tt>Recommends</tt> field should list packages
  4521. that would be found together with this one in all but
  4522. unusual installations.
  4523. </p>
  4524. </item>
  4525. <tag><tt>Suggests</tt></tag>
  4526. <item>
  4527. This is used to declare that one package may be more
  4528. useful with one or more others. Using this field
  4529. tells the packaging system and the user that the
  4530. listed packages are related to this one and can
  4531. perhaps enhance its usefulness, but that installing
  4532. this one without them is perfectly reasonable.
  4533. </item>
  4534. <tag><tt>Enhances</tt></tag>
  4535. <item>
  4536. This field is similar to Suggests but works in the
  4537. opposite direction. It is used to declare that a
  4538. package can enhance the functionality of another
  4539. package.
  4540. </item>
  4541. <tag><tt>Pre-Depends</tt></tag>
  4542. <item>
  4543. <p>
  4544. This field is like <tt>Depends</tt>, except that it
  4545. also forces <prgn>dpkg</prgn> to complete installation
  4546. of the packages named before even starting the
  4547. installation of the package which declares the
  4548. pre-dependency, as follows:
  4549. </p>
  4550. <p>
  4551. When a package declaring a pre-dependency is about to
  4552. be <em>unpacked</em> the pre-dependency can be
  4553. satisfied if the depended-on package is either fully
  4554. configured, <em>or even if</em> the depended-on
  4555. package(s) are only in the "Unpacked" or the "Half-Configured"
  4556. state, provided that they have been configured
  4557. correctly at some point in the past (and not removed
  4558. or partially removed since). In this case, both the
  4559. previously-configured and currently "Unpacked" or
  4560. "Half-Configured" versions must satisfy any version
  4561. clause in the <tt>Pre-Depends</tt> field.
  4562. </p>
  4563. <p>
  4564. When the package declaring a pre-dependency is about to
  4565. be <em>configured</em>, the pre-dependency will be treated
  4566. as a normal <tt>Depends</tt>. It will be considered
  4567. satisfied only if the depended-on package has been
  4568. correctly configured. However, unlike
  4569. with <tt>Depends</tt>, <tt>Pre-Depends</tt> does not
  4570. permit circular dependencies to be broken. If a circular
  4571. dependency is encountered while attempting to honor
  4572. <tt>Pre-Depends</tt>, the installation will be aborted.
  4573. </p>
  4574. <p>
  4575. <tt>Pre-Depends</tt> are also required if the
  4576. <prgn>preinst</prgn> script depends on the named package.
  4577. It is best to avoid this situation if possible.
  4578. </p>
  4579. <p>
  4580. <tt>Pre-Depends</tt> should be used sparingly,
  4581. preferably only by packages whose premature upgrade or
  4582. installation would hamper the ability of the system to
  4583. continue with any upgrade that might be in progress.
  4584. </p>
  4585. <p>
  4586. You should not specify a <tt>Pre-Depends</tt> entry for a
  4587. package before this has been discussed on the
  4588. <tt>debian-devel</tt> mailing list and a consensus about
  4589. doing that has been reached. See <ref id="dependencies">.
  4590. </p>
  4591. </item>
  4592. </taglist>
  4593. </p>
  4594. <p>
  4595. When selecting which level of dependency to use you should
  4596. consider how important the depended-on package is to the
  4597. functionality of the one declaring the dependency. Some
  4598. packages are composed of components of varying degrees of
  4599. importance. Such a package should list using
  4600. <tt>Depends</tt> the package(s) which are required by the
  4601. more important components. The other components'
  4602. requirements may be mentioned as Suggestions or
  4603. Recommendations, as appropriate to the components' relative
  4604. importance.
  4605. </p>
  4606. </sect>
  4607. <sect id="breaks">
  4608. <heading>Packages which break other packages - <tt>Breaks</tt></heading>
  4609. <p>
  4610. When one binary package declares that it breaks another,
  4611. <prgn>dpkg</prgn> will refuse to allow the package which
  4612. declares <tt>Breaks</tt> to be unpacked unless the broken
  4613. package is deconfigured first, and it will refuse to
  4614. allow the broken package to be reconfigured.
  4615. </p>
  4616. <p>
  4617. A package will not be regarded as causing breakage merely
  4618. because its configuration files are still installed; it must
  4619. be at least "Half-Installed".
  4620. </p>
  4621. <p>
  4622. A special exception is made for packages which declare that
  4623. they break their own package name or a virtual package which
  4624. they provide (see below): this does not count as a real
  4625. breakage.
  4626. </p>
  4627. <p>
  4628. Normally a <tt>Breaks</tt> entry will have an "earlier than"
  4629. version clause; such a <tt>Breaks</tt> is introduced in the
  4630. version of an (implicit or explicit) dependency which violates
  4631. an assumption or reveals a bug in earlier versions of the broken
  4632. package, or which takes over a file from earlier versions of the
  4633. package named in <tt>Breaks</tt>. This use of <tt>Breaks</tt>
  4634. will inform higher-level package management tools that the
  4635. broken package must be upgraded before the new one.
  4636. </p>
  4637. <p>
  4638. If the breaking package also overwrites some files from the
  4639. older package, it should use <tt>Replaces</tt> to ensure this
  4640. goes smoothly. See <ref id="replaces"> for a full discussion
  4641. of taking over files from other packages, including how to
  4642. use <tt>Breaks</tt> in those cases.
  4643. </p>
  4644. <p>
  4645. Many of the cases where <tt>Breaks</tt> should be used were
  4646. previously handled with <tt>Conflicts</tt>
  4647. because <tt>Breaks</tt> did not yet exist.
  4648. Many <tt>Conflicts</tt> fields should now be <tt>Breaks</tt>.
  4649. See <ref id="conflicts"> for more information about the
  4650. differences.
  4651. </p>
  4652. </sect>
  4653. <sect id="conflicts">
  4654. <heading>Conflicting binary packages - <tt>Conflicts</tt></heading>
  4655. <p>
  4656. When one binary package declares a conflict with another using
  4657. a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will refuse to
  4658. allow them to be unpacked on the system at the same time. This
  4659. is a stronger restriction than <tt>Breaks</tt>, which prevents
  4660. the broken package from being configured while the breaking
  4661. package is in the "Unpacked" state but allows both packages to
  4662. be unpacked at the same time.
  4663. </p>
  4664. <p>
  4665. If one package is to be unpacked, the other must be removed
  4666. first. If the package being unpacked is marked as replacing
  4667. (see <ref id="replaces">, but note that <tt>Breaks</tt> should
  4668. normally be used in this case) the one on the system, or the one
  4669. on the system is marked as deselected, or both packages are
  4670. marked <tt>Essential</tt>, then <prgn>dpkg</prgn> will
  4671. automatically remove the package which is causing the conflict.
  4672. Otherwise, it will halt the installation of the new package with
  4673. an error. This mechanism is specifically designed to produce an
  4674. error when the installed package is <tt>Essential</tt>, but the
  4675. new package is not.
  4676. </p>
  4677. <p>
  4678. A package will not cause a conflict merely because its
  4679. configuration files are still installed; it must be at least
  4680. "Half-Installed".
  4681. </p>
  4682. <p>
  4683. A special exception is made for packages which declare a
  4684. conflict with their own package name, or with a virtual
  4685. package which they provide (see below): this does not
  4686. prevent their installation, and allows a package to conflict
  4687. with others providing a replacement for it. You use this
  4688. feature when you want the package in question to be the only
  4689. package providing some feature.
  4690. </p>
  4691. <p>
  4692. Normally, <tt>Breaks</tt> should be used instead
  4693. of <tt>Conflicts</tt> since <tt>Conflicts</tt> imposes a
  4694. stronger restriction on the ordering of package installation or
  4695. upgrade and can make it more difficult for the package manager
  4696. to find a correct solution to an upgrade or installation
  4697. problem. <tt>Breaks</tt> should be used
  4698. <list>
  4699. <item>when moving a file from one package to another (see
  4700. <ref id="replaces">),</item>
  4701. <item>when splitting a package (a special case of the previous
  4702. one), or</item>
  4703. <item>when the breaking package exposes a bug in or interacts
  4704. badly with particular versions of the broken
  4705. package.</item>
  4706. </list>
  4707. <tt>Conflicts</tt> should be used
  4708. <list>
  4709. <item>when two packages provide the same file and will
  4710. continue to do so,</item>
  4711. <item>in conjunction with <tt>Provides</tt> when only one
  4712. package providing a given virtual facility may be unpacked
  4713. at a time (see <ref id="virtual">),</item>
  4714. <item>in other cases where one must prevent simultaneous
  4715. installation of two packages for reasons that are ongoing
  4716. (not fixed in a later version of one of the packages) or
  4717. that must prevent both packages from being unpacked at the
  4718. same time, not just configured.</item>
  4719. </list>
  4720. Be aware that adding <tt>Conflicts</tt> is normally not the best
  4721. solution when two packages provide the same files. Depending on
  4722. the reason for that conflict, using alternatives or renaming the
  4723. files is often a better approach. See, for
  4724. example, <ref id="binaries">.
  4725. </p>
  4726. <p>
  4727. Neither <tt>Breaks</tt> nor <tt>Conflicts</tt> should be used
  4728. unless two packages cannot be installed at the same time or
  4729. installing them both causes one of them to be broken or
  4730. unusable. Having similar functionality or performing the same
  4731. tasks as another package is not sufficient reason to
  4732. declare <tt>Breaks</tt> or <tt>Conflicts</tt> with that package.
  4733. </p>
  4734. <p>
  4735. A <tt>Conflicts</tt> entry may have an "earlier than" version
  4736. clause if the reason for the conflict is corrected in a later
  4737. version of one of the packages. However, normally the presence
  4738. of an "earlier than" version clause is a sign
  4739. that <tt>Breaks</tt> should have been used instead. An "earlier
  4740. than" version clause in <tt>Conflicts</tt>
  4741. prevents <prgn>dpkg</prgn> from upgrading or installing the
  4742. package which declares such a conflict until the upgrade or
  4743. removal of the conflicted-with package has been completed, which
  4744. is a strong restriction.
  4745. </p>
  4746. </sect>
  4747. <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
  4748. </heading>
  4749. <p>
  4750. As well as the names of actual ("concrete") packages, the
  4751. package relationship fields <tt>Depends</tt>,
  4752. <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
  4753. <tt>Pre-Depends</tt>, <tt>Breaks</tt>, <tt>Conflicts</tt>,
  4754. <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
  4755. <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
  4756. may mention "virtual packages".
  4757. </p>
  4758. <p>
  4759. A <em>virtual package</em> is one which appears in the
  4760. <tt>Provides</tt> control field of another package. The effect
  4761. is as if the package(s) which provide a particular virtual
  4762. package name had been listed by name everywhere the virtual
  4763. package name appears. (See also <ref id="virtual_pkg">)
  4764. </p>
  4765. <p>
  4766. If there are both concrete and virtual packages of the same
  4767. name, then the dependency may be satisfied (or the conflict
  4768. caused) by either the concrete package with the name in
  4769. question or any other concrete package which provides the
  4770. virtual package with the name in question. This is so that,
  4771. for example, supposing we have
  4772. <example compact="compact">
  4773. Package: foo
  4774. Depends: bar
  4775. </example> and someone else releases an enhanced version of
  4776. the <tt>bar</tt> package they can say:
  4777. <example compact="compact">
  4778. Package: bar-plus
  4779. Provides: bar
  4780. </example>
  4781. and the <tt>bar-plus</tt> package will now also satisfy the
  4782. dependency for the <tt>foo</tt> package.
  4783. </p>
  4784. <p>
  4785. If a relationship field has a version number attached, only real
  4786. packages will be considered to see whether the relationship is
  4787. satisfied (or the prohibition violated, for a conflict or
  4788. breakage). In other words, if a version number is specified,
  4789. this is a request to ignore all <tt>Provides</tt> for that
  4790. package name and consider only real packages. The package
  4791. manager will assume that a package providing that virtual
  4792. package is not of the "right" version. A <tt>Provides</tt>
  4793. field may not contain version numbers, and the version number of
  4794. the concrete package which provides a particular virtual package
  4795. will not be considered when considering a dependency on or
  4796. conflict with the virtual package name.<footnote>
  4797. It is possible that a future release of <prgn>dpkg</prgn> may
  4798. add the ability to specify a version number for each virtual
  4799. package it provides. This feature is not yet present,
  4800. however, and is expected to be used only infrequently.
  4801. </footnote>
  4802. </p>
  4803. <p>
  4804. To specify which of a set of real packages should be the default
  4805. to satisfy a particular dependency on a virtual package, list
  4806. the real package as an alternative before the virtual one.
  4807. </p>
  4808. <p>
  4809. If the virtual package represents a facility that can only be
  4810. provided by one real package at a time, such as
  4811. the <package>mail-transport-agent</package> virtual package that
  4812. requires installation of a binary that would conflict with all
  4813. other providers of that virtual package (see
  4814. <ref id="mail-transport-agents">), all packages providing that
  4815. virtual package should also declare a conflict with it
  4816. using <tt>Conflicts</tt>. This will ensure that at most one
  4817. provider of that virtual package is unpacked or installed at a
  4818. time.
  4819. </p>
  4820. </sect>
  4821. <sect id="replaces"><heading>Overwriting files and replacing
  4822. packages - <tt>Replaces</tt></heading>
  4823. <p>
  4824. Packages can declare in their control file that they should
  4825. overwrite files in certain other packages, or completely replace
  4826. other packages. The <tt>Replaces</tt> control field has these
  4827. two distinct purposes.
  4828. </p>
  4829. <sect1><heading>Overwriting files in other packages</heading>
  4830. <p>
  4831. It is usually an error for a package to contain files which
  4832. are on the system in another package. However, if the
  4833. overwriting package declares that it <tt>Replaces</tt> the one
  4834. containing the file being overwritten, then <prgn>dpkg</prgn>
  4835. will replace the file from the old package with that from the
  4836. new. The file will no longer be listed as "owned" by the old
  4837. package and will be taken over by the new package.
  4838. Normally, <tt>Breaks</tt> should be used in conjunction
  4839. with <tt>Replaces</tt>.<footnote>
  4840. To see why <tt>Breaks</tt> is normally needed in addition
  4841. to <tt>Replaces</tt>, consider the case of a file in the
  4842. package <package>foo</package> being taken over by the
  4843. package <package>foo-data</package>.
  4844. <tt>Replaces</tt> will allow <package>foo-data</package> to
  4845. be installed and take over that file. However,
  4846. without <tt>Breaks</tt>, nothing
  4847. requires <package>foo</package> to be upgraded to a newer
  4848. version that knows it does not include that file and instead
  4849. depends on <package>foo-data</package>. Nothing would
  4850. prevent the new <package>foo-data</package> package from
  4851. being installed and then removed, removing the file that it
  4852. took over from <package>foo</package>. After that
  4853. operation, the package manager would think the system was in
  4854. a consistent state, but the <package>foo</package> package
  4855. would be missing one of its files.
  4856. </footnote>
  4857. </p>
  4858. <p>
  4859. For example, if a package <package>foo</package> is split
  4860. into <package>foo</package> and <package>foo-data</package>
  4861. starting at version 1.2-3, <package>foo-data</package> would
  4862. have the fields
  4863. <example compact="compact">
  4864. Replaces: foo (&lt;&lt; 1.2-3)
  4865. Breaks: foo (&lt;&lt; 1.2-3)
  4866. </example>
  4867. in its control file. The new version of the
  4868. package <package>foo</package> would normally have the field
  4869. <example compact="compact">
  4870. Depends: foo-data (&gt;= 1.2-3)
  4871. </example>
  4872. (or possibly <tt>Recommends</tt> or even <tt>Suggests</tt> if
  4873. the files moved into <package>foo-data</package> are not
  4874. required for normal operation).
  4875. </p>
  4876. <p>
  4877. If a package is completely replaced in this way, so that
  4878. <prgn>dpkg</prgn> does not know of any files it still
  4879. contains, it is considered to have "disappeared". It will
  4880. be marked as not wanted on the system (selected for
  4881. removal) and "Not-Installed". Any <tt>conffile</tt>s
  4882. details noted for the package will be ignored, as they
  4883. will have been taken over by the overwriting package. The
  4884. package's <prgn>postrm</prgn> script will be run with a
  4885. special argument to allow the package to do any final
  4886. cleanup required. See <ref id="mscriptsinstact">.
  4887. <footnote>
  4888. Replaces is a one way relationship. You have to install
  4889. the replacing package after the replaced package.
  4890. </footnote>
  4891. </p>
  4892. <p>
  4893. For this usage of <tt>Replaces</tt>, virtual packages (see
  4894. <ref id="virtual">) are not considered when looking at a
  4895. <tt>Replaces</tt> field. The packages declared as being
  4896. replaced must be mentioned by their real names.
  4897. </p>
  4898. <p>
  4899. This usage of <tt>Replaces</tt> only takes effect when both
  4900. packages are at least partially on the system at once. It is
  4901. not relevant if the packages conflict unless the conflict has
  4902. been overridden.
  4903. </p>
  4904. </sect1>
  4905. <sect1><heading>Replacing whole packages, forcing their
  4906. removal</heading>
  4907. <p>
  4908. Second, <tt>Replaces</tt> allows the packaging system to
  4909. resolve which package should be removed when there is a
  4910. conflict (see <ref id="conflicts">). This usage only takes
  4911. effect when the two packages <em>do</em> conflict, so that the
  4912. two usages of this field do not interfere with each other.
  4913. </p>
  4914. <p>
  4915. In this situation, the package declared as being replaced
  4916. can be a virtual package, so for example, all mail
  4917. transport agents (MTAs) would have the following fields in
  4918. their control files:
  4919. <example compact="compact">
  4920. Provides: mail-transport-agent
  4921. Conflicts: mail-transport-agent
  4922. Replaces: mail-transport-agent
  4923. </example>
  4924. ensuring that only one MTA can be unpacked at any one
  4925. time. See <ref id="virtual"> for more information about this
  4926. example.
  4927. </sect1>
  4928. </sect>
  4929. <sect id="sourcebinarydeps">
  4930. <heading>Relationships between source and binary packages -
  4931. <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
  4932. <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
  4933. </heading>
  4934. <p>
  4935. Source packages that require certain binary packages to be
  4936. installed or absent at the time of building the package
  4937. can declare relationships to those binary packages.
  4938. </p>
  4939. <p>
  4940. This is done using the <tt>Build-Depends</tt>,
  4941. <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
  4942. <tt>Build-Conflicts-Indep</tt> control fields.
  4943. </p>
  4944. <p>
  4945. Build-dependencies on "build-essential" binary packages can be
  4946. omitted. Please see <ref id="pkg-relations"> for more information.
  4947. </p>
  4948. <p>
  4949. The dependencies and conflicts they define must be satisfied
  4950. (as defined earlier for binary packages) in order to invoke
  4951. the targets in <tt>debian/rules</tt>, as follows:<footnote>
  4952. <p>
  4953. There is no Build-Depends-Arch; this role is essentially
  4954. met with Build-Depends. Anyone building the
  4955. <tt>build-indep</tt> and <tt>binary-indep</tt> targets is
  4956. assumed to be building the whole package, and therefore
  4957. installation of all build dependencies is required.
  4958. </p>
  4959. <p>
  4960. The autobuilders use <tt>dpkg-buildpackage -B</tt>, which
  4961. calls <tt>build</tt>, not <tt>build-arch</tt> since it does
  4962. not yet know how to check for its existence, and
  4963. <tt>binary-arch</tt>. The purpose of the original split
  4964. between <tt>Build-Depends</tt> and
  4965. <tt>Build-Depends-Indep</tt> was so that the autobuilders
  4966. wouldn't need to install extra packages needed only for the
  4967. binary-indep targets. But without a build-arch/build-indep
  4968. split, this didn't work, since most of the work is done in
  4969. the build target, not in the binary target.
  4970. </p>
  4971. </footnote>
  4972. <taglist>
  4973. <tag><tt>clean</tt>, <tt>build-arch</tt>, and
  4974. <tt>binary-arch</tt></tag>
  4975. <item>
  4976. Only the <tt>Build-Depends</tt> and <tt>Build-Conflicts</tt>
  4977. fields must be satisfied when these targets are invoked.
  4978. </item>
  4979. <tag><tt>build</tt>, <tt>build-indep</tt>, <tt>binary</tt>,
  4980. and <tt>binary-indep</tt></tag>
  4981. <item>
  4982. The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
  4983. <tt>Build-Depends-Indep</tt>, and
  4984. <tt>Build-Conflicts-Indep</tt> fields must be satisfied when
  4985. these targets are invoked.
  4986. </item>
  4987. </taglist>
  4988. </p>
  4989. </sect>
  4990. <sect id="built-using">
  4991. <heading>Additional source packages used to build the binary
  4992. - <tt>Built-Using</tt>
  4993. </heading>
  4994. <p>
  4995. Some binary packages incorporate parts of other packages when built
  4996. but do not have to depend on those packages. Examples include
  4997. linking with static libraries or incorporating source code from
  4998. another package during the build. In this case, the source packages
  4999. of those other packages are a required part of the complete source
  5000. (the binary package is not reproducible without them).
  5001. </p>
  5002. <p>
  5003. A <tt>Built-Using</tt> field must list the corresponding source
  5004. package for any such binary package incorporated during the build
  5005. <footnote>
  5006. <tt>Build-Depends</tt> in the source package is not adequate since
  5007. it (rightfully) does not document the exact version used in the
  5008. build.
  5009. </footnote>,
  5010. including an "exactly equal" ("=") version relation on the version
  5011. that was used to build that binary package<footnote>
  5012. The archive software might reject packages that refer to
  5013. non-existent sources.
  5014. </footnote>.
  5015. </p>
  5016. <p>
  5017. A package using the source code from the gcc-4.6-source
  5018. binary package built from the gcc-4.6 source package would
  5019. have this field in its control file:
  5020. <example compact="compact">
  5021. Built-Using: gcc-4.6 (= 4.6.0-11)
  5022. </example>
  5023. </p>
  5024. <p>
  5025. A package including binaries from grub2 and loadlin would
  5026. have this field in its control file:
  5027. <example compact="compact">
  5028. Built-Using: grub2 (= 1.99-9), loadlin (= 1.6e-1)
  5029. </example>
  5030. </p>
  5031. </sect>
  5032. </chapt>
  5033. <chapt id="sharedlibs"><heading>Shared libraries</heading>
  5034. <p>
  5035. Packages containing shared libraries must be constructed with
  5036. a little care to make sure that the shared library is always
  5037. available. This is especially important for packages whose
  5038. shared libraries are vitally important, such as the C library
  5039. (currently <tt>libc6</tt>).
  5040. </p>
  5041. <p>
  5042. This section deals only with public shared libraries: shared
  5043. libraries that are placed in directories searched by the dynamic
  5044. linker by default or which are intended to be linked against
  5045. normally and possibly used by other, independent packages. Shared
  5046. libraries that are internal to a particular package or that are
  5047. only loaded as dynamic modules are not covered by this section and
  5048. are not subject to its requirements.
  5049. </p>
  5050. <p>
  5051. A shared library is identified by the <tt>SONAME</tt> attribute
  5052. stored in its dynamic section. When a binary is linked against a
  5053. shared library, the <tt>SONAME</tt> of the shared library is
  5054. recorded in the binary's <tt>NEEDED</tt> section so that the
  5055. dynamic linker knows that library must be loaded at runtime. The
  5056. shared library file's full name (which usually contains additional
  5057. version information not needed in the <tt>SONAME</tt>) is
  5058. therefore normally not referenced directly. Instead, the shared
  5059. library is loaded by its <tt>SONAME</tt>, which exists on the file
  5060. system as a symlink pointing to the full name of the shared
  5061. library. This symlink must be provided by the
  5062. package. <ref id="sharedlibs-runtime"> describes how to do this.
  5063. <footnote>
  5064. This is a convention of shared library versioning, but not a
  5065. requirement. Some libraries use the <tt>SONAME</tt> as the full
  5066. library file name instead and therefore do not need a symlink.
  5067. Most, however, encode additional information about
  5068. backwards-compatible revisions as a minor version number in the
  5069. file name. The <tt>SONAME</tt> itself only changes when
  5070. binaries linked with the earlier version of the shared library
  5071. may no longer work, but the filename may change with each
  5072. release of the library. See <ref id="sharedlibs-runtime"> for
  5073. more information.
  5074. </footnote>
  5075. </p>
  5076. <p>
  5077. When linking a binary or another shared library against a shared
  5078. library, the <tt>SONAME</tt> for that shared library is not yet
  5079. known. Instead, the shared library is found by looking for a file
  5080. matching the library name with <tt>.so</tt> appended. This file
  5081. exists on the file system as a symlink pointing to the shared
  5082. library.
  5083. </p>
  5084. <p>
  5085. Shared libraries are normally split into several binary packages.
  5086. The <tt>SONAME</tt> symlink is installed by the runtime shared
  5087. library package, and the bare <tt>.so</tt> symlink is installed in
  5088. the development package since it's only used when linking binaries
  5089. or shared libraries. However, there are some exceptions for
  5090. unusual shared libraries or for shared libraries that are also
  5091. loaded as dynamic modules by other programs.
  5092. </p>
  5093. <p>
  5094. This section is primarily concerned with how the separation of
  5095. shared libraries into multiple packages should be done and how
  5096. dependencies on and between shared library binary packages are
  5097. managed in Debian. <ref id="libraries"> should be read in
  5098. conjunction with this section and contains additional rules for
  5099. the files contained in the shared library packages.
  5100. </p>
  5101. <sect id="sharedlibs-runtime">
  5102. <heading>Run-time shared libraries</heading>
  5103. <p>
  5104. The run-time shared library must be placed in a package
  5105. whose name changes whenever the <tt>SONAME</tt> of the shared
  5106. library changes. This allows several versions of the shared
  5107. library to be installed at the same time, allowing installation
  5108. of the new version of the shared library without immediately
  5109. breaking binaries that depend on the old version. Normally, the
  5110. run-time shared library and its <tt>SONAME</tt> symlink should
  5111. be placed in a package named
  5112. <package><var>libraryname</var><var>soversion</var></package>,
  5113. where <var>soversion</var> is the version number in
  5114. the <tt>SONAME</tt> of the shared library. Alternatively, if it
  5115. would be confusing to directly append <var>soversion</var>
  5116. to <var>libraryname</var> (if, for
  5117. example, <var>libraryname</var> itself ends in a number), you
  5118. should use
  5119. <package><var>libraryname</var>-<var>soversion</var></package>
  5120. instead.
  5121. </p>
  5122. <p>
  5123. To determine the <var>soversion</var>, look at
  5124. the <tt>SONAME</tt> of the library, stored in the
  5125. ELF <tt>SONAME</tt> attribute. It is usually of the
  5126. form <tt><var>name</var>.so.<var>major-version</var></tt> (for
  5127. example, <tt>libz.so.1</tt>). The version part is the part
  5128. which comes after <tt>.so.</tt>, so in that example it
  5129. is <tt>1</tt>. The soname may instead be of the
  5130. form <tt><var>name</var>-<var>major-version</var>.so</tt>, such
  5131. as <tt>libdb-5.1.so</tt>, in which case the name would
  5132. be <tt>libdb</tt> and the version would be <tt>5.1</tt>.
  5133. </p>
  5134. <p>
  5135. If you have several shared libraries built from the same source
  5136. tree, you may lump them all together into a single shared
  5137. library package provided that all of their <tt>SONAME</tt>s will
  5138. always change together. Be aware that this is not normally the
  5139. case, and if the <tt>SONAME</tt>s do not change together,
  5140. upgrading such a merged shared library package will be
  5141. unnecessarily difficult because of file conflicts with the old
  5142. version of the package. When in doubt, always split shared
  5143. library packages so that each binary package installs a single
  5144. shared library.
  5145. </p>
  5146. <p>
  5147. Every time the shared library ABI changes in a way that may
  5148. break binaries linked against older versions of the shared
  5149. library, the <tt>SONAME</tt> of the library and the
  5150. corresponding name for the binary package containing the runtime
  5151. shared library should change. Normally, this means
  5152. the <tt>SONAME</tt> should change any time an interface is
  5153. removed from the shared library or the signature of an interface
  5154. (the number of parameters or the types of parameters that it
  5155. takes, for example) is changed. This practice is vital to
  5156. allowing clean upgrades from older versions of the package and
  5157. clean transitions between the old ABI and new ABI without having
  5158. to upgrade every affected package simultaneously.
  5159. </p>
  5160. <p>
  5161. The <tt>SONAME</tt> and binary package name need not, and indeed
  5162. normally should not, change if new interfaces are added but none
  5163. are removed or changed, since this will not break binaries
  5164. linked against the old shared library. Correct versioning of
  5165. dependencies on the newer shared library by binaries that use
  5166. the new interfaces is handled via
  5167. the <qref id="sharedlibs-depends"><tt>symbols</tt>
  5168. or <tt>shlibs</tt> system</qref>.
  5169. </p>
  5170. <p>
  5171. The package should install the shared libraries under
  5172. their normal names. For example, the <package>libgdbm3</package>
  5173. package should install <file>libgdbm.so.3.0.0</file> as
  5174. <file>/usr/lib/libgdbm.so.3.0.0</file>. The files should not be
  5175. renamed or re-linked by any <prgn>prerm</prgn> or
  5176. <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
  5177. of renaming things safely without affecting running programs,
  5178. and attempts to interfere with this are likely to lead to
  5179. problems.
  5180. </p>
  5181. <p>
  5182. Shared libraries should not be installed executable, since
  5183. the dynamic linker does not require this and trying to
  5184. execute a shared library usually results in a core dump.
  5185. </p>
  5186. <p>
  5187. The run-time library package should include the symbolic link for
  5188. the <tt>SONAME</tt> that <prgn>ldconfig</prgn> would create for
  5189. the shared libraries. For example,
  5190. the <package>libgdbm3</package> package should include a symbolic
  5191. link from <file>/usr/lib/libgdbm.so.3</file> to
  5192. <file>libgdbm.so.3.0.0</file>. This is needed so that the dynamic
  5193. linker (for example <prgn>ld.so</prgn> or
  5194. <prgn>ld-linux.so.*</prgn>) can find the library between the
  5195. time that <prgn>dpkg</prgn> installs it and the time that
  5196. <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
  5197. script.<footnote>
  5198. The package management system requires the library to be
  5199. placed before the symbolic link pointing to it in the
  5200. <file>.deb</file> file. This is so that when
  5201. <prgn>dpkg</prgn> comes to install the symlink
  5202. (overwriting the previous symlink pointing at an older
  5203. version of the library), the new shared library is already
  5204. in place. In the past, this was achieved by creating the
  5205. library in the temporary packaging directory before
  5206. creating the symlink. Unfortunately, this was not always
  5207. effective, since the building of the tar file in the
  5208. <file>.deb</file> depended on the behavior of the underlying
  5209. file system. Some file systems (such as reiserfs) reorder
  5210. the files so that the order of creation is forgotten.
  5211. Since version 1.7.0, <prgn>dpkg</prgn>
  5212. reorders the files itself as necessary when building a
  5213. package. Thus it is no longer important to concern
  5214. oneself with the order of file creation.
  5215. </footnote>
  5216. </p>
  5217. <sect1 id="ldconfig">
  5218. <heading><tt>ldconfig</tt></heading>
  5219. <p>
  5220. Any package installing shared libraries in one of the default
  5221. library directories of the dynamic linker (which are currently
  5222. <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
  5223. listed in <file>/etc/ld.so.conf</file><footnote>
  5224. These are currently <file>/usr/local/lib</file> plus
  5225. directories under <file>/lib</file> and <file>/usr/lib</file>
  5226. matching the multiarch triplet for the system architecture.
  5227. </footnote>
  5228. must use <prgn>ldconfig</prgn> to update the shared library
  5229. system.
  5230. </p>
  5231. <p>
  5232. The package maintainer scripts must only call
  5233. <prgn>ldconfig</prgn> under these circumstances:
  5234. <list compact="compact">
  5235. <item>When the <prgn>postinst</prgn> script is run with a
  5236. first argument of <tt>configure</tt>, the script must call
  5237. <prgn>ldconfig</prgn>, and may optionally invoke
  5238. <prgn>ldconfig</prgn> at other times.
  5239. </item>
  5240. <item>When the <prgn>postrm</prgn> script is run with a
  5241. first argument of <tt>remove</tt>, the script should call
  5242. <prgn>ldconfig</prgn>.
  5243. </item>
  5244. </list>
  5245. <footnote>
  5246. <p>
  5247. During install or upgrade, the preinst is called before
  5248. the new files are unpacked, so calling "ldconfig" is
  5249. pointless. The preinst of an existing package can also be
  5250. called if an upgrade fails. However, this happens during
  5251. the critical time when a shared libs may exist on-disk
  5252. under a temporary name. Thus, it is dangerous and
  5253. forbidden by current policy to call "ldconfig" at this
  5254. time.
  5255. </p>
  5256. <p>
  5257. When a package is installed or upgraded, "postinst
  5258. configure" runs after the new files are safely on-disk.
  5259. Since it is perfectly safe to invoke ldconfig
  5260. unconditionally in a postinst, it is OK for a package to
  5261. simply put ldconfig in its postinst without checking the
  5262. argument. The postinst can also be called to recover from
  5263. a failed upgrade. This happens before any new files are
  5264. unpacked, so there is no reason to call "ldconfig" at this
  5265. point.
  5266. </p>
  5267. <p>
  5268. For a package that is being removed, prerm is
  5269. called with all the files intact, so calling ldconfig is
  5270. useless. The other calls to "prerm" happen in the case of
  5271. upgrade at a time when all the files of the old package
  5272. are on-disk, so again calling "ldconfig" is pointless.
  5273. </p>
  5274. <p>
  5275. postrm, on the other hand, is called with the "remove"
  5276. argument just after the files are removed, so this is
  5277. the proper time to call "ldconfig" to notify the system
  5278. of the fact that the shared libraries from the package
  5279. are removed. The postrm can be called at several other
  5280. times. At the time of "postrm purge", "postrm
  5281. abort-install", or "postrm abort-upgrade", calling
  5282. "ldconfig" is useless because the shared lib files are
  5283. not on-disk. However, when "postrm" is invoked with
  5284. arguments "upgrade", "failed-upgrade", or "disappear", a
  5285. shared lib may exist on-disk under a temporary filename.
  5286. </p>
  5287. </footnote>
  5288. </p>
  5289. </sect1>
  5290. </sect>
  5291. <sect id="sharedlibs-support-files">
  5292. <heading>Shared library support files</heading>
  5293. <p>
  5294. If your package contains files whose names do not change with
  5295. each change in the library shared object version, you must not
  5296. put them in the shared library package. Otherwise, several
  5297. versions of the shared library cannot be installed at the same
  5298. time without filename clashes, making upgrades and transitions
  5299. unnecessarily difficult.
  5300. </p>
  5301. <p>
  5302. It is recommended that supporting files and run-time support
  5303. programs that do not need to be invoked manually by users, but
  5304. are nevertheless required for the package to function, be placed
  5305. (if they are binary) in a subdirectory of <file>/usr/lib</file>,
  5306. preferably under <file>/usr/lib/</file><var>package-name</var>.
  5307. If the program or file is architecture independent, the
  5308. recommendation is for it to be placed in a subdirectory of
  5309. <file>/usr/share</file> instead, preferably under
  5310. <file>/usr/share/</file><var>package-name</var>. Following the
  5311. <var>package-name</var> naming convention ensures that the file
  5312. names change when the shared object version changes.
  5313. </p>
  5314. <p>
  5315. Run-time support programs that use the shared library but are
  5316. not required for the library to function or files used by the
  5317. shared library that can be used by any version of the shared
  5318. library package should instead be put in a separate package.
  5319. This package might typically be named
  5320. <package><var>libraryname</var>-tools</package>; note the
  5321. absence of the <var>soversion</var> in the package name.
  5322. </p>
  5323. <p>
  5324. Files and support programs only useful when compiling software
  5325. against the library should be included in the development
  5326. package for the library.<footnote>
  5327. For example, a <file><var>package-name</var>-config</file>
  5328. script or <package>pkg-config</package> configuration files.
  5329. </footnote>
  5330. </p>
  5331. </sect>
  5332. <sect id="sharedlibs-static">
  5333. <heading>Static libraries</heading>
  5334. <p>
  5335. The static library (<file><var>libraryname.a</var></file>)
  5336. is usually provided in addition to the shared version.
  5337. It is placed into the development package (see below).
  5338. </p>
  5339. <p>
  5340. In some cases, it is acceptable for a library to be
  5341. available in static form only; these cases include:
  5342. <list>
  5343. <item>libraries for languages whose shared library support
  5344. is immature or unstable</item>
  5345. <item>libraries whose interfaces are in flux or under
  5346. development (commonly the case when the library's
  5347. major version number is zero, or where the ABI breaks
  5348. across patchlevels)</item>
  5349. <item>libraries which are explicitly intended to be
  5350. available only in static form by their upstream
  5351. author(s)</item>
  5352. </list>
  5353. </p>
  5354. <sect id="sharedlibs-dev">
  5355. <heading>Development files</heading>
  5356. <p>
  5357. If there are development files associated with a shared library,
  5358. the source package needs to generate a binary development package
  5359. named <package><var>libraryname</var><var>soversion</var>-dev</package>,
  5360. or if you prefer only to support one development version at a
  5361. time, <package><var>libraryname</var>-dev</package>. Installing
  5362. the development package must result in installation of all the
  5363. development files necessary for compiling programs against that
  5364. shared library.<footnote>
  5365. This wording allows the development files to be split into
  5366. several packages, such as a separate architecture-independent
  5367. <package><var>libraryname</var>-headers</package>, provided that
  5368. the development package depends on all the required additional
  5369. packages.
  5370. </footnote>
  5371. </p>
  5372. <p>
  5373. In case several development versions of a library exist, you may
  5374. need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
  5375. <ref id="conflicts">) to ensure that the user only installs one
  5376. development version at a time (as different development versions are
  5377. likely to have the same header files in them, which would cause a
  5378. filename clash if both were unpacked).
  5379. </p>
  5380. <p>
  5381. The development package should contain a symlink for the associated
  5382. shared library without a version number. For example, the
  5383. <package>libgdbm-dev</package> package should include a symlink
  5384. from <file>/usr/lib/libgdbm.so</file> to
  5385. <file>libgdbm.so.3.0.0</file>. This symlink is needed by the linker
  5386. (<prgn>ld</prgn>) when compiling packages, as it will only look for
  5387. <file>libgdbm.so</file> when compiling dynamically.
  5388. </p>
  5389. <p>
  5390. If the package provides Ada Library Information
  5391. (<file>*.ali</file>) files for use with GNAT, these files must be
  5392. installed read-only (mode 0444) so that GNAT will not attempt to
  5393. recompile them. This overrides the normal file mode requirements
  5394. given in <ref id="permissions-owners">.
  5395. </p>
  5396. </sect>
  5397. <sect id="sharedlibs-intradeps">
  5398. <heading>Dependencies between the packages of the same library</heading>
  5399. <p>
  5400. Typically the development version should have an exact
  5401. version dependency on the runtime library, to make sure that
  5402. compilation and linking happens correctly. The
  5403. <tt>${binary:Version}</tt> substitution variable can be
  5404. useful for this purpose.
  5405. <footnote>
  5406. Previously, <tt>${Source-Version}</tt> was used, but its name
  5407. was confusing and it has been deprecated since dpkg 1.13.19.
  5408. </footnote>
  5409. </p>
  5410. </sect>
  5411. <sect id="sharedlibs-depends">
  5412. <heading>Dependencies between the library and other
  5413. packages</heading>
  5414. <p>
  5415. If a package contains a binary or library which links to a
  5416. shared library, we must ensure that, when the package is
  5417. installed on the system, all of the libraries needed are also
  5418. installed. These dependencies must be added to the binary
  5419. package when it is built, since they may change based on which
  5420. version of a shared library the binary or library was linked
  5421. with even if there are no changes to the source of the binary
  5422. (for example, symbol versions change, macros become functions or
  5423. vice versa, or the binary package may determine at compile-time
  5424. whether new library interfaces are available and can be called).
  5425. To allow these dependencies to be constructed, shared libraries
  5426. must provide either a <file>symbols</file> file or
  5427. a <file>shlibs</file> file. These provide information on the
  5428. package dependencies required to ensure the presence of
  5429. interfaces provided by this library. Any package with binaries
  5430. or libraries linking to a shared library must use these files to
  5431. determine the required dependencies when it is built. Other
  5432. packages which use a shared library (for example using
  5433. <tt>dlopen()</tt>) should compute appropriate dependencies
  5434. using these files at build time as well.
  5435. </p>
  5436. <p>
  5437. The two mechanisms differ in the degree of detail that they
  5438. provide. A <file>symbols</file> file documents, for each symbol
  5439. exported by a library, the minimal version of the package any
  5440. binary using this symbol will need. This is typically the
  5441. version of the package in which the symbol was introduced. This
  5442. information permits detailed analysis of the symbols used by a
  5443. particular package and construction of an accurate dependency,
  5444. but it requires the package maintainer to track more information
  5445. about the shared library.
  5446. </p>
  5447. <p>
  5448. A <file>shlibs</file> file, in contrast, only documents the last
  5449. time the library ABI changed in any way. It only provides
  5450. information about the library as a whole, not individual
  5451. symbols. When a package is built using a shared library with
  5452. only a <file>shlibs</file> file, the generated dependency will
  5453. require a version of the shared library equal to or newer than
  5454. the version of the last ABI change. This generates
  5455. unnecessarily restrictive dependencies compared
  5456. to <file>symbols</file> files if none of the symbols used by the
  5457. package have changed. This, in turn, may make upgrades
  5458. needlessly complex and unnecessarily restrict use of the package
  5459. on systems with older versions of the shared libraries.
  5460. </p>
  5461. <p>
  5462. <file>shlibs</file> files also only support a limited range of
  5463. library SONAMEs, making it difficult to use <file>shlibs</file>
  5464. files in some unusual corner cases.<footnote>
  5465. A <file>shlibs</file> file represents an SONAME as a library
  5466. name and version number, such as <tt>libfoo VERSION</tt>,
  5467. instead of recording the actual SONAME. If the SONAME doesn't
  5468. match one of the two expected formats
  5469. (<tt>libfoo-VERSION.so</tt> or <tt>libfoo.so.VERSION</tt>), it
  5470. cannot be represented.
  5471. </footnote>
  5472. </p>
  5473. <p>
  5474. <file>symbols</file> files are therefore recommended for most
  5475. shared library packages since they provide more accurate
  5476. dependencies. For most C libraries, the additional detail
  5477. required by <file>symbols</file> files is not too difficult to
  5478. maintain. However, maintaining exhaustive symbols information
  5479. for a C++ library can be quite onerous, so <file>shlibs</file>
  5480. files may be more appropriate for most C++ libraries. Libraries
  5481. with a corresponding udeb must also provide
  5482. a <file>shlibs</file> file, since the udeb infrastructure does
  5483. not use <file>symbols</file> files.
  5484. </p>
  5485. <sect1 id="dpkg-shlibdeps">
  5486. <heading>Generating dependencies on shared libraries</heading>
  5487. <p>
  5488. When a package that contains any shared libraries or compiled
  5489. binaries is built, it must run <prgn>dpkg-shlibdeps</prgn> on
  5490. each shared library and compiled binary to determine the
  5491. libraries used and hence the dependencies needed by the
  5492. package.<footnote>
  5493. <prgn>dpkg-shlibdeps</prgn> will use a program
  5494. like <prgn>objdump</prgn> or <prgn>readelf</prgn> to find
  5495. the libraries and the symbols in those libraries directly
  5496. needed by the binaries or shared libraries in the package.
  5497. </footnote>
  5498. To do this, put a call to <prgn>dpkg-shlibdeps</prgn> into
  5499. your <file>debian/rules</file> file in the source package.
  5500. List all of the compiled binaries, libraries, or loadable
  5501. modules in your package.<footnote>
  5502. The easiest way to call <prgn>dpkg-shlibdeps</prgn>
  5503. correctly is to use a package helper framework such
  5504. as <package>debhelper</package>. If you are
  5505. using <package>debhelper</package>,
  5506. the <prgn>dh_shlibdeps</prgn> program will do this work for
  5507. you. It will also correctly handle multi-binary packages.
  5508. </footnote>
  5509. <prgn>dpkg-shlibdeps</prgn> will use the <file>symbols</file>
  5510. or <file>shlibs</file> files installed by the shared libraries
  5511. to generate dependency information. The package must then
  5512. provide a substitution variable into which the discovered
  5513. dependency information can be placed.
  5514. </p>
  5515. <p>
  5516. If you are creating a udeb for use in the Debian Installer,
  5517. you will need to specify that <prgn>dpkg-shlibdeps</prgn>
  5518. should use the dependency line of type <tt>udeb</tt> by adding
  5519. the <tt>-tudeb</tt> option<footnote>
  5520. <prgn>dh_shlibdeps</prgn> from the <tt>debhelper</tt> suite
  5521. will automatically add this option if it knows it is
  5522. processing a udeb.
  5523. </footnote>. If there is no dependency line of
  5524. type <tt>udeb</tt> in the <file>shlibs</file>
  5525. file, <prgn>dpkg-shlibdeps</prgn> will fall back to the
  5526. regular dependency line.
  5527. </p>
  5528. <p>
  5529. <prgn>dpkg-shlibdeps</prgn> puts the dependency information
  5530. into the <file>debian/substvars</file> file by default, which
  5531. is then used by <prgn>dpkg-gencontrol</prgn>. You will need
  5532. to place a <tt>${shlibs:Depends}</tt> variable in
  5533. the <tt>Depends</tt> field in the control file of every binary
  5534. package built by this source package that contains compiled
  5535. binaries, libraries, or loadable modules. If you have
  5536. multiple binary packages, you will need to
  5537. call <prgn>dpkg-shlibdeps</prgn> on each one which contains
  5538. compiled libraries or binaries. For example, you could use
  5539. the <tt>-T</tt> option to the <tt>dpkg</tt> utilities to
  5540. specify a different <file>substvars</file> file for each
  5541. binary package.<footnote>
  5542. Again, <prgn>dh_shlibdeps</prgn>
  5543. and <prgn>dh_gencontrol</prgn> will handle everything except
  5544. the addition of the variable to the control file for you if
  5545. you're using <package>debhelper</package>, including
  5546. generating separate <file>substvars</file> files for each
  5547. binary package and calling <prgn>dpkg-gencontrol</prgn> with
  5548. the appropriate flags.
  5549. </footnote>
  5550. </p>
  5551. <p>
  5552. For more details on <prgn>dpkg-shlibdeps</prgn>,
  5553. see <manref name="dpkg-shlibdeps" section="1">.
  5554. </p>
  5555. <p>
  5556. We say that a binary <tt>foo</tt> <em>directly</em> uses a
  5557. library <tt>libbar</tt> if it is explicitly linked with that
  5558. library (that is, the library is listed in the
  5559. ELF <tt>NEEDED</tt> attribute, caused by adding <tt>-lbar</tt>
  5560. to the link line when the binary is created). Other libraries
  5561. that are needed by <tt>libbar</tt> are
  5562. linked <em>indirectly</em> to <tt>foo</tt>, and the dynamic
  5563. linker will load them automatically when it
  5564. loads <tt>libbar</tt>. A package should depend on the
  5565. libraries it directly uses, but not the libraries it only uses
  5566. indirectly. The dependencies for the libraries used
  5567. directly will automatically pull in the indirectly-used
  5568. libraries. <prgn>dpkg-shlibdeps</prgn> will handle this logic
  5569. automatically, but package maintainers need to be aware of
  5570. this distinction between directly and indirectly using a
  5571. library if they have to override its results for some reason.
  5572. <footnote>
  5573. A good example of where this helps is the following. We
  5574. could update <tt>libimlib</tt> with a new version that
  5575. supports a new revision of a graphics format called dgf (but
  5576. retaining the same major version number) and depends on a
  5577. new library package <package>libdgf4</package> instead of
  5578. the older <package>libdgf3</package>. If we
  5579. used <prgn>ldd</prgn> to add dependencies for every library
  5580. directly or indirectly linked with a binary, every package
  5581. that uses <tt>libimlib</tt> would need to be recompiled so
  5582. it would also depend on <package>libdgf4</package> in order
  5583. to retire the older <package>libdgf3</package> package.
  5584. Since dependencies are only added based on
  5585. ELF <tt>NEEDED</tt> attribute, packages
  5586. using <tt>libimlib</tt> can rely on <tt>libimlib</tt> itself
  5587. having the dependency on an appropriate version
  5588. of <tt>libdgf</tt> and do not need rebuilding.
  5589. </footnote>
  5590. </p>
  5591. </sect1>
  5592. <sect1 id="sharedlibs-updates">
  5593. <heading>Shared library ABI changes</heading>
  5594. <p>
  5595. Maintaining a shared library package using
  5596. either <file>symbols</file> or <file>shlibs</file> files
  5597. requires being aware of the exposed ABI of the shared library
  5598. and any changes to it. Both <file>symbols</file>
  5599. and <file>shlibs</file> files record every change to the ABI
  5600. of the shared library; <file>symbols</file> files do so per
  5601. public symbol, whereas <file>shlibs</file> files record only
  5602. the last change for the entire library.
  5603. </p>
  5604. <p>
  5605. There are two types of ABI changes: ones that are
  5606. backward-compatible and ones that are not. An ABI change is
  5607. backward-compatible if any reasonable program or library that
  5608. was linked with the previous version of the shared library
  5609. will still work correctly with the new version of the shared
  5610. library.<footnote>
  5611. An example of an "unreasonable" program is one that uses
  5612. library interfaces that are documented as internal and
  5613. unsupported. If the only programs or libraries affected by
  5614. a change are "unreasonable" ones, other techniques, such as
  5615. declaring <tt>Breaks</tt> relationships with affected
  5616. packages or treating their usage of the library as bugs in
  5617. those packages, may be appropriate instead of changing the
  5618. SONAME. However, the default approach is to change the
  5619. SONAME for any change to the ABI that could break a program.
  5620. </footnote>
  5621. Adding new symbols to the shared library is a
  5622. backward-compatible change. Removing symbols from the shared
  5623. library is not. Changing the behavior of a symbol may or may
  5624. not be backward-compatible depending on the change; for
  5625. example, changing a function to accept a new enum constant not
  5626. previously used by the library is generally
  5627. backward-compatible, but changing the members of a struct that
  5628. is passed into library functions is generally not unless the
  5629. library takes special precautions to accept old versions of
  5630. the data structure.
  5631. </p>
  5632. <p>
  5633. ABI changes that are not backward-compatible normally require
  5634. changing the <tt>SONAME</tt> of the library and therefore the
  5635. shared library package name, which forces rebuilding all
  5636. packages using that shared library to update their
  5637. dependencies and allow them to use the new version of the
  5638. shared library. For more information,
  5639. see <ref id="sharedlibs-runtime">. The remainder of this
  5640. section will deal with backward-compatible changes.
  5641. </p>
  5642. <p>
  5643. Backward-compatible changes require either updating or
  5644. recording the <var>minimal-version</var> for that symbol
  5645. in <file>symbols</file> files or updating the version in
  5646. the <var>dependencies</var> in <file>shlibs</file> files. For
  5647. more information on how to do this in the two formats, see
  5648. <ref id="symbols"> and <ref id="shlibs">. Below are general
  5649. rules that apply to both files.
  5650. </p>
  5651. <p>
  5652. The easy case is when a public symbol is added. Simply add
  5653. the version at which the symbol was introduced
  5654. (for <file>symbols</file> files) or update the dependency
  5655. version (for <file>shlibs</file>) files. But special care
  5656. should be taken to update dependency versions when the
  5657. behavior of a public symbol changes. This is easy to neglect,
  5658. since there is no automated method of determining such
  5659. changes, but failing to update versions in this case may
  5660. result in binary packages with too-weak dependencies that will
  5661. fail at runtime, possibly in ways that can cause security
  5662. vulnerabilities. If the package maintainer believes that a
  5663. symbol behavior change may have occurred but isn't sure, it's
  5664. safer to update the version rather than leave it unmodified.
  5665. This may result in unnecessarily strict dependencies, but it
  5666. ensures that packages whose dependencies are satisfied will
  5667. work properly.
  5668. </p>
  5669. <p>
  5670. A common example of when a change to the dependency version
  5671. is required is a function that takes an enum or struct
  5672. argument that controls what the function does. For example:
  5673. <example>
  5674. enum library_op { OP_FOO, OP_BAR };
  5675. int library_do_operation(enum library_op);
  5676. </example>
  5677. If a new operation, <tt>OP_BAZ</tt>, is added,
  5678. the <var>minimal-version</var>
  5679. of <tt>library_do_operation</tt> (for <file>symbols</file>
  5680. files) or the version in the dependency for the shared library
  5681. (for <file>shlibs</file> files) must be increased to the
  5682. version at which <tt>OP_BAZ</tt> was introduced. Otherwise, a
  5683. binary built against the new version of the library (having
  5684. detected at compile-time that the library
  5685. supports <tt>OP_BAZ</tt>) may be installed with a shared
  5686. library that doesn't support <tt>OP_BAZ</tt> and will fail at
  5687. runtime when it tries to pass <tt>OP_BAZ</tt> into this
  5688. function.
  5689. </p>
  5690. <p>
  5691. Dependency versions in either <file>symbols</file>
  5692. or <file>shlibs</file> files normally should not contain the
  5693. Debian revision of the package, since the library behavior is
  5694. normally fixed for a particular upstream version and any
  5695. Debian packaging of that upstream version will have the same
  5696. behavior. In the rare case that the library behavior was
  5697. changed in a particular Debian revision, appending <tt>~</tt>
  5698. to the end of the version that includes the Debian revision is
  5699. recommended, since this allows backports of the shared library
  5700. package using the normal backport versioning convention to
  5701. satisfy the dependency.
  5702. </p>
  5703. </sect1>
  5704. <sect1 id="sharedlibs-symbols">
  5705. <heading>The <tt>symbols</tt> system</heading>
  5706. <p>
  5707. In the following sections, we will first describe where the
  5708. various <file>symbols</file> files are to be found, then
  5709. the <file>symbols</file> file format, and finally how to
  5710. create <file>symbols</file> files if your package contains a
  5711. shared library.
  5712. </p>
  5713. <sect2 id="symbols-paths">
  5714. <heading>The <file>symbols</file> files present on the
  5715. system</heading>
  5716. <p>
  5717. <file>symbols</file> files for a shared library are normally
  5718. provided by the shared library package as a control file,
  5719. but there are several override paths that are checked first
  5720. in case that information is wrong or missing. The following
  5721. list gives them in the order in which they are read
  5722. by <prgn>dpkg-shlibdeps</prgn> The first one that contains
  5723. the required information is used.
  5724. <list>
  5725. <item>
  5726. <p><file>debian/*/DEBIAN/symbols</file></p>
  5727. <p>
  5728. During the package build, if the package itself
  5729. contains shared libraries with <file>symbols</file>
  5730. files, they will be generated in these staging
  5731. directories by <prgn>dpkg-gensymbols</prgn>
  5732. (see <ref id="providing-symbols">). <file>symbols</file>
  5733. files found in the build tree take precedence
  5734. over <file>symbols</file> files from other binary
  5735. packages.
  5736. </p>
  5737. <p>
  5738. These files must exist
  5739. before <prgn>dpkg-shlibdeps</prgn> is run or the
  5740. dependencies of binaries and libraries from a source
  5741. package on other libraries from that same source
  5742. package will not be correct. In practice, this means
  5743. that <prgn>dpkg-gensymbols</prgn> must be run
  5744. before <prgn>dpkg-shlibdeps</prgn> during the package
  5745. build.<footnote>
  5746. An example may clarify. Suppose the source
  5747. package <tt>foo</tt> generates two binary
  5748. packages, <tt>libfoo2</tt> and <tt>foo-runtime</tt>.
  5749. When building the binary packages, the contents of
  5750. the packages are staged in the
  5751. directories <file>debian/libfoo2</file>
  5752. and <file>debian/foo-runtime</file> respectively.
  5753. (<file>debian/tmp</file> could be used instead of
  5754. one of these.) Since <tt>libfoo2</tt> provides
  5755. the <tt>libfoo</tt> shared library, it will contain
  5756. a <tt>symbols</tt> file, which will be installed
  5757. in <file>debian/libfoo2/DEBIAN/symbols</file>,
  5758. eventually to be included as a control file in that
  5759. package. When <prgn>dpkg-shlibdeps</prgn> is run on
  5760. the
  5761. executable <file>debian/foo-runtime/usr/bin/foo-prog</file>,
  5762. it will examine
  5763. the <file>debian/libfoo2/DEBIAN/symbols</file> file
  5764. to determine whether <tt>foo-prog</tt>'s library
  5765. dependencies are satisfied by any of the libraries
  5766. provided by <tt>libfoo2</tt>. Since those binaries
  5767. were linked against the just-built shared library as
  5768. part of the build process, the <file>symbols</file>
  5769. file for the newly-built <tt>libfoo2</tt> must take
  5770. precedence over a <file>symbols</file> file for any
  5771. other <tt>libfoo2</tt> package already installed on
  5772. the system.
  5773. </footnote>
  5774. </p>
  5775. </item>
  5776. <item>
  5777. <p>
  5778. <file>/etc/dpkg/symbols/<var>package</var>.symbols.<var>arch</var></file>
  5779. and <file>/etc/dpkg/symbols/<var>package</var>.symbols</file>
  5780. </p>
  5781. <p>
  5782. Per-system overrides of shared library dependencies.
  5783. These files normally do not exist. They are
  5784. maintained by the local system administrator and must
  5785. not be created by any Debian package.
  5786. </p>
  5787. </item>
  5788. <item>
  5789. <p><file>symbols</file> control files for packages
  5790. installed on the system</p>
  5791. <p>
  5792. The <file>symbols</file> control files for all the
  5793. packages currently installed on the system are
  5794. searched last. This will be the most common source of
  5795. shared library dependency information. These are
  5796. normally found
  5797. in <file>/var/lib/dpkg/info/*.symbols</file>, but
  5798. packages should not rely on this and instead should
  5799. use <tt>dpkg-query --control-path <var>package</var>
  5800. symbols</tt> if for some reason these files need to be
  5801. examined.
  5802. </p>
  5803. </item>
  5804. </list>
  5805. </p>
  5806. <p>
  5807. Be aware that if a <file>debian/shlibs.local</file> exists
  5808. in the source package, it will override
  5809. any <file>symbols</file> files. This is the only case where
  5810. a <file>shlibs</file> is used despite <file>symbols</file>
  5811. files being present. See <ref id="shlibs-paths">
  5812. and <ref id="sharedlibs-shlibdeps"> for more information.
  5813. </p>
  5814. </sect2>
  5815. <sect2 id="symbols">
  5816. <heading>The <file>symbols</file> File Format</heading>
  5817. <p>
  5818. The following documents the format of
  5819. the <file>symbols</file> control file as included in binary
  5820. packages. These files are built from
  5821. template <file>symbols</file> files in the source package
  5822. by <prgn>dpkg-gensymbols</prgn>. The template files support
  5823. a richer syntax that allows <prgn>dpkg-gensymbols</prgn> to
  5824. do some of the tedious work involved in
  5825. maintaining <file>symbols</file> files, such as handling C++
  5826. symbols or optional symbols that may not exist on particular
  5827. architectures. When writing <file>symbols</file> files for
  5828. a shared library package, refer
  5829. to <manref name="dpkg-gensymbols" section="1"> for the
  5830. richer syntax.
  5831. </p>
  5832. <p>
  5833. A <file>symbols</file> may contain one or more entries, one
  5834. for each shared library contained in the package
  5835. corresponding to that <file>symbols</file>. Each entry has
  5836. the following format:
  5837. </p>
  5838. <p>
  5839. <example>
  5840. <var>library-soname</var> <var>main-dependency-template</var>
  5841. [| <var>alternative-dependency-template</var>]
  5842. [...]
  5843. [* <var>field-name</var>: <var>field-value</var>]
  5844. [...]
  5845. <var>symbol</var> <var>minimal-version</var>[ <var>id-of-dependency-template</var> ]
  5846. </example>
  5847. </p>
  5848. <p>
  5849. To explain this format, we'll use the the <tt>zlib1g</tt>
  5850. package as an example, which (at the time of writing)
  5851. installs the shared
  5852. library <file>/usr/lib/libz.so.1.2.3.4</file>. Mandatory
  5853. lines will be described first, followed by optional lines.
  5854. </p>
  5855. <p>
  5856. <var>library-soname</var> must contain exactly the value of
  5857. the ELF <tt>SONAME</tt> attribute of the shared library. In
  5858. our example, this is <tt>libz.so.1</tt>.<footnote>
  5859. This can be determined by using the command
  5860. <example compact="compact">
  5861. readelf -d /usr/lib/libz.so.1.2.3.4 | grep SONAME
  5862. </example>
  5863. </footnote>
  5864. </p>
  5865. <p>
  5866. <var>main-dependency-template</var> has the same syntax as a
  5867. dependency field in a binary package control file, except
  5868. that the string <tt>#MINVER#</tt> is replaced by a version
  5869. restriction like <tt>(>= <var>version</var>)</tt> or by
  5870. nothing if an unversioned dependency is deemed sufficient.
  5871. The version restriction will be based on which symbols from
  5872. the shared library are referenced and the version at which
  5873. they were introduced (see below). In nearly all
  5874. cases, <var>main-dependency-template</var> will
  5875. be <tt><var>package</var> #MINVER#</tt>,
  5876. where <var>package</var> is the name of the binary package
  5877. containing the shared library. This adds a simple,
  5878. possibly-versioned dependency on the shared library package.
  5879. In some rare cases, such as when multiple packages provide
  5880. the same shared library ABI, the dependency template may
  5881. need to be more complex.
  5882. </p>
  5883. <p>
  5884. In our example, the first line of
  5885. the <tt>zlib1g</tt> <file>symbols</file> file would be:
  5886. <example compact="compact">
  5887. libz.so.1 zlib1g #MINVER#
  5888. </example>
  5889. </p>
  5890. <p>
  5891. Each public symbol exported by the shared library must have
  5892. a corresponding symbol line, indented by one
  5893. space. <var>symbol</var> is the exported symbol (which, for
  5894. C++, means the mangled symbol) followed by <tt>@</tt> and
  5895. the symbol version, or the string <tt>Base</tt> if there is
  5896. no symbol version. <var>minimal-version</var> is the most
  5897. recent version of the shared library that changed the
  5898. behavior of that symbol, whether by adding it, changing its
  5899. function signature (the parameters, their types, or the
  5900. return type), or changing its behavior in a way that is
  5901. visible to a caller.
  5902. <var>id-of-dependency-template</var> is an optional
  5903. field that references
  5904. an <var>alternative-dependency-template</var>; see below for
  5905. a full description.
  5906. </p>
  5907. <p>
  5908. For example, <tt>libz.so.1</tt> contains the
  5909. symbols <tt>compress</tt>
  5910. and <tt>compressBound</tt>. <tt>compress</tt> has no symbol
  5911. version and last changed its behavior in upstream
  5912. version <tt>1:1.1.4</tt>. <tt>compressBound</tt> has the
  5913. symbol version <tt>ZLIB_1.2.0</tt>, was introduced in
  5914. upstream version <tt>1:1.2.0</tt>, and has not changed its
  5915. behavior. Its <file>symbols</file> file therefore contains
  5916. the lines:
  5917. <example compact="compact">
  5918. compress@Base 1:1.1.4
  5919. compressBound@ZLIB_1.2.0 1:1.2.0
  5920. </example>
  5921. Packages using only <tt>compress</tt> would then get a
  5922. dependency on <tt>zlib1g (>= 1:1.1.4)</tt>, but packages
  5923. using <tt>compressBound</tt> would get a dependency
  5924. on <tt>zlib1g (>= 1:1.2.0)</tt>.
  5925. </p>
  5926. <p>
  5927. One or more <var>alternative-dependency-template</var> lines
  5928. may be provided. These are used in cases where some symbols
  5929. in the shared library should use one dependency template
  5930. while others should use a different template. The
  5931. alternative dependency templates are used only if a symbol
  5932. line contains the <var>id-of-dependency-template</var>
  5933. field. The first alternative dependency template is
  5934. numbered 1, the second 2, and so forth.<footnote>
  5935. An example of where this may be needed is with a library
  5936. that implements the libGL interface. All GL
  5937. implementations provide the same set of base interfaces,
  5938. and then may provide some additional interfaces only used
  5939. by programs that require that specific GL implementation.
  5940. So, for example, libgl1-mesa-glx may use the
  5941. following <file>symbols</file> file:
  5942. <example>
  5943. libGL.so.1 libgl1
  5944. | libgl1-mesa-glx #MINVER#
  5945. publicGlSymbol@Base 6.3-1
  5946. [...]
  5947. implementationSpecificSymbol@Base 6.5.2-7 1
  5948. [...]
  5949. </example>
  5950. Binaries or shared libraries using
  5951. only <tt>publicGlSymbol</tt> would depend only
  5952. on <tt>libgl1</tt> (which may be provided by multiple
  5953. packages), but ones
  5954. using <tt>implementationSpecificSymbol</tt> would get a
  5955. dependency on <tt>libgl1-mesa-glx (>= 6.5.2-7)</tt>
  5956. </footnote>
  5957. </p>
  5958. <p>
  5959. Finally, the entry for the library may contain one or more
  5960. metadata fields. Currently, the only
  5961. supported <var>field-name</var>
  5962. is <tt>Build-Depends-Package</tt>, whose value lists
  5963. the <qref id="sharedlibs-dev">library development
  5964. package</qref> on which packages using this shared library
  5965. declare a build dependency. If this field is
  5966. present, <prgn>dpkg-shlibdeps</prgn> uses it to ensure that
  5967. the resulting binary package dependency on the shared
  5968. library is at least as strict as the source package
  5969. dependency on the shared library development
  5970. package.<footnote>
  5971. This field should normally not be necessary, since if the
  5972. behavior of any symbol has changed, the corresponding
  5973. symbol <var>minimal-version</var> should have been
  5974. increased. But including it makes the <tt>symbols</tt>
  5975. system more robust by tightening the dependency in cases
  5976. where the package using the shared library specifically
  5977. requires at least a particular version of the shared
  5978. library development package for some reason.
  5979. </footnote>
  5980. For our example, the <tt>zlib1g</tt> <file>symbols</file>
  5981. file would contain:
  5982. <example compact="compact">
  5983. * Build-Depends-Package: zlib1g-dev
  5984. </example>
  5985. </p>
  5986. <p>
  5987. Also see <manref name="deb-symbols" section="5">.
  5988. </p>
  5989. </sect2>
  5990. <sect2 id="providing-symbols">
  5991. <heading>Providing a <file>symbols</file> file</heading>
  5992. <p>
  5993. If your package provides a shared library, you should
  5994. arrange to include a <file>symbols</file> control file
  5995. following the format described above in that package. You
  5996. must include either a <file>symbols</file> control file or
  5997. a <file>shlibs</file> control file.
  5998. </p>
  5999. <p>
  6000. Normally, this is done by creating a <file>symbols</file> in
  6001. the source package
  6002. named <file>debian/<var>package</var>.symbols</file>
  6003. or <file>debian/symbols</file>, possibly
  6004. with <file>.<var>arch</var></file> appended if the symbols
  6005. information varies by architecture. This file may use the
  6006. extended syntax documented in <manref name="dpkg-gensymbols"
  6007. section="1">. Then, call <prgn>dpkg-gensymbols</prgn> as
  6008. part of the package build process. It will
  6009. create <file>symbols</file> files in the package staging
  6010. area based on the binaries and libraries in the package
  6011. staging area and the <file>symbols</file> files in the
  6012. source package.<footnote>
  6013. If you are
  6014. using <tt>debhelper</tt>, <prgn>dh_makeshlibs</prgn> will
  6015. take care of calling either <prgn>dpkg-gensymbols</prgn>
  6016. or generating a <file>shlibs</file> file as appropriate.
  6017. </footnote>
  6018. </p>
  6019. <p>
  6020. Packages that provide <file>symbols</file> files must keep
  6021. them up-to-date to ensure correct dependencies in packages
  6022. that use the shared libraries. This means updating
  6023. the <file>symbols</file> file whenever a new public symbol
  6024. is added, changing the <var>minimal-version</var> field
  6025. whenever a symbol changes behavior or signature in a
  6026. backward-compatible way (see <ref id="sharedlibs-updates">),
  6027. and changing the <var>library-soname</var>
  6028. and <var>main-dependency-template</var>, and probably all of
  6029. the <var>minimal-version</var> fields, when the library
  6030. changes <tt>SONAME</tt>. Removing a public symbol from
  6031. the <file>symbols</file> file because it's no longer
  6032. provided by the library normally requires changing
  6033. the <tt>SONAME</tt> of the library.
  6034. See <ref id="sharedlibs-runtime"> for more information
  6035. on <tt>SONAME</tt>s.
  6036. </p>
  6037. </sect2>
  6038. </sect1>
  6039. <sect1 id="sharedlibs-shlibdeps">
  6040. <heading>The <tt>shlibs</tt> system</heading>
  6041. <p>
  6042. The <tt>shlibs</tt> system is a simpler alternative to
  6043. the <tt>symbols</tt> system for declaring dependencies for
  6044. shared libraries. It may be more appropriate for C++
  6045. libraries and other cases where tracking individual symbols is
  6046. too difficult. It predated the <tt>symbols</tt> system and is
  6047. therefore frequently seen in older packages. It is also
  6048. required for udebs, which do not support <tt>symbols</tt>.
  6049. </p>
  6050. <p>
  6051. In the following sections, we will first describe where the
  6052. various <file>shlibs</file> files are to be found, then how to
  6053. use <prgn>dpkg-shlibdeps</prgn>, and finally
  6054. the <file>shlibs</file> file format and how to create them.
  6055. </p>
  6056. <sect2 id="shlibs-paths">
  6057. <heading>The <file>shlibs</file> files present on the
  6058. system</heading>
  6059. <p>
  6060. There are several places where <tt>shlibs</tt> files are
  6061. found. The following list gives them in the order in which
  6062. they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
  6063. one which gives the required information is used.)
  6064. <list>
  6065. <item>
  6066. <p><file>debian/shlibs.local</file></p>
  6067. <p>
  6068. This lists overrides for this package. This file
  6069. should normally not be used, but may be needed
  6070. temporarily in unusual situations to work around bugs
  6071. in other packages, or in unusual cases where the
  6072. normally declared dependency information in the
  6073. installed <file>shlibs</file> file for a library
  6074. cannot be used. This file overrides information
  6075. obtained from any other source.
  6076. </p>
  6077. </item>
  6078. <item>
  6079. <p><file>/etc/dpkg/shlibs.override</file></p>
  6080. <p>
  6081. This lists global overrides. This list is normally
  6082. empty. It is maintained by the local system
  6083. administrator.
  6084. </p>
  6085. </item>
  6086. <item>
  6087. <p><file>DEBIAN/shlibs</file> files in the "build
  6088. directory"</p>
  6089. <p>
  6090. These files are generated as part of the package build
  6091. process and staged for inclusion as control files in
  6092. the binary packages being built. They provide details
  6093. of any shared libraries included in the same package.
  6094. </p>
  6095. </item>
  6096. <item>
  6097. <p><file>shlibs</file> control files for packages
  6098. installed on the system</p>
  6099. <p>
  6100. The <file>shlibs</file> control files for all the
  6101. packages currently installed on the system. These are
  6102. normally found
  6103. in <file>/var/lib/dpkg/info/*.shlibs</file>, but
  6104. packages should not rely on this and instead should
  6105. use <tt>dpkg-query --control-path <var>package</var>
  6106. shlibs</tt> if for some reason these files need to be
  6107. examined.
  6108. </p>
  6109. </item>
  6110. <item>
  6111. <p><file>/etc/dpkg/shlibs.default</file></p>
  6112. <p>
  6113. This file lists any shared libraries whose packages
  6114. have failed to provide correct <file>shlibs</file>
  6115. files. It was used when the <file>shlibs</file> setup
  6116. was first introduced, but it is now normally empty.
  6117. It is maintained by the <tt>dpkg</tt> maintainer.
  6118. </p>
  6119. </item>
  6120. </list>
  6121. </p>
  6122. <p>
  6123. If a <file>symbols</file> file for a shared library package
  6124. is available, <prgn>dpkg-shlibdeps</prgn> will always use it
  6125. in preference to a <file>shlibs</file>, with the exception
  6126. of <file>debian/shlibs.local</file>. The latter overrides
  6127. any other <file>shlibs</file> or <file>symbols</file> files.
  6128. </p>
  6129. </sect2>
  6130. <sect2 id="shlibs">
  6131. <heading>The <file>shlibs</file> File Format</heading>
  6132. <p>
  6133. Each <file>shlibs</file> file has the same format. Lines
  6134. beginning with <tt>#</tt> are considered to be comments and
  6135. are ignored. Each line is of the form:
  6136. <example compact="compact">
  6137. [<var>type</var>: ]<var>library-name</var> <var>soname-version</var> <var>dependencies ...</var>
  6138. </example>
  6139. </p>
  6140. <p>
  6141. We will explain this by reference to the example of the
  6142. <tt>zlib1g</tt> package, which (at the time of writing)
  6143. installs the shared
  6144. library <file>/usr/lib/libz.so.1.2.3.4</file>.
  6145. </p>
  6146. <p>
  6147. <var>type</var> is an optional element that indicates the
  6148. type of package for which the line is valid. The only type
  6149. currently in use is <tt>udeb</tt>. The colon and space
  6150. after the type are required.
  6151. </p>
  6152. <p>
  6153. <var>library-name</var> is the name of the shared library,
  6154. in this case <tt>libz</tt>. (This must match the name part
  6155. of the soname, see below.)
  6156. </p>
  6157. <p>
  6158. <var>soname-version</var> is the version part of the
  6159. ELF <tt>SONAME</tt> attribute of the library, determined the
  6160. same way that the <var>soversion</var> component of the
  6161. recommended shared library package name is determined.
  6162. See <ref id="sharedlibs-runtime"> for the details.
  6163. </p>
  6164. <p>
  6165. <var>dependencies</var> has the same syntax as a dependency
  6166. field in a binary package control file. It should give
  6167. details of which packages are required to satisfy a binary
  6168. built against the version of the library contained in the
  6169. package. See <ref id="depsyntax"> for details on the
  6170. syntax, and <ref id="sharedlibs-updates"> for details on how
  6171. to maintain the dependency version constraint.
  6172. </p>
  6173. <p>
  6174. In our example, if the last change to the <tt>zlib1g</tt>
  6175. package that could change behavior for a client of that
  6176. library was in version <tt>1:1.2.3.3.dfsg-1</tt>, then
  6177. the <tt>shlibs</tt> entry for this library could say:
  6178. <example compact="compact">
  6179. libz 1 zlib1g (>= 1:1.2.3.3.dfsg)
  6180. </example>
  6181. This version restriction must be new enough that any binary
  6182. built against the current version of the library will work
  6183. with any version of the shared library that satisfies that
  6184. dependency.
  6185. </p>
  6186. <p>
  6187. As zlib1g also provides a udeb containing the shared
  6188. library, there would also be a second line:
  6189. <example compact="compact">
  6190. udeb: libz 1 zlib1g-udeb (>= 1:1.2.3.3.dfsg)
  6191. </example>
  6192. </p>
  6193. </sect2>
  6194. <sect2>
  6195. <heading>Providing a <file>shlibs</file> file</heading>
  6196. <p>
  6197. To provide a <file>shlibs</file> file for a shared library
  6198. binary package, create a <file>shlibs</file> file following
  6199. the format described above and place it in
  6200. the <file>DEBIAN</file> directory for that package during
  6201. the build. It will then be included as a control file for
  6202. that package<footnote>
  6203. This is what <prgn>dh_makeshlibs</prgn> in
  6204. the <package>debhelper</package> suite does. If your
  6205. package also has a udeb that provides a shared
  6206. library, <prgn>dh_makeshlibs</prgn> can automatically
  6207. generate the <tt>udeb:</tt> lines if you specify the name
  6208. of the udeb with the <tt>--add-udeb</tt> option.
  6209. </footnote>.
  6210. </p>
  6211. <p>
  6212. Since <prgn>dpkg-shlibdeps</prgn> reads
  6213. the <file>DEBIAN/shlibs</file> files in all of the binary
  6214. packages being built from this source package, all of
  6215. the <file>DEBIAN/shlibs</file> files should be installed
  6216. before <prgn>dpkg-shlibdeps</prgn> is called on any of the
  6217. binary packages.
  6218. </p>
  6219. </sect2>
  6220. </sect1>
  6221. </sect>
  6222. </chapt>
  6223. <chapt id="opersys"><heading>The Operating System</heading>
  6224. <sect>
  6225. <heading>File system hierarchy</heading>
  6226. <sect1 id="fhs">
  6227. <heading>File System Structure</heading>
  6228. <p>
  6229. The location of all files and directories must comply with the
  6230. Filesystem Hierarchy Standard (FHS), version 2.3, with the
  6231. exceptions noted below, and except where doing so would
  6232. violate other terms of Debian Policy. The following
  6233. exceptions to the FHS apply:
  6234. <enumlist>
  6235. <item>
  6236. <p>
  6237. The FHS requirement that architecture-independent
  6238. application-specific static files be located in
  6239. <file>/usr/share</file> is relaxed to a suggestion.
  6240. In particular, a subdirectory of <file>/usr/lib</file> may
  6241. be used by a package (or a collection of packages) to hold a
  6242. mixture of architecture-independent and
  6243. architecture-dependent files. However, when a directory is
  6244. entirely composed of architecture-independent files, it
  6245. should be located in <file>/usr/share</file>.
  6246. </p>
  6247. </item>
  6248. <item>
  6249. <p>
  6250. The optional rules related to user specific
  6251. configuration files for applications are stored in
  6252. the user's home directory are relaxed. It is
  6253. recommended that such files start with the
  6254. '<tt>.</tt>' character (a "dot file"), and if an
  6255. application needs to create more than one dot file
  6256. then the preferred placement is in a subdirectory
  6257. with a name starting with a '.' character, (a "dot
  6258. directory"). In this case it is recommended the
  6259. configuration files not start with the '.'
  6260. character.
  6261. </p>
  6262. </item>
  6263. <item>
  6264. <p>
  6265. The requirement for amd64 to use <file>/lib64</file>
  6266. for 64 bit binaries is removed.
  6267. </p>
  6268. </item>
  6269. <item>
  6270. <p>
  6271. The requirement for object files, internal binaries, and
  6272. libraries, including <file>libc.so.*</file>, to be located
  6273. directly under <file>/lib{,32}</file> and
  6274. <file>/usr/lib{,32}</file> is amended, permitting files
  6275. to instead be installed to
  6276. <file>/lib/<var>triplet</var></file> and
  6277. <file>/usr/lib/<var>triplet</var></file>, where
  6278. <tt><var>triplet</var></tt> is the value returned by
  6279. <tt>dpkg-architecture -qDEB_HOST_MULTIARCH</tt> for the
  6280. architecture of the package. Packages may <em>not</em>
  6281. install files to any <var>triplet</var> path other
  6282. than the one matching the architecture of that package;
  6283. for instance, an <tt>Architecture: amd64</tt> package
  6284. containing 32-bit x86 libraries may not install these
  6285. libraries to <file>/usr/lib/i386-linux-gnu</file>.
  6286. <footnote>
  6287. This is necessary in order to reserve the directories for
  6288. use in cross-installation of library packages from other
  6289. architectures, as part of <tt>multiarch</tt>.
  6290. </footnote>
  6291. </p>
  6292. <p>
  6293. The requirement for C and C++ headers files to be
  6294. accessible through the search path
  6295. <file>/usr/include/</file> is amended, permitting files to
  6296. be accessible through the search path
  6297. <file>/usr/include/<var>triplet</var></file> where
  6298. <tt><var>triplet</var></tt> is as above. <footnote>
  6299. This is necessary for architecture-dependant headers
  6300. file to coexist in a <tt>multiarch</tt> setup.
  6301. </footnote>
  6302. </p>
  6303. <p>
  6304. Applications may also use a single subdirectory under
  6305. <file>/usr/lib/<var>triplet</var></file>.
  6306. </p>
  6307. <p>
  6308. The execution time linker/loader, ld*, must still be made
  6309. available in the existing location under /lib or /lib64
  6310. since this is part of the ELF ABI for the architecture.
  6311. </p>
  6312. </item>
  6313. <item>
  6314. <p>
  6315. The requirement that
  6316. <file>/usr/local/share/man</file> be "synonymous"
  6317. with <file>/usr/local/man</file> is relaxed to a
  6318. recommendation</p>
  6319. </item>
  6320. <item>
  6321. <p>
  6322. The requirement that windowmanagers with a single
  6323. configuration file call it <file>system.*wmrc</file>
  6324. is removed, as is the restriction that the window
  6325. manager subdirectory be named identically to the
  6326. window manager name itself.
  6327. </p>
  6328. </item>
  6329. <item>
  6330. <p>
  6331. The requirement that boot manager configuration
  6332. files live in <file>/etc</file>, or at least are
  6333. symlinked there, is relaxed to a recommendation.
  6334. </p>
  6335. </item>
  6336. <item>
  6337. <p>
  6338. The additional directory <file>/run</file> in the root
  6339. file system is allowed. <file>/run</file>
  6340. replaces <file>/var/run</file>, and the
  6341. subdirectory <file>/run/lock</file>
  6342. replaces <file>/var/lock</file>, with
  6343. the <file>/var</file> directories replaced by symlinks
  6344. for backwards compatibility. <file>/run</file>
  6345. and <file>/run/lock</file> must follow all of the
  6346. requirements in the FHS for <file>/var/run</file>
  6347. and <file>/var/lock</file>, respectively, such as file
  6348. naming conventions, file format requirements, or the
  6349. requirement that files be cleared during the boot
  6350. process. Files and directories residing
  6351. in <file>/run</file> should be stored on a temporary
  6352. file system.
  6353. </p>
  6354. <p>
  6355. Packages must not assume the <file>/run</file>
  6356. directory exists or is usable without a dependency
  6357. on <tt>initscripts (>= 2.88dsf-13.3)</tt> until the
  6358. stable release of Debian supports <file>/run</file>.
  6359. </p>
  6360. </item>
  6361. <item>
  6362. <p>
  6363. The <file>/sys</file> directory in the root filesystem is
  6364. additionally allowed. <footnote>This directory is used as
  6365. mount point to mount virtual filesystems to get access to
  6366. kernel information.</footnote>
  6367. </p>
  6368. </item>
  6369. <item>
  6370. <p>
  6371. The <file>/var/www</file> directory is additionally allowed.
  6372. </p>
  6373. </item>
  6374. <item>
  6375. <p>
  6376. The requirement for <file>/usr/local/lib&lt;qual&gt;</file>
  6377. to exist if <file>/lib&lt;qual&gt;</file> or
  6378. <file>/usr/lib&lt;qual&gt;</file> exists (where
  6379. <file>lib&lt;qual&gt;</file> is a variant of
  6380. <file>lib</file> such as <file>lib32</file> or
  6381. <file>lib64</file>) is removed.
  6382. </p>
  6383. </item>
  6384. <item>
  6385. <p>
  6386. On GNU/Hurd systems, the following additional
  6387. directories are allowed in the root
  6388. filesystem: <file>/hurd</file>
  6389. and <file>/servers</file>.<footnote>
  6390. These directories are used to store translators and as
  6391. a set of standard names for mount points,
  6392. respectively.
  6393. </footnote>
  6394. </p>
  6395. </item>
  6396. </enumlist>
  6397. </p>
  6398. <p>
  6399. The version of this document referred here can be
  6400. found in the <tt>debian-policy</tt> package or on <url
  6401. id="http://www.debian.org/doc/packaging-manuals/fhs/"
  6402. name="FHS (Debian copy)"> alongside this manual (or, if
  6403. you have the <package>debian-policy</package> installed,
  6404. you can try <url
  6405. id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
  6406. (local copy)">). The
  6407. latest version, which may be a more recent version, may
  6408. be found on
  6409. <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
  6410. Specific questions about following the standard may be
  6411. asked on the <tt>debian-devel</tt> mailing list, or
  6412. referred to the FHS mailing list (see the
  6413. <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
  6414. more information).
  6415. </p>
  6416. </sect1>
  6417. <sect1>
  6418. <heading>Site-specific programs</heading>
  6419. <p>
  6420. As mandated by the FHS, packages must not place any
  6421. files in <file>/usr/local</file>, either by putting them in
  6422. the file system archive to be unpacked by <prgn>dpkg</prgn>
  6423. or by manipulating them in their maintainer scripts.
  6424. </p>
  6425. <p>
  6426. However, the package may create empty directories below
  6427. <file>/usr/local</file> so that the system administrator knows
  6428. where to place site-specific files. These are not
  6429. directories <em>in</em> <file>/usr/local</file>, but are
  6430. children of directories in <file>/usr/local</file>. These
  6431. directories (<file>/usr/local/*/dir/</file>)
  6432. should be removed on package removal if they are
  6433. empty.
  6434. </p>
  6435. <p>
  6436. Note that this applies only to
  6437. directories <em>below</em> <file>/usr/local</file>,
  6438. not <em>in</em> <file>/usr/local</file>. Packages must
  6439. not create sub-directories in the
  6440. directory <file>/usr/local</file> itself, except those
  6441. listed in FHS, section 4.5. However, you may create
  6442. directories below them as you wish. You must not remove
  6443. any of the directories listed in 4.5, even if you created
  6444. them.
  6445. </p>
  6446. <p>
  6447. Since <file>/usr/local</file> can be mounted read-only from a
  6448. remote server, these directories must be created and
  6449. removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
  6450. maintainer scripts and not be included in the
  6451. <file>.deb</file> archive. These scripts must not fail if
  6452. either of these operations fail.
  6453. </p>
  6454. <p>
  6455. For example, the <tt>emacsen-common</tt> package could
  6456. contain something like
  6457. <example compact="compact">
  6458. if [ ! -e /usr/local/share/emacs ]; then
  6459. if mkdir /usr/local/share/emacs 2>/dev/null; then
  6460. if chown root:staff /usr/local/share/emacs; then
  6461. chmod 2775 /usr/local/share/emacs || true
  6462. fi
  6463. fi
  6464. fi
  6465. </example>
  6466. in its <prgn>postinst</prgn> script, and
  6467. <example compact="compact">
  6468. rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
  6469. rmdir /usr/local/share/emacs 2>/dev/null || true
  6470. </example>
  6471. in the <prgn>prerm</prgn> script. (Note that this form is
  6472. used to ensure that if the script is interrupted, the
  6473. directory <file>/usr/local/share/emacs</file> will still be
  6474. removed.)
  6475. </p>
  6476. <p>
  6477. If you do create a directory in <file>/usr/local</file> for
  6478. local additions to a package, you should ensure that
  6479. settings in <file>/usr/local</file> take precedence over the
  6480. equivalents in <file>/usr</file>.
  6481. </p>
  6482. <p>
  6483. However, because <file>/usr/local</file> and its contents are
  6484. for exclusive use of the local administrator, a package
  6485. must not rely on the presence or absence of files or
  6486. directories in <file>/usr/local</file> for normal operation.
  6487. </p>
  6488. <p>
  6489. The <file>/usr/local</file> directory itself and all the
  6490. subdirectories created by the package should (by default) have
  6491. permissions 2775 (group-writable and set-group-id) and be
  6492. owned by <tt>root:staff</tt>.
  6493. </p>
  6494. </sect1>
  6495. <sect1>
  6496. <heading>The system-wide mail directory</heading>
  6497. <p>
  6498. The system-wide mail directory
  6499. is <file>/var/mail</file>. This directory is part of the
  6500. base system and should not be owned by any particular mail
  6501. agents. The use of the old
  6502. location <file>/var/spool/mail</file> is deprecated, even
  6503. though the spool may still be physically located there.
  6504. </p>
  6505. </sect1>
  6506. <sect1 id="fhs-run">
  6507. <heading><file>/run</file> and <file>/run/lock</file></heading>
  6508. <p>
  6509. The directory <file>/run</file> is cleared at boot, normally
  6510. by being a mount point for a temporary file system. Packages
  6511. therefore must not assume that any files or directories
  6512. under <file>/run</file> other than <file>/run/lock</file>
  6513. exist unless the package has arranged to create those files or
  6514. directories since the last reboot. Normally, this is done by
  6515. the package via an init script. See <ref id="writing-init">
  6516. for more information.
  6517. </p>
  6518. <p>
  6519. Packages must not include files or directories
  6520. under <file>/run</file>, or under the
  6521. older <file>/var/run</file> and <file>/var/lock</file> paths.
  6522. The latter paths will normally be symlinks or other
  6523. redirections to <file>/run</file> for backwards compatibility.
  6524. </p>
  6525. </sect1>
  6526. </sect>
  6527. <sect>
  6528. <heading>Users and groups</heading>
  6529. <sect1>
  6530. <heading>Introduction</heading>
  6531. <p>
  6532. The Debian system can be configured to use either plain or
  6533. shadow passwords.
  6534. </p>
  6535. <p>
  6536. Some user ids (UIDs) and group ids (GIDs) are reserved
  6537. globally for use by certain packages. Because some
  6538. packages need to include files which are owned by these
  6539. users or groups, or need the ids compiled into binaries,
  6540. these ids must be used on any Debian system only for the
  6541. purpose for which they are allocated. This is a serious
  6542. restriction, and we should avoid getting in the way of
  6543. local administration policies. In particular, many sites
  6544. allocate users and/or local system groups starting at 100.
  6545. </p>
  6546. <p>
  6547. Apart from this we should have dynamically allocated ids,
  6548. which should by default be arranged in some sensible
  6549. order, but the behavior should be configurable.
  6550. </p>
  6551. <p>
  6552. Packages other than <tt>base-passwd</tt> must not modify
  6553. <file>/etc/passwd</file>, <file>/etc/shadow</file>,
  6554. <file>/etc/group</file> or <file>/etc/gshadow</file>.
  6555. </p>
  6556. </sect1>
  6557. <sect1>
  6558. <heading>UID and GID classes</heading>
  6559. <p>
  6560. The UID and GID numbers are divided into classes as
  6561. follows:
  6562. <taglist>
  6563. <tag>0-99:</tag>
  6564. <item>
  6565. <p>
  6566. Globally allocated by the Debian project, the same
  6567. on every Debian system. These ids will appear in
  6568. the <file>passwd</file> and <file>group</file> files of all
  6569. Debian systems, new ids in this range being added
  6570. automatically as the <tt>base-passwd</tt> package is
  6571. updated.
  6572. </p>
  6573. <p>
  6574. Packages which need a single statically allocated
  6575. uid or gid should use one of these; their
  6576. maintainers should ask the <tt>base-passwd</tt>
  6577. maintainer for ids.
  6578. </p>
  6579. </item>
  6580. <tag>100-999:</tag>
  6581. <item>
  6582. <p>
  6583. Dynamically allocated system users and groups.
  6584. Packages which need a user or group, but can have
  6585. this user or group allocated dynamically and
  6586. differently on each system, should use <tt>adduser
  6587. --system</tt> to create the group and/or user.
  6588. <prgn>adduser</prgn> will check for the existence of
  6589. the user or group, and if necessary choose an unused
  6590. id based on the ranges specified in
  6591. <file>adduser.conf</file>.
  6592. </p>
  6593. </item>
  6594. <tag>1000-59999:</tag>
  6595. <item>
  6596. <p>
  6597. Dynamically allocated user accounts. By default
  6598. <prgn>adduser</prgn> will choose UIDs and GIDs for
  6599. user accounts in this range, though
  6600. <file>adduser.conf</file> may be used to modify this
  6601. behavior.
  6602. </p>
  6603. </item>
  6604. <tag>60000-64999:</tag>
  6605. <item>
  6606. <p>
  6607. Globally allocated by the Debian project, but only
  6608. created on demand. The ids are allocated centrally
  6609. and statically, but the actual accounts are only
  6610. created on users' systems on demand.
  6611. </p>
  6612. <p>
  6613. These ids are for packages which are obscure or
  6614. which require many statically-allocated ids. These
  6615. packages should check for and create the accounts in
  6616. <file>/etc/passwd</file> or <file>/etc/group</file> (using
  6617. <prgn>adduser</prgn> if it has this facility) if
  6618. necessary. Packages which are likely to require
  6619. further allocations should have a "hole" left after
  6620. them in the allocation, to give them room to
  6621. grow.
  6622. </p>
  6623. </item>
  6624. <tag>65000-65533:</tag>
  6625. <item>
  6626. <p>Reserved.</p>
  6627. </item>
  6628. <tag>65534:</tag>
  6629. <item>
  6630. <p>
  6631. User <tt>nobody</tt>. The corresponding gid refers
  6632. to the group <tt>nogroup</tt>.
  6633. </p>
  6634. </item>
  6635. <tag>65535:</tag>
  6636. <item>
  6637. <p>
  6638. This value <em>must not</em> be used, because it was
  6639. the error return sentinel value when <tt>uid_t</tt>
  6640. was 16 bits.
  6641. </p>
  6642. </item>
  6643. <tag>65536-4294967293:</tag>
  6644. <item>
  6645. <p>
  6646. Dynamically allocated user accounts. By
  6647. default <prgn>adduser</prgn> will not allocate UIDs
  6648. and GIDs in this range, to ease compatibility with
  6649. legacy systems where <tt>uid_t</tt> is still 16
  6650. bits.
  6651. </p>
  6652. </item>
  6653. <tag>4294967294:</tag>
  6654. <item>
  6655. <p>
  6656. <tt>(uid_t)(-2) == (gid_t)(-2)</tt> <em>must not</em> be
  6657. used, because it is used as the anonymous, unauthenticated
  6658. user by some NFS implementations.
  6659. </p>
  6660. </item>
  6661. <tag>4294967295:</tag>
  6662. <item>
  6663. <p>
  6664. <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
  6665. not</em> be used, because it is the error return
  6666. sentinel value.
  6667. </p>
  6668. </item>
  6669. </taglist>
  6670. </p>
  6671. </sect1>
  6672. </sect>
  6673. <sect id="sysvinit">
  6674. <heading>System run levels and <file>init.d</file> scripts</heading>
  6675. <sect1 id="/etc/init.d">
  6676. <heading>Introduction</heading>
  6677. <p>
  6678. The <file>/etc/init.d</file> directory contains the scripts
  6679. executed by <prgn>init</prgn> at boot time and when the
  6680. init state (or "runlevel") is changed (see <manref
  6681. name="init" section="8">).
  6682. </p>
  6683. <p>
  6684. There are at least two different, yet functionally
  6685. equivalent, ways of handling these scripts. For the sake
  6686. of simplicity, this document describes only the symbolic
  6687. link method. However, it must not be assumed by maintainer
  6688. scripts that this method is being used, and any automated
  6689. manipulation of the various runlevel behaviors by
  6690. maintainer scripts must be performed using
  6691. <prgn>update-rc.d</prgn> as described below and not by
  6692. manually installing or removing symlinks. For information
  6693. on the implementation details of the other method,
  6694. implemented in the <tt>file-rc</tt> package, please refer
  6695. to the documentation of that package.
  6696. </p>
  6697. <p>
  6698. These scripts are referenced by symbolic links in the
  6699. <file>/etc/rc<var>n</var>.d</file> directories. When changing
  6700. runlevels, <prgn>init</prgn> looks in the directory
  6701. <file>/etc/rc<var>n</var>.d</file> for the scripts it should
  6702. execute, where <tt><var>n</var></tt> is the runlevel that
  6703. is being changed to, or <tt>S</tt> for the boot-up
  6704. scripts.
  6705. </p>
  6706. <p>
  6707. The names of the links all have the form
  6708. <file>S<var>mm</var><var>script</var></file> or
  6709. <file>K<var>mm</var><var>script</var></file> where
  6710. <var>mm</var> is a two-digit number and <var>script</var>
  6711. is the name of the script (this should be the same as the
  6712. name of the actual script in <file>/etc/init.d</file>).
  6713. </p>
  6714. <p>
  6715. When <prgn>init</prgn> changes runlevel first the targets
  6716. of the links whose names start with a <tt>K</tt> are
  6717. executed, each with the single argument <tt>stop</tt>,
  6718. followed by the scripts prefixed with an <tt>S</tt>, each
  6719. with the single argument <tt>start</tt>. (The links are
  6720. those in the <file>/etc/rc<var>n</var>.d</file> directory
  6721. corresponding to the new runlevel.) The <tt>K</tt> links
  6722. are responsible for killing services and the <tt>S</tt>
  6723. link for starting services upon entering the runlevel.
  6724. </p>
  6725. <p>
  6726. For example, if we are changing from runlevel 2 to
  6727. runlevel 3, init will first execute all of the <tt>K</tt>
  6728. prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
  6729. all of the <tt>S</tt> prefixed scripts in that directory.
  6730. The links starting with <tt>K</tt> will cause the
  6731. referred-to file to be executed with an argument of
  6732. <tt>stop</tt>, and the <tt>S</tt> links with an argument
  6733. of <tt>start</tt>.
  6734. </p>
  6735. <p>
  6736. The two-digit number <var>mm</var> is used to determine
  6737. the order in which to run the scripts: low-numbered links
  6738. have their scripts run first. For example, the
  6739. <tt>K20</tt> scripts will be executed before the
  6740. <tt>K30</tt> scripts. This is used when a certain service
  6741. must be started before another. For example, the name
  6742. server <prgn>bind</prgn> might need to be started before
  6743. the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
  6744. can set up its access lists. In this case, the script
  6745. that starts <prgn>bind</prgn> would have a lower number
  6746. than the script that starts <prgn>inn</prgn> so that it
  6747. runs first:
  6748. <example compact="compact">
  6749. /etc/rc2.d/S17bind
  6750. /etc/rc2.d/S70inn
  6751. </example>
  6752. </p>
  6753. <p>
  6754. The two runlevels 0 (halt) and 6 (reboot) are slightly
  6755. different. In these runlevels, the links with an
  6756. <tt>S</tt> prefix are still called after those with a
  6757. <tt>K</tt> prefix, but they too are called with the single
  6758. argument <tt>stop</tt>.
  6759. </p>
  6760. </sect1>
  6761. <sect1 id="writing-init">
  6762. <heading>Writing the scripts</heading>
  6763. <p>
  6764. Packages that include daemons for system services should
  6765. place scripts in <file>/etc/init.d</file> to start or stop
  6766. services at boot time or during a change of runlevel.
  6767. These scripts should be named
  6768. <file>/etc/init.d/<var>package</var></file>, and they should
  6769. accept one argument, saying what to do:
  6770. <taglist>
  6771. <tag><tt>start</tt></tag>
  6772. <item>start the service,</item>
  6773. <tag><tt>stop</tt></tag>
  6774. <item>stop the service,</item>
  6775. <tag><tt>restart</tt></tag>
  6776. <item>stop and restart the service if it's already running,
  6777. otherwise start the service</item>
  6778. <tag><tt>reload</tt></tag>
  6779. <item><p>cause the configuration of the service to be
  6780. reloaded without actually stopping and restarting
  6781. the service,</item>
  6782. <tag><tt>force-reload</tt></tag>
  6783. <item>cause the configuration to be reloaded if the
  6784. service supports this, otherwise restart the
  6785. service.</item>
  6786. </taglist>
  6787. The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
  6788. <tt>force-reload</tt> options should be supported by all
  6789. scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
  6790. option is optional.
  6791. </p>
  6792. <p>
  6793. The <file>init.d</file> scripts must ensure that they will
  6794. behave sensibly (i.e., returning success and not starting
  6795. multiple copies of a service) if invoked with <tt>start</tt>
  6796. when the service is already running, or with <tt>stop</tt>
  6797. when it isn't, and that they don't kill unfortunately-named
  6798. user processes. The best way to achieve this is usually to
  6799. use <prgn>start-stop-daemon</prgn> with the <tt>--oknodo</tt>
  6800. option.
  6801. </p>
  6802. <p>
  6803. Be careful of using <tt>set -e</tt> in <file>init.d</file>
  6804. scripts. Writing correct <file>init.d</file> scripts requires
  6805. accepting various error exit statuses when daemons are already
  6806. running or already stopped without aborting
  6807. the <file>init.d</file> script, and common <file>init.d</file>
  6808. function libraries are not safe to call with <tt>set -e</tt>
  6809. in effect<footnote>
  6810. <tt>/lib/lsb/init-functions</tt>, which assists in writing
  6811. LSB-compliant init scripts, may fail if <tt>set -e</tt> is
  6812. in effect and echoing status messages to the console fails,
  6813. for example.
  6814. </footnote>. For <tt>init.d</tt> scripts, it's often easier
  6815. to not use <tt>set -e</tt> and instead check the result of
  6816. each command separately.
  6817. </p>
  6818. <p>
  6819. If a service reloads its configuration automatically (as
  6820. in the case of <prgn>cron</prgn>, for example), the
  6821. <tt>reload</tt> option of the <file>init.d</file> script
  6822. should behave as if the configuration has been reloaded
  6823. successfully.
  6824. </p>
  6825. <p>
  6826. The <file>/etc/init.d</file> scripts must be treated as
  6827. configuration files, either (if they are present in the
  6828. package, that is, in the .deb file) by marking them as
  6829. <tt>conffile</tt>s, or, (if they do not exist in the .deb)
  6830. by managing them correctly in the maintainer scripts (see
  6831. <ref id="config-files">). This is important since we want
  6832. to give the local system administrator the chance to adapt
  6833. the scripts to the local system, e.g., to disable a
  6834. service without de-installing the package, or to specify
  6835. some special command line options when starting a service,
  6836. while making sure their changes aren't lost during the next
  6837. package upgrade.
  6838. </p>
  6839. <p>
  6840. These scripts should not fail obscurely when the
  6841. configuration files remain but the package has been
  6842. removed, as configuration files remain on the system after
  6843. the package has been removed. Only when <prgn>dpkg</prgn>
  6844. is executed with the <tt>--purge</tt> option will
  6845. configuration files be removed. In particular, as the
  6846. <file>/etc/init.d/<var>package</var></file> script itself is
  6847. usually a <tt>conffile</tt>, it will remain on the system
  6848. if the package is removed but not purged. Therefore, you
  6849. should include a <tt>test</tt> statement at the top of the
  6850. script, like this:
  6851. <example compact="compact">
  6852. test -f <var>program-executed-later-in-script</var> || exit 0
  6853. </example>
  6854. </p>
  6855. <p>
  6856. Often there are some variables in the <file>init.d</file>
  6857. scripts whose values control the behavior of the scripts,
  6858. and which a system administrator is likely to want to
  6859. change. As the scripts themselves are frequently
  6860. <tt>conffile</tt>s, modifying them requires that the
  6861. administrator merge in their changes each time the package
  6862. is upgraded and the <tt>conffile</tt> changes. To ease
  6863. the burden on the system administrator, such configurable
  6864. values should not be placed directly in the script.
  6865. Instead, they should be placed in a file in
  6866. <file>/etc/default</file>, which typically will have the same
  6867. base name as the <file>init.d</file> script. This extra file
  6868. should be sourced by the script when the script runs. It
  6869. must contain only variable settings and comments in SUSv3
  6870. <prgn>sh</prgn> format. It may either be a
  6871. <tt>conffile</tt> or a configuration file maintained by
  6872. the package maintainer scripts. See <ref id="config-files">
  6873. for more details.
  6874. </p>
  6875. <p>
  6876. To ensure that vital configurable values are always
  6877. available, the <file>init.d</file> script should set default
  6878. values for each of the shell variables it uses, either
  6879. before sourcing the <file>/etc/default/</file> file or
  6880. afterwards using something like the <tt>:
  6881. ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
  6882. script must behave sensibly and not fail if the
  6883. <file>/etc/default</file> file is deleted.
  6884. </p>
  6885. <p>
  6886. Files and directories under <file>/run</file>, including ones
  6887. referred to via the compatibility paths <file>/var/run</file>
  6888. and <file>/var/lock</file>, are normally stored on a temporary
  6889. filesystem and are normally not persistent across a reboot.
  6890. The <file>init.d</file> scripts must handle this correctly.
  6891. This will typically mean creating any required subdirectories
  6892. dynamically when the <file>init.d</file> script is run.
  6893. See <ref id="fhs-run"> for more information.
  6894. </p>
  6895. </sect1>
  6896. <sect1>
  6897. <heading>Interfacing with the initscript system</heading>
  6898. <p>
  6899. Maintainers should use the abstraction layer provided by
  6900. the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
  6901. programs to deal with initscripts in their packages'
  6902. scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
  6903. and <prgn>postrm</prgn>.
  6904. </p>
  6905. <p>
  6906. Directly managing the /etc/rc?.d links and directly
  6907. invoking the <file>/etc/init.d/</file> initscripts should
  6908. be done only by packages providing the initscript
  6909. subsystem (such as <prgn>sysv-rc</prgn> and
  6910. <prgn>file-rc</prgn>).
  6911. </p>
  6912. <sect2>
  6913. <heading>Managing the links</heading>
  6914. <p>
  6915. The program <prgn>update-rc.d</prgn> is provided for
  6916. package maintainers to arrange for the proper creation and
  6917. removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
  6918. or their functional equivalent if another method is being
  6919. used. This may be used by maintainers in their packages'
  6920. <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.
  6921. </p>
  6922. <p>
  6923. You must not include any <file>/etc/rc<var>n</var>.d</file>
  6924. symbolic links in the actual archive or manually create or
  6925. remove the symbolic links in maintainer scripts; you must
  6926. use the <prgn>update-rc.d</prgn> program instead. (The
  6927. former will fail if an alternative method of maintaining
  6928. runlevel information is being used.) You must not include
  6929. the <file>/etc/rc<var>n</var>.d</file> directories themselves
  6930. in the archive either. (Only the <tt>sysvinit</tt>
  6931. package may do so.)
  6932. </p>
  6933. <p>
  6934. By default <prgn>update-rc.d</prgn> will start services in
  6935. each of the multi-user state runlevels (2, 3, 4, and 5)
  6936. and stop them in the halt runlevel (0), the single-user
  6937. runlevel (1) and the reboot runlevel (6). The system
  6938. administrator will have the opportunity to customize
  6939. runlevels by simply adding, moving, or removing the
  6940. symbolic links in <file>/etc/rc<var>n</var>.d</file> if
  6941. symbolic links are being used, or by modifying
  6942. <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
  6943. is being used.
  6944. </p>
  6945. <p>
  6946. To get the default behavior for your package, put in your
  6947. <prgn>postinst</prgn> script
  6948. <example compact="compact">
  6949. update-rc.d <var>package</var> defaults
  6950. </example>
  6951. and in your <prgn>postrm</prgn>
  6952. <example compact="compact">
  6953. if [ "$1" = purge ]; then
  6954. update-rc.d <var>package</var> remove
  6955. fi
  6956. </example>. Note that if your package changes runlevels
  6957. or priority, you may have to remove and recreate the links,
  6958. since otherwise the old links may persist. Refer to the
  6959. documentation of <prgn>update-rc.d</prgn>.
  6960. </p>
  6961. <p>
  6962. This will use a default sequence number of 20. If it does
  6963. not matter when or in which order the <file>init.d</file>
  6964. script is run, use this default. If it does, then you
  6965. should talk to the maintainer of the <prgn>sysvinit</prgn>
  6966. package or post to <tt>debian-devel</tt>, and they will
  6967. help you choose a number.
  6968. </p>
  6969. <p>
  6970. For more information about using <tt>update-rc.d</tt>,
  6971. please consult its man page <manref name="update-rc.d"
  6972. section="8">.
  6973. </p>
  6974. </sect2>
  6975. <sect2>
  6976. <heading>Running initscripts</heading>
  6977. <p>
  6978. The program <prgn>invoke-rc.d</prgn> is provided to make
  6979. it easier for package maintainers to properly invoke an
  6980. initscript, obeying runlevel and other locally-defined
  6981. constraints that might limit a package's right to start,
  6982. stop and otherwise manage services. This program may be
  6983. used by maintainers in their packages' scripts.
  6984. </p>
  6985. <p>
  6986. The package maintainer scripts must use
  6987. <prgn>invoke-rc.d</prgn> to invoke the
  6988. <file>/etc/init.d/*</file> initscripts, instead of
  6989. calling them directly.
  6990. </p>
  6991. <p>
  6992. By default, <prgn>invoke-rc.d</prgn> will pass any
  6993. action requests (start, stop, reload, restart...) to the
  6994. <file>/etc/init.d</file> script, filtering out requests
  6995. to start or restart a service out of its intended
  6996. runlevels.
  6997. </p>
  6998. <p>
  6999. Most packages will simply need to change:
  7000. <example compact="compact">/etc/init.d/&lt;package&gt;
  7001. &lt;action&gt;</example> in their <prgn>postinst</prgn>
  7002. and <prgn>prerm</prgn> scripts to:
  7003. <example compact="compact">
  7004. if which invoke-rc.d >/dev/null 2>&1; then
  7005. invoke-rc.d <var>package</var> &lt;action&gt;
  7006. else
  7007. /etc/init.d/<var>package</var> &lt;action&gt;
  7008. fi
  7009. </example>
  7010. </p>
  7011. <p>
  7012. A package should register its initscript services using
  7013. <prgn>update-rc.d</prgn> before it tries to invoke them
  7014. using <prgn>invoke-rc.d</prgn>. Invocation of
  7015. unregistered services may fail.
  7016. </p>
  7017. <p>
  7018. For more information about using
  7019. <prgn>invoke-rc.d</prgn>, please consult its man page
  7020. <manref name="invoke-rc.d" section="8">.
  7021. </p>
  7022. </sect2>
  7023. </sect1>
  7024. <sect1>
  7025. <heading>Boot-time initialization</heading>
  7026. <p>
  7027. There used to be another directory, <file>/etc/rc.boot</file>,
  7028. which contained scripts which were run once per machine
  7029. boot. This has been deprecated in favour of links from
  7030. <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
  7031. described in <ref id="/etc/init.d">. Packages must not
  7032. place files in <file>/etc/rc.boot</file>.
  7033. </p>
  7034. </sect1>
  7035. <sect1>
  7036. <heading>Example</heading>
  7037. <p>
  7038. An example on which you can base your
  7039. <file>/etc/init.d</file> scripts is found in
  7040. <file>/etc/init.d/skeleton</file>.
  7041. </p>
  7042. </sect1>
  7043. </sect>
  7044. <sect>
  7045. <heading>Console messages from <file>init.d</file> scripts</heading>
  7046. <p>
  7047. This section describes the formats to be used for messages
  7048. written to standard output by the <file>/etc/init.d</file>
  7049. scripts. The intent is to improve the consistency of
  7050. Debian's startup and shutdown look and feel. For this
  7051. reason, please look very carefully at the details. We want
  7052. the messages to have the same format in terms of wording,
  7053. spaces, punctuation and case of letters.
  7054. </p>
  7055. <p>
  7056. Here is a list of overall rules that should be used for
  7057. messages generated by <file>/etc/init.d</file> scripts.
  7058. </p>
  7059. <p>
  7060. <list>
  7061. <item>
  7062. The message should fit in one line (fewer than 80
  7063. characters), start with a capital letter and end with
  7064. a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
  7065. </item>
  7066. <item>
  7067. If the script is performing some time consuming task in
  7068. the background (not merely starting or stopping a
  7069. program, for instance), an ellipsis (three dots:
  7070. <tt>...</tt>) should be output to the screen, with no
  7071. leading or tailing whitespace or line feeds.
  7072. </item>
  7073. <item>
  7074. The messages should appear as if the computer is telling
  7075. the user what it is doing (politely :-), but should not
  7076. mention "it" directly. For example, instead of:
  7077. <example compact="compact">
  7078. I'm starting network daemons: nfsd mountd.
  7079. </example>
  7080. the message should say
  7081. <example compact="compact">
  7082. Starting network daemons: nfsd mountd.
  7083. </example>
  7084. </item>
  7085. </list>
  7086. </p>
  7087. <p>
  7088. <tt>init.d</tt> script should use the following standard
  7089. message formats for the situations enumerated below.
  7090. </p>
  7091. <p>
  7092. <list>
  7093. <item>
  7094. <p>When daemons are started</p>
  7095. <p>
  7096. If the script starts one or more daemons, the output
  7097. should look like this (a single line, no leading
  7098. spaces):
  7099. <example compact="compact">
  7100. Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
  7101. </example>
  7102. The <var>description</var> should describe the
  7103. subsystem the daemon or set of daemons are part of,
  7104. while <var>daemon-1</var> up to <var>daemon-n</var>
  7105. denote each daemon's name (typically the file name of
  7106. the program).
  7107. </p>
  7108. <p>
  7109. For example, the output of <file>/etc/init.d/lpd</file>
  7110. would look like:
  7111. <example compact="compact">
  7112. Starting printer spooler: lpd.
  7113. </example>
  7114. </p>
  7115. <p>
  7116. This can be achieved by saying
  7117. <example compact="compact">
  7118. echo -n "Starting printer spooler: lpd"
  7119. start-stop-daemon --start --quiet --exec /usr/sbin/lpd
  7120. echo "."
  7121. </example>
  7122. in the script. If there are more than one daemon to
  7123. start, the output should look like this:
  7124. <example compact="compact">
  7125. echo -n "Starting remote file system services:"
  7126. echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
  7127. echo -n " mountd"; start-stop-daemon --start --quiet mountd
  7128. echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
  7129. echo "."
  7130. </example>
  7131. This makes it possible for the user to see what is
  7132. happening and when the final daemon has been started.
  7133. Care should be taken in the placement of white spaces:
  7134. in the example above the system administrators can
  7135. easily comment out a line if they don't want to start
  7136. a specific daemon, while the displayed message still
  7137. looks good.
  7138. </p>
  7139. </item>
  7140. <item>
  7141. <p>When a system parameter is being set</p>
  7142. <p>
  7143. If you have to set up different system parameters
  7144. during the system boot, you should use this format:
  7145. <example compact="compact">
  7146. Setting <var>parameter</var> to "<var>value</var>".
  7147. </example>
  7148. </p>
  7149. <p>
  7150. You can use a statement such as the following to get
  7151. the quotes right:
  7152. <example compact="compact">
  7153. echo "Setting DNS domainname to \"$domainname\"."
  7154. </example>
  7155. </p>
  7156. <p>
  7157. Note that the same symbol (<tt>"</tt>) <!-- " --> is used
  7158. for the left and right quotation marks. A grave accent
  7159. (<tt>`</tt>) is not a quote character; neither is an
  7160. apostrophe (<tt>'</tt>).
  7161. </p>
  7162. </item>
  7163. <item>
  7164. <p>When a daemon is stopped or restarted</p>
  7165. <p>
  7166. When you stop or restart a daemon, you should issue a
  7167. message identical to the startup message, except that
  7168. <tt>Starting</tt> is replaced with <tt>Stopping</tt>
  7169. or <tt>Restarting</tt> respectively.
  7170. </p>
  7171. <p>
  7172. For example, stopping the printer daemon will look like
  7173. this:
  7174. <example compact="compact">
  7175. Stopping printer spooler: lpd.
  7176. </example>
  7177. </p>
  7178. </item>
  7179. <item>
  7180. <p>When something is executed</p>
  7181. <p>
  7182. There are several examples where you have to run a
  7183. program at system startup or shutdown to perform a
  7184. specific task, for example, setting the system's clock
  7185. using <prgn>netdate</prgn> or killing all processes
  7186. when the system shuts down. Your message should look
  7187. like this:
  7188. <example compact="compact">
  7189. Doing something very useful...done.
  7190. </example>
  7191. You should print the <tt>done.</tt> immediately after
  7192. the job has been completed, so that the user is
  7193. informed why they have to wait. You can get this
  7194. behavior by saying
  7195. <example compact="compact">
  7196. echo -n "Doing something very useful..."
  7197. do_something
  7198. echo "done."
  7199. </example>
  7200. in your script.
  7201. </p>
  7202. </item>
  7203. <item>
  7204. <p>When the configuration is reloaded</p>
  7205. <p>
  7206. When a daemon is forced to reload its configuration
  7207. files you should use the following format:
  7208. <example compact="compact">
  7209. Reloading <var>description</var> configuration...done.
  7210. </example>
  7211. where <var>description</var> is the same as in the
  7212. daemon starting message.
  7213. </p>
  7214. </item>
  7215. </list>
  7216. </p>
  7217. </sect>
  7218. <sect id="cron-jobs">
  7219. <heading>Cron jobs</heading>
  7220. <p>
  7221. Packages must not modify the configuration file
  7222. <file>/etc/crontab</file>, and they must not modify the files in
  7223. <file>/var/spool/cron/crontabs</file>.
  7224. </p>
  7225. <p>
  7226. If a package wants to install a job that has to be executed via
  7227. cron, it should place a file named as specified
  7228. in <ref id="cron-files"> into one or more of the following
  7229. directories:
  7230. <example compact="compact">
  7231. /etc/cron.hourly
  7232. /etc/cron.daily
  7233. /etc/cron.weekly
  7234. /etc/cron.monthly
  7235. </example>
  7236. As these directory names imply, the files within them are
  7237. executed on an hourly, daily, weekly, or monthly basis,
  7238. respectively. The exact times are listed in
  7239. <file>/etc/crontab</file>.
  7240. </p>
  7241. <p>
  7242. All files installed in any of these directories must be
  7243. scripts (e.g., shell scripts or Perl scripts) so that they
  7244. can easily be modified by the local system administrator.
  7245. In addition, they must be treated as configuration files.
  7246. </p>
  7247. <p>
  7248. If a certain job has to be executed at some other frequency or
  7249. at a specific time, the package should install a file in
  7250. <file>/etc/cron.d</file> with a name as specified
  7251. in <ref id="cron-files">. This file uses the same syntax
  7252. as <file>/etc/crontab</file> and is processed
  7253. by <prgn>cron</prgn> automatically. The file must also be
  7254. treated as a configuration file. (Note that entries in the
  7255. <file>/etc/cron.d</file> directory are not handled by
  7256. <prgn>anacron</prgn>. Thus, you should only use this
  7257. directory for jobs which may be skipped if the system is not
  7258. running.)
  7259. </p>
  7260. <p>
  7261. Unlike <file>crontab</file> files described in the IEEE Std
  7262. 1003.1-2008 (POSIX.1) available from
  7263. <url id="http://www.opengroup.org/onlinepubs/9699919799/"
  7264. name="The Open Group">, the files in
  7265. <file>/etc/cron.d</file> and the file
  7266. <file>/etc/crontab</file> have seven fields; namely:
  7267. <enumlist>
  7268. <item>Minute [0,59]</item>
  7269. <item>Hour [0,23]</item>
  7270. <item>Day of the month [1,31]</item>
  7271. <item>Month of the year [1,12]</item>
  7272. <item>Day of the week ([0,6] with 0=Sunday)</item>
  7273. <item>Username</item>
  7274. <item>Command to be run</item>
  7275. </enumlist>
  7276. Ranges of numbers are allowed. Ranges are two numbers
  7277. separated with a hyphen. The specified range is inclusive.
  7278. Lists are allowed. A list is a set of numbers (or ranges)
  7279. separated by commas. Step values can be used in conjunction
  7280. with ranges.
  7281. </p>
  7282. <p>
  7283. The scripts or <tt>crontab</tt> entries in these directories should
  7284. check if all necessary programs are installed before they
  7285. try to execute them. Otherwise, problems will arise when a
  7286. package was removed but not purged since configuration files
  7287. are kept on the system in this situation.
  7288. </p>
  7289. <p>
  7290. Any <tt>cron</tt> daemon must provide
  7291. <file>/usr/bin/crontab</file> and support normal
  7292. <tt>crontab</tt> entries as specified in POSIX. The daemon
  7293. must also support names for days and months, ranges, and
  7294. step values. It has to support <file>/etc/crontab</file>,
  7295. and correctly execute the scripts in
  7296. <file>/etc/cron.d</file>. The daemon must also correctly
  7297. execute scripts in
  7298. <file>/etc/cron.{hourly,daily,weekly,monthly}</file>.
  7299. </p>
  7300. <sect1 id="cron-files">
  7301. <heading>Cron job file names</heading>
  7302. <p>
  7303. The file name of a cron job file should normally match the
  7304. name of the package from which it comes.
  7305. </p>
  7306. <p>
  7307. If a package supplies multiple cron job files files in the
  7308. same directory, the file names should all start with the name
  7309. of the package (possibly modified as described below) followed
  7310. by a hyphen (<tt>-</tt>) and a suitable suffix.
  7311. </p>
  7312. <p>
  7313. A cron job file name must not include any period or plus
  7314. characters (<tt>.</tt> or <tt>+</tt>) characters as this will
  7315. cause cron to ignore the file. Underscores (<tt>_</tt>)
  7316. should be used instead of <tt>.</tt> and <tt>+</tt>
  7317. characters.
  7318. </p>
  7319. </sect1>
  7320. </sect>
  7321. <sect id="menus">
  7322. <heading>Menus</heading>
  7323. <p>
  7324. The Debian <tt>menu</tt> package provides a standard
  7325. interface between packages providing applications and
  7326. <em>menu programs</em> (either X window managers or
  7327. text-based menu programs such as <prgn>pdmenu</prgn>).
  7328. </p>
  7329. <p>
  7330. All packages that provide applications that need not be
  7331. passed any special command line arguments for normal
  7332. operation should register a menu entry for those
  7333. applications, so that users of the <tt>menu</tt> package
  7334. will automatically get menu entries in their window
  7335. managers, as well in shells like <tt>pdmenu</tt>.
  7336. </p>
  7337. <p>
  7338. Menu entries should follow the current menu policy.
  7339. </p>
  7340. <p>
  7341. The menu policy can be found in the <tt>menu-policy</tt>
  7342. files in the <tt>debian-policy</tt> package.
  7343. It is also available from the Debian web mirrors at
  7344. <tt><url name="/doc/packaging-manuals/menu-policy/"
  7345. id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>.
  7346. </p>
  7347. <p>
  7348. Please also refer to the <em>Debian Menu System</em>
  7349. documentation that comes with the <package>menu</package>
  7350. package for information about how to register your
  7351. applications.
  7352. </p>
  7353. </sect>
  7354. <sect id="mime">
  7355. <heading>Multimedia handlers</heading>
  7356. <p>
  7357. MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
  7358. is a mechanism for encoding files and data streams and
  7359. providing meta-information about them, in particular their
  7360. type (e.g. audio or video) and format (e.g. PNG, HTML,
  7361. MP3).
  7362. </p>
  7363. <p>
  7364. Registration of MIME type handlers allows programs like mail
  7365. user agents and web browsers to invoke these handlers to
  7366. view, edit or display MIME types they don't support directly.
  7367. </p>
  7368. <p>
  7369. Packages which provide programs to view/show/play, compose, edit or
  7370. print MIME types should register them as such by placing a file in
  7371. <manref name="mailcap" section="5"> format (RFC 1524) in the directory
  7372. <file>/usr/lib/mime/packages/</file>. The file name should be the
  7373. binary package's name.
  7374. </p>
  7375. <p>
  7376. The <package>mime-support</package> package provides the
  7377. <prgn>update-mime</prgn> program, which integrates these
  7378. registrations in the <file>/etc/mailcap</file> file, using dpkg
  7379. triggers<footnote>
  7380. Creating, modifying or removing a file in
  7381. <file>/usr/lib/mime/packages/</file> using maintainer scripts will
  7382. not activate the trigger. In that case, it can be done by calling
  7383. <tt>dpkg-trigger --no-await /usr/lib/mime/packages</tt> from
  7384. the maintainer script after creating, modifying, or removing
  7385. the file.
  7386. </footnote>.
  7387. Packages using this facility <em>should not</em> depend on,
  7388. recommend, or suggest <prgn>mime-support</prgn>.
  7389. </p>
  7390. </sect>
  7391. <sect>
  7392. <heading>Keyboard configuration</heading>
  7393. <p>
  7394. To achieve a consistent keyboard configuration so that all
  7395. applications interpret a keyboard event the same way, all
  7396. programs in the Debian distribution must be configured to
  7397. comply with the following guidelines.
  7398. </p>
  7399. <p>
  7400. The following keys must have the specified interpretations:
  7401. <taglist>
  7402. <tag><tt>&lt;--</tt></tag>
  7403. <item>delete the character to the left of the cursor</item>
  7404. <tag><tt>Delete</tt></tag>
  7405. <item>delete the character to the right of the cursor</item>
  7406. <tag><tt>Control+H</tt></tag>
  7407. <item>emacs: the help prefix</item>
  7408. </taglist>
  7409. The interpretation of any keyboard events should be
  7410. independent of the terminal that is used, be it a virtual
  7411. console, an X terminal emulator, an rlogin/telnet session,
  7412. etc.
  7413. </p>
  7414. <p>
  7415. The following list explains how the different programs
  7416. should be set up to achieve this:
  7417. </p>
  7418. <p>
  7419. <list>
  7420. <item>
  7421. <tt>&lt;--</tt> generates <tt>KB_BackSpace</tt> in X.
  7422. </item>
  7423. <item>
  7424. <tt>Delete</tt> generates <tt>KB_Delete</tt> in X.
  7425. </item>
  7426. <item>
  7427. X translations are set up to make
  7428. <tt>KB_Backspace</tt> generate ASCII DEL, and to make
  7429. <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
  7430. is the vt220 escape code for the "delete character"
  7431. key). This must be done by loading the X resources
  7432. using <prgn>xrdb</prgn> on all local X displays, not
  7433. using the application defaults, so that the
  7434. translation resources used correspond to the
  7435. <prgn>xmodmap</prgn> settings.
  7436. </item>
  7437. <item>
  7438. The Linux console is configured to make
  7439. <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
  7440. generate <tt>ESC [ 3 ~</tt>.
  7441. </item>
  7442. <item>
  7443. X applications are configured so that <tt>&lt;</tt>
  7444. deletes left, and <tt>Delete</tt> deletes right. Motif
  7445. applications already work like this.
  7446. </item>
  7447. <item>
  7448. Terminals should have <tt>stty erase ^?</tt> .
  7449. </item>
  7450. <item>
  7451. The <tt>xterm</tt> terminfo entry should have <tt>ESC
  7452. [ 3 ~</tt> for <tt>kdch1</tt>, just as for
  7453. <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.
  7454. </item>
  7455. <item>
  7456. Emacs is programmed to map <tt>KB_Backspace</tt> or
  7457. the <tt>stty erase</tt> character to
  7458. <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
  7459. or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
  7460. <tt>^H</tt> to <tt>help</tt> as always.
  7461. </item>
  7462. <item>
  7463. Other applications use the <tt>stty erase</tt>
  7464. character and <tt>kdch1</tt> for the two delete keys,
  7465. with ASCII DEL being "delete previous character" and
  7466. <tt>kdch1</tt> being "delete character under
  7467. cursor".
  7468. </item>
  7469. </list>
  7470. </p>
  7471. <p>
  7472. This will solve the problem except for the following
  7473. cases:
  7474. </p>
  7475. <p>
  7476. <list>
  7477. <item>
  7478. Some terminals have a <tt>&lt;--</tt> key that cannot
  7479. be made to produce anything except <tt>^H</tt>. On
  7480. these terminals Emacs help will be unavailable on
  7481. <tt>^H</tt> (assuming that the <tt>stty erase</tt>
  7482. character takes precedence in Emacs, and has been set
  7483. correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
  7484. available) can be used instead.
  7485. </item>
  7486. <item>
  7487. Some operating systems use <tt>^H</tt> for <tt>stty
  7488. erase</tt>. However, modern telnet versions and all
  7489. rlogin versions propagate <tt>stty</tt> settings, and
  7490. almost all UNIX versions honour <tt>stty erase</tt>.
  7491. Where the <tt>stty</tt> settings are not propagated
  7492. correctly, things can be made to work by using
  7493. <tt>stty</tt> manually.
  7494. </item>
  7495. <item>
  7496. Some systems (including previous Debian versions) use
  7497. <prgn>xmodmap</prgn> to arrange for both
  7498. <tt>&lt;--</tt> and <tt>Delete</tt> to generate
  7499. <tt>KB_Delete</tt>. We can change the behavior of
  7500. their X clients using the same X resources that we use
  7501. to do it for our own clients, or configure our clients
  7502. using their resources when things are the other way
  7503. around. On displays configured like this
  7504. <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
  7505. will.
  7506. </item>
  7507. <item>
  7508. Some operating systems have different <tt>kdch1</tt>
  7509. settings in their <tt>terminfo</tt> database for
  7510. <tt>xterm</tt> and others. On these systems the
  7511. <tt>Delete</tt> key will not work correctly when you
  7512. log in from a system conforming to our policy, but
  7513. <tt>&lt;--</tt> will.
  7514. </item>
  7515. </list>
  7516. </p>
  7517. </sect>
  7518. <sect>
  7519. <heading>Environment variables</heading>
  7520. <p>
  7521. A program must not depend on environment variables to get
  7522. reasonable defaults. (That's because these environment
  7523. variables would have to be set in a system-wide
  7524. configuration file like <file>/etc/profile</file>, which is not
  7525. supported by all shells.)
  7526. </p>
  7527. <p>
  7528. If a program usually depends on environment variables for its
  7529. configuration, the program should be changed to fall back to
  7530. a reasonable default configuration if these environment
  7531. variables are not present. If this cannot be done easily
  7532. (e.g., if the source code of a non-free program is not
  7533. available), the program must be replaced by a small
  7534. "wrapper" shell script which sets the environment variables
  7535. if they are not already defined, and calls the original program.
  7536. </p>
  7537. <p>
  7538. Here is an example of a wrapper script for this purpose:
  7539. <example compact="compact">
  7540. #!/bin/sh
  7541. BAR=${BAR:-/var/lib/fubar}
  7542. export BAR
  7543. exec /usr/lib/foo/foo "$@"
  7544. </example>
  7545. </p>
  7546. <p>
  7547. Furthermore, as <file>/etc/profile</file> is a configuration
  7548. file of the <prgn>base-files</prgn> package, other packages must
  7549. not put any environment variables or other commands into that
  7550. file.
  7551. </p>
  7552. </sect>
  7553. <sect id="doc-base">
  7554. <heading>Registering Documents using doc-base</heading>
  7555. <p>
  7556. The <package>doc-base</package> package implements a
  7557. flexible mechanism for handling and presenting
  7558. documentation. The recommended practice is for every Debian
  7559. package that provides online documentation (other than just
  7560. manual pages) to register these documents with
  7561. <package>doc-base</package> by installing a
  7562. <package>doc-base</package> control file in
  7563. <file>/usr/share/doc-base/</file>.
  7564. </p>
  7565. <p>
  7566. Please refer to the documentation that comes with the
  7567. <package>doc-base</package> package for information and
  7568. details.
  7569. </p>
  7570. </sect>
  7571. <sect id="alternateinit">
  7572. <heading>Alternate init systems</heading>
  7573. <p>
  7574. A number of other init systems are available now in Debian that
  7575. can be used in place of <package>sysvinit</package>. Alternative
  7576. init implementations must support running SysV init scripts as
  7577. described at <ref id="sysvinit"> for compatibility.
  7578. </p>
  7579. <p>
  7580. Packages may integrate with these replacement init systems by
  7581. providing implementation-specific configuration information about
  7582. how and when to start a service or in what order to run certain
  7583. tasks at boot time. However, any package integrating with other
  7584. init systems must also be backwards-compatible with
  7585. <package>sysvinit</package> by providing a SysV-style init script
  7586. with the same name as and equivalent functionality to any
  7587. init-specific job, as this is the only start-up configuration
  7588. method guaranteed to be supported by all init implementations. An
  7589. exception to this rule is scripts or jobs provided by the init
  7590. implementation itself; such jobs may be required for an
  7591. implementation-specific equivalent of the <file>/etc/rcS.d/</file>
  7592. scripts and may not have a one-to-one correspondence with the init
  7593. scripts.
  7594. </p>
  7595. <sect1 id="upstart">
  7596. <heading>Event-based boot with upstart</heading>
  7597. <p>
  7598. Packages may integrate with the <prgn>upstart</prgn> event-based
  7599. boot system by installing job files in the
  7600. <file>/etc/init</file> directory. SysV init scripts for which
  7601. an equivalent upstart job is available must query the output of
  7602. the command <prgn>initctl version</prgn> for the string
  7603. <tt>upstart</tt> and avoid running in favor of the native
  7604. upstart job, using a test such as this:
  7605. <example compact="compact">
  7606. if [ "$1" = start ] && which initctl >/dev/null && initctl version | grep -q upstart
  7607. then
  7608. exit 1
  7609. fi
  7610. </example>
  7611. </p>
  7612. <p>
  7613. Because packages shipping upstart jobs may be installed on
  7614. systems that are not using upstart, maintainer scripts must
  7615. still use the common <prgn>update-rc.d</prgn> and
  7616. <prgn>invoke-rc.d</prgn> interfaces for configuring runlevels
  7617. and for starting and stopping services. These maintainer
  7618. scripts must not call the upstart <prgn>start</prgn>,
  7619. <prgn>restart</prgn>, <prgn>reload</prgn>, or <prgn>stop</prgn>
  7620. interfaces directly. Instead, implementations of
  7621. <prgn>invoke-rc.d</prgn> must detect when upstart is running and
  7622. when an upstart job with the same name as an init script is
  7623. present, and perform the requested action using the upstart job
  7624. instead of the init script.
  7625. </p>
  7626. <p>
  7627. Dependency-based boot managers for SysV init scripts, such as
  7628. <prgn>startpar</prgn>, may avoid running a given init script
  7629. entirely when an equivalent upstart job is present, to avoid
  7630. unnecessary forking of no-op init scripts. In this case, the
  7631. boot manager should integrate with upstart to detect when the
  7632. upstart job in question is started or stopped to know when the
  7633. dependency has been satisfied.
  7634. </p>
  7635. </sect1>
  7636. </sect>
  7637. </chapt>
  7638. <chapt id="files">
  7639. <heading>Files</heading>
  7640. <sect id="binaries">
  7641. <heading>Binaries</heading>
  7642. <p>
  7643. Two different packages must not install programs with
  7644. different functionality but with the same filenames. (The
  7645. case of two programs having the same functionality but
  7646. different implementations is handled via "alternatives" or
  7647. the "Conflicts" mechanism. See <ref id="maintscripts"> and
  7648. <ref id="conflicts"> respectively.) If this case happens,
  7649. one of the programs must be renamed. The maintainers should
  7650. report this to the <tt>debian-devel</tt> mailing list and
  7651. try to find a consensus about which program will have to be
  7652. renamed. If a consensus cannot be reached, <em>both</em>
  7653. programs must be renamed.
  7654. </p>
  7655. <p>
  7656. Binary executables must not be statically linked with the GNU C
  7657. library, since this prevents the binary from benefiting from
  7658. fixes and improvements to the C library without being rebuilt
  7659. and complicates security updates. This requirement may be
  7660. relaxed for binary executables whose intended purpose is to
  7661. diagnose and fix the system in situations where the GNU C
  7662. library may not be usable (such as system recovery shells or
  7663. utilities like ldconfig) or for binary executables where the
  7664. security benefits of static linking outweigh the drawbacks.
  7665. </p>
  7666. <p>
  7667. By default, when a package is being built, any binaries
  7668. created should include debugging information, as well as
  7669. being compiled with optimization. You should also turn on
  7670. as many reasonable compilation warnings as possible; this
  7671. makes life easier for porters, who can then look at build
  7672. logs for possible problems. For the C programming language,
  7673. this means the following compilation parameters should be
  7674. used:
  7675. <example compact="compact">
  7676. CC = gcc
  7677. CFLAGS = -O2 -g -Wall # sane warning options vary between programs
  7678. LDFLAGS = # none
  7679. INSTALL = install -s # (or use strip on the files in debian/tmp)
  7680. </example>
  7681. </p>
  7682. <p>
  7683. Note that by default all installed binaries should be stripped,
  7684. either by using the <tt>-s</tt> flag to
  7685. <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
  7686. the binaries after they have been copied into
  7687. <file>debian/tmp</file> but before the tree is made into a
  7688. package.
  7689. </p>
  7690. <p>
  7691. Although binaries in the build tree should be compiled with
  7692. debugging information by default, it can often be difficult to
  7693. debug programs if they are also subjected to compiler
  7694. optimization. For this reason, it is recommended to support the
  7695. standardized environment variable <tt>DEB_BUILD_OPTIONS</tt>
  7696. (see <ref id="debianrules-options">). This variable can contain
  7697. several flags to change how a package is compiled and built.
  7698. </p>
  7699. <p>
  7700. It is up to the package maintainer to decide what
  7701. compilation options are best for the package. Certain
  7702. binaries (such as computationally-intensive programs) will
  7703. function better with certain flags (<tt>-O3</tt>, for
  7704. example); feel free to use them. Please use good judgment
  7705. here. Don't use flags for the sake of it; only use them
  7706. if there is good reason to do so. Feel free to override
  7707. the upstream author's ideas about which compilation
  7708. options are best: they are often inappropriate for our
  7709. environment.
  7710. </p>
  7711. </sect>
  7712. <sect id="libraries">
  7713. <heading>Libraries</heading>
  7714. <p>
  7715. If the package is <strong>architecture: any</strong>, then
  7716. the shared library compilation and linking flags must have
  7717. <tt>-fPIC</tt>, or the package shall not build on some of
  7718. the supported architectures<footnote>
  7719. <p>
  7720. If you are using GCC, <tt>-fPIC</tt> produces code with
  7721. relocatable position independent code, which is required for
  7722. most architectures to create a shared library, with i386 and
  7723. perhaps some others where non position independent code is
  7724. permitted in a shared library.
  7725. </p>
  7726. <p>
  7727. Position independent code may have a performance penalty,
  7728. especially on <tt>i386</tt>. However, in most cases the
  7729. speed penalty must be measured against the memory wasted on
  7730. the few architectures where non position independent code is
  7731. even possible.
  7732. </p>
  7733. </footnote>. Any exception to this rule must be discussed on
  7734. the mailing list <em>debian-devel@lists.debian.org</em>, and
  7735. a rough consensus obtained. The reasons for not compiling
  7736. with <tt>-fPIC</tt> flag must be recorded in the file
  7737. <tt>README.Debian</tt>, and care must be taken to either
  7738. restrict the architecture or arrange for <tt>-fPIC</tt> to
  7739. be used on architectures where it is required.<footnote>
  7740. <p>
  7741. Some of the reasons why this might be required is if the
  7742. library contains hand crafted assembly code that is not
  7743. relocatable, the speed penalty is excessive for compute
  7744. intensive libs, and similar reasons.
  7745. </p>
  7746. </footnote>
  7747. </p>
  7748. <p>
  7749. As to the static libraries, the common case is not to have
  7750. relocatable code, since there is no benefit, unless in specific
  7751. cases; therefore the static version must not be compiled
  7752. with the <tt>-fPIC</tt> flag. Any exception to this rule
  7753. should be discussed on the mailing list
  7754. <em>debian-devel@lists.debian.org</em>, and the reasons for
  7755. compiling with the <tt>-fPIC</tt> flag must be recorded in
  7756. the file <tt>README.Debian</tt>. <footnote>
  7757. <p>
  7758. Some of the reasons for linking static libraries with
  7759. the <tt>-fPIC</tt> flag are if, for example, one needs a
  7760. Perl API for a library that is under rapid development,
  7761. and has an unstable API, so shared libraries are
  7762. pointless at this phase of the library's development. In
  7763. that case, since Perl needs a library with relocatable
  7764. code, it may make sense to create a static library with
  7765. relocatable code. Another reason cited is if you are
  7766. distilling various libraries into a common shared
  7767. library, like <tt>mklibs</tt> does in the Debian
  7768. installer project.
  7769. </p>
  7770. </footnote>
  7771. </p>
  7772. <p>
  7773. In other words, if both a shared and a static library is
  7774. being built, each source unit (<tt>*.c</tt>, for example,
  7775. for C files) will need to be compiled twice, for the normal
  7776. case.
  7777. </p>
  7778. <p>
  7779. Libraries should be built with threading support and to be
  7780. thread-safe if the library supports this.
  7781. </p>
  7782. <p>
  7783. Although not enforced by the build tools, shared libraries
  7784. must be linked against all libraries that they use symbols from
  7785. in the same way that binaries are. This ensures the correct
  7786. functioning of the <qref id="sharedlibs-symbols">symbols</qref>
  7787. and <qref id="sharedlibs-shlibdeps">shlibs</qref>
  7788. systems and guarantees that all libraries can be safely opened
  7789. with <tt>dlopen()</tt>. Packagers may wish to use the gcc
  7790. option <tt>-Wl,-z,defs</tt> when building a shared library.
  7791. Since this option enforces symbol resolution at build time,
  7792. a missing library reference will be caught early as a fatal
  7793. build error.
  7794. </p>
  7795. <p>
  7796. All installed shared libraries should be stripped with
  7797. <example compact="compact">
  7798. strip --strip-unneeded <var>your-lib</var>
  7799. </example>
  7800. (The option <tt>--strip-unneeded</tt> makes
  7801. <prgn>strip</prgn> remove only the symbols which aren't
  7802. needed for relocation processing.) Shared libraries can
  7803. function perfectly well when stripped, since the symbols for
  7804. dynamic linking are in a separate part of the ELF object
  7805. file.<footnote>
  7806. You might also want to use the options
  7807. <tt>--remove-section=.comment</tt> and
  7808. <tt>--remove-section=.note</tt> on both shared libraries
  7809. and executables, and <tt>--strip-debug</tt> on static
  7810. libraries.
  7811. </footnote>
  7812. </p>
  7813. <p>
  7814. Note that under some circumstances it may be useful to
  7815. install a shared library unstripped, for example when
  7816. building a separate package to support debugging.
  7817. </p>
  7818. <p>
  7819. Shared object files (often <file>.so</file> files) that are not
  7820. public libraries, that is, they are not meant to be linked
  7821. to by third party executables (binaries of other packages),
  7822. should be installed in subdirectories of the
  7823. <file>/usr/lib</file> directory. Such files are exempt from the
  7824. rules that govern ordinary shared libraries, except that
  7825. they must not be installed executable and should be
  7826. stripped.<footnote>
  7827. A common example are the so-called "plug-ins",
  7828. internal shared objects that are dynamically loaded by
  7829. programs using <manref name="dlopen" section="3">.
  7830. </footnote>
  7831. </p>
  7832. <p>
  7833. Packages that use <prgn>libtool</prgn> to create and install
  7834. their shared libraries install a file containing additional
  7835. metadata (ending in <file>.la</file>) alongside the library.
  7836. For public libraries intended for use by other packages, these
  7837. files normally should not be included in the Debian package,
  7838. since the information they include is not necessary to link with
  7839. the shared library on Debian and can add unnecessary additional
  7840. dependencies to other programs or libraries.<footnote>
  7841. These files store, among other things, all libraries on which
  7842. that shared library depends. Unfortunately, if
  7843. the <file>.la</file> file is present and contains that
  7844. dependency information, using <prgn>libtool</prgn> when
  7845. linking against that library will cause the resulting program
  7846. or library to be linked against those dependencies as well,
  7847. even if this is unnecessary. This can create unneeded
  7848. dependencies on shared library packages that would otherwise
  7849. be hidden behind the library ABI, and can make library
  7850. transitions to new SONAMEs unnecessarily complicated and
  7851. difficult to manage.
  7852. </footnote>
  7853. If the <file>.la</file> file is required for that library (if,
  7854. for instance, it's loaded via <tt>libltdl</tt> in a way that
  7855. requires that meta-information), the <tt>dependency_libs</tt>
  7856. setting in the <file>.la</file> file should normally be set to
  7857. the empty string. If the shared library development package has
  7858. historically included the <file>.la</file>, it must be retained
  7859. in the development package (with <tt>dependency_libs</tt>
  7860. emptied) until all libraries that depend on it have removed or
  7861. emptied <tt>dependency_libs</tt> in their <file>.la</file>
  7862. files to prevent linking with those other libraries
  7863. using <prgn>libtool</prgn> from failing.
  7864. </p>
  7865. <p>
  7866. If the <file>.la</file> must be included, it should be included
  7867. in the development (<tt>-dev</tt>) package, unless the library
  7868. will be loaded by <prgn>libtool</prgn>'s <tt>libltdl</tt>
  7869. library. If it is intended for use with <tt>libltdl</tt>,
  7870. the <file>.la</file> files must go in the run-time library
  7871. package.
  7872. </p>
  7873. <p>
  7874. These requirements for handling of <file>.la</file> files do not
  7875. apply to loadable modules or libraries not installed in
  7876. directories searched by default by the dynamic linker. Packages
  7877. installing loadable modules will frequently need to install
  7878. the <file>.la</file> files alongside the modules so that they
  7879. can be loaded by <tt>libltdl</tt>. <tt>dependency_libs</tt>
  7880. does not need to be modified for libraries or modules that are
  7881. not installed in directories searched by the dynamic linker by
  7882. default and not intended for use by other packages.
  7883. </p>
  7884. <p>
  7885. You must make sure that you use only released versions of
  7886. shared libraries to build your packages; otherwise other
  7887. users will not be able to run your binaries
  7888. properly. Producing source packages that depend on
  7889. unreleased compilers is also usually a bad
  7890. idea.
  7891. </p>
  7892. </sect>
  7893. <sect>
  7894. <heading>Shared libraries</heading>
  7895. <p>
  7896. This section has moved to <ref id="sharedlibs">.
  7897. </p>
  7898. </sect>
  7899. <sect id="scripts">
  7900. <heading>Scripts</heading>
  7901. <p>
  7902. All command scripts, including the package maintainer
  7903. scripts inside the package and used by <prgn>dpkg</prgn>,
  7904. should have a <tt>#!</tt> line naming the shell to be used
  7905. to interpret them.
  7906. </p>
  7907. <p>
  7908. In the case of Perl scripts this should be
  7909. <tt>#!/usr/bin/perl</tt>.
  7910. </p>
  7911. <p>
  7912. When scripts are installed into a directory in the system
  7913. PATH, the script name should not include an extension such
  7914. as <tt>.sh</tt> or <tt>.pl</tt> that denotes the scripting
  7915. language currently used to implement it.
  7916. </p>
  7917. <p>
  7918. Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>) other than
  7919. <file>init.d</file> scripts should almost certainly start
  7920. with <tt>set -e</tt> so that errors are detected.
  7921. <file>init.d</file> scripts are something of a special case, due
  7922. to how frequently they need to call commands that are allowed to
  7923. fail, and it may instead be easier to check the exit status of
  7924. commands directly. See <ref id="writing-init"> for more
  7925. information about writing <file>init.d</file> scripts.
  7926. </p>
  7927. <p>
  7928. Every script should use <tt>set -e</tt> or check the exit status
  7929. of <em>every</em> command.
  7930. </p>
  7931. <p>
  7932. Scripts may assume that <file>/bin/sh</file> implements the
  7933. SUSv3 Shell Command Language<footnote>
  7934. Single UNIX Specification, version 3, which is also IEEE
  7935. 1003.1-2004 (POSIX), and is available on the World Wide Web
  7936. from <url id="http://www.unix.org/version3/online.html"
  7937. name="The Open Group"> after free
  7938. registration.</footnote>
  7939. plus the following additional features not mandated by
  7940. SUSv3:<footnote>
  7941. These features are in widespread use in the Linux community
  7942. and are implemented in all of bash, dash, and ksh, the most
  7943. common shells users may wish to use as <file>/bin/sh</file>.
  7944. </footnote>
  7945. <list>
  7946. <item><tt>echo -n</tt>, if implemented as a shell built-in,
  7947. must not generate a newline.</item>
  7948. <item><tt>test</tt>, if implemented as a shell built-in, must
  7949. support <tt>-a</tt> and <tt>-o</tt> as binary logical
  7950. operators.</item>
  7951. <item><tt>local</tt> to create a scoped variable must be
  7952. supported, including listing multiple variables in a single
  7953. local command and assigning a value to a variable at the
  7954. same time as localizing it. <tt>local</tt> may or
  7955. may not preserve the variable value from an outer scope if
  7956. no assignment is present. Uses such as:
  7957. <example compact>
  7958. fname () {
  7959. local a b c=delta d
  7960. # ... use a, b, c, d ...
  7961. }
  7962. </example>
  7963. must be supported and must set the value of <tt>c</tt> to
  7964. <tt>delta</tt>.
  7965. </item>
  7966. <item>The XSI extension to <prgn>kill</prgn> allowing <tt>kill
  7967. -<var>signal</var></tt>, where <var>signal</var> is either
  7968. the name of a signal or one of the numeric signals listed in
  7969. the XSI extension (0, 1, 2, 3, 6, 9, 14, and 15), must be
  7970. supported if <prgn>kill</prgn> is implemented as a shell
  7971. built-in.
  7972. </item>
  7973. <item>The XSI extension to <prgn>trap</prgn> allowing numeric
  7974. signals must be supported. In addition to the signal
  7975. numbers listed in the extension, which are the same as for
  7976. <prgn>kill</prgn> above, 13 (SIGPIPE) must be allowed.
  7977. </item>
  7978. </list>
  7979. If a shell script requires non-SUSv3 features from the shell
  7980. interpreter other than those listed above, the appropriate shell
  7981. must be specified in the first line of the script (e.g.,
  7982. <tt>#!/bin/bash</tt>) and the package must depend on the package
  7983. providing the shell (unless the shell package is marked
  7984. "Essential", as in the case of <prgn>bash</prgn>).
  7985. </p>
  7986. <p>
  7987. You may wish to restrict your script to SUSv3 features plus the
  7988. above set when possible so that it may use <file>/bin/sh</file>
  7989. as its interpreter. Checking your script
  7990. with <prgn>checkbashisms</prgn> from
  7991. the <package>devscripts</package> package or running your script
  7992. with an alternate shell such as <prgn>posh</prgn> may help
  7993. uncover violations of the above requirements. If in doubt
  7994. whether a script complies with these requirements,
  7995. use <file>/bin/bash</file>.
  7996. </p>
  7997. <p>
  7998. Perl scripts should check for errors when making any
  7999. system calls, including <tt>open</tt>, <tt>print</tt>,
  8000. <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
  8001. </p>
  8002. <p>
  8003. <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
  8004. scripting languages. See <em>Csh Programming Considered
  8005. Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
  8006. can be found at <url id="http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/">.
  8007. If an upstream package comes with <prgn>csh</prgn> scripts
  8008. then you must make sure that they start with
  8009. <tt>#!/bin/csh</tt> and make your package depend on the
  8010. <prgn>c-shell</prgn> virtual package.
  8011. </p>
  8012. <p>
  8013. Any scripts which create files in world-writeable
  8014. directories (e.g., in <file>/tmp</file>) must use a
  8015. mechanism which will fail atomically if a file with the same
  8016. name already exists.
  8017. </p>
  8018. <p>
  8019. The Debian base system provides the <prgn>tempfile</prgn>
  8020. and <prgn>mktemp</prgn> utilities for use by scripts for
  8021. this purpose.
  8022. </p>
  8023. </sect>
  8024. <sect>
  8025. <heading>Symbolic links</heading>
  8026. <p>
  8027. In general, symbolic links within a top-level directory should
  8028. be relative, and symbolic links pointing from one top-level
  8029. directory to or into another should be absolute. (A top-level
  8030. directory is a sub-directory of the root
  8031. directory <file>/</file>.) For example, a symbolic link
  8032. from <file>/usr/lib/foo</file> to <file>/usr/share/bar</file>
  8033. should be relative (<file>../share/bar</file>), but a symbolic
  8034. link from <file>/var/run</file> to <file>/run</file> should be
  8035. absolute.<footnote>
  8036. This is necessary to allow top-level directories to be
  8037. symlinks. If linking <file>/var/run</file>
  8038. to <file>/run</file> were done with the relative symbolic
  8039. link <file>../run</file>, but <file>/var</file> were a
  8040. symbolic link to <file>/srv/disk1</file>, the symbolic link
  8041. would point to <file>/srv/run</file> rather than the intended
  8042. target.
  8043. </footnote>
  8044. Symbolic links must not traverse above the root directory.
  8045. </p>
  8046. <p>
  8047. In addition, symbolic links should be specified as short as
  8048. possible, i.e., link targets like <file>foo/../bar</file> are
  8049. deprecated.
  8050. </p>
  8051. <p>
  8052. Note that when creating a relative link using
  8053. <prgn>ln</prgn> it is not necessary for the target of the
  8054. link to exist relative to the working directory you're
  8055. running <prgn>ln</prgn> from, nor is it necessary to change
  8056. directory to the directory where the link is to be made.
  8057. Simply include the string that should appear as the target
  8058. of the link (this will be a pathname relative to the
  8059. directory in which the link resides) as the first argument
  8060. to <prgn>ln</prgn>.
  8061. </p>
  8062. <p>
  8063. For example, in your <prgn>Makefile</prgn> or
  8064. <file>debian/rules</file>, you can do things like:
  8065. <example compact="compact">
  8066. ln -fs gcc $(prefix)/bin/cc
  8067. ln -fs gcc debian/tmp/usr/bin/cc
  8068. ln -fs ../sbin/sendmail $(prefix)/bin/runq
  8069. ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
  8070. </example>
  8071. </p>
  8072. <p>
  8073. A symbolic link pointing to a compressed file (in the sense
  8074. that it is meant to be uncompressed with <prgn>unzip</prgn>
  8075. or <prgn>zless</prgn> etc.) should always
  8076. have the same file extension as the referenced file. (For
  8077. example, if a file <file>foo.gz</file> is referenced by a
  8078. symbolic link, the filename of the link has to end with
  8079. "<file>.gz</file>" too, as in <file>bar.gz</file>.)
  8080. </p>
  8081. </sect>
  8082. <sect>
  8083. <heading>Device files</heading>
  8084. <p>
  8085. Packages must not include device files or named pipes in the
  8086. package file tree.
  8087. </p>
  8088. <p>
  8089. If a package needs any special device files that are not
  8090. included in the base system, it must call
  8091. <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
  8092. after notifying the user<footnote>
  8093. This notification could be done via a (low-priority)
  8094. debconf message, or an echo (printf) statement.
  8095. </footnote>.
  8096. </p>
  8097. <p>
  8098. Packages must not remove any device files in the
  8099. <prgn>postrm</prgn> or any other script. This is left to the
  8100. system administrator.
  8101. </p>
  8102. <p>
  8103. Debian uses the serial devices
  8104. <file>/dev/ttyS*</file>. Programs using the old
  8105. <file>/dev/cu*</file> devices should be changed to use
  8106. <file>/dev/ttyS*</file>.
  8107. </p>
  8108. <p>
  8109. Named pipes needed by the package must be created in
  8110. the <prgn>postinst</prgn> script<footnote>
  8111. It's better to use <prgn>mkfifo</prgn> rather
  8112. than <prgn>mknod</prgn> to create named pipes so that
  8113. automated checks for packages incorrectly creating device
  8114. files with <prgn>mknod</prgn> won't have false positives.
  8115. </footnote> and removed in
  8116. the <prgn>prerm</prgn> or <prgn>postrm</prgn> script as
  8117. appropriate.
  8118. </p>
  8119. </sect>
  8120. <sect id="config-files">
  8121. <heading>Configuration files</heading>
  8122. <sect1>
  8123. <heading>Definitions</heading>
  8124. <p>
  8125. <taglist>
  8126. <tag>configuration file</tag>
  8127. <item>
  8128. A file that affects the operation of a program, or
  8129. provides site- or host-specific information, or
  8130. otherwise customizes the behavior of a program.
  8131. Typically, configuration files are intended to be
  8132. modified by the system administrator (if needed or
  8133. desired) to conform to local policy or to provide
  8134. more useful site-specific behavior.
  8135. </item>
  8136. <tag><tt>conffile</tt></tag>
  8137. <item>
  8138. A file listed in a package's <tt>conffiles</tt>
  8139. file, and is treated specially by <prgn>dpkg</prgn>
  8140. (see <ref id="configdetails">).
  8141. </item>
  8142. </taglist>
  8143. </p>
  8144. <p>
  8145. The distinction between these two is important; they are
  8146. not interchangeable concepts. Almost all
  8147. <tt>conffile</tt>s are configuration files, but many
  8148. configuration files are not <tt>conffiles</tt>.
  8149. </p>
  8150. <p>
  8151. As noted elsewhere, <file>/etc/init.d</file> scripts,
  8152. <file>/etc/default</file> files, scripts installed in
  8153. <file>/etc/cron.{hourly,daily,weekly,monthly}</file>, and cron
  8154. configuration installed in <file>/etc/cron.d</file> must be
  8155. treated as configuration files. In general, any script that
  8156. embeds configuration information is de-facto a configuration
  8157. file and should be treated as such.
  8158. </p>
  8159. </sect1>
  8160. <sect1>
  8161. <heading>Location</heading>
  8162. <p>
  8163. Any configuration files created or used by your package
  8164. must reside in <file>/etc</file>. If there are several,
  8165. consider creating a subdirectory of <file>/etc</file>
  8166. named after your package.
  8167. </p>
  8168. <p>
  8169. If your package creates or uses configuration files
  8170. outside of <file>/etc</file>, and it is not feasible to modify
  8171. the package to use <file>/etc</file> directly, put the files
  8172. in <file>/etc</file> and create symbolic links to those files
  8173. from the location that the package requires.
  8174. </p>
  8175. </sect1>
  8176. <sect1>
  8177. <heading>Behavior</heading>
  8178. <p>
  8179. Configuration file handling must conform to the following
  8180. behavior:
  8181. <list compact="compact">
  8182. <item>
  8183. local changes must be preserved during a package
  8184. upgrade, and
  8185. </item>
  8186. <item>
  8187. configuration files must be preserved when the
  8188. package is removed, and only deleted when the
  8189. package is purged.
  8190. </item>
  8191. </list>
  8192. Obsolete configuration files without local changes should be
  8193. removed by the package during upgrade.<footnote>
  8194. The <prgn>dpkg-maintscript-helper</prgn> tool, available from the
  8195. <package>dpkg</package> package, can help for this task.</footnote>
  8196. </p>
  8197. <p>
  8198. The easy way to achieve this behavior is to make the
  8199. configuration file a <tt>conffile</tt>. This is
  8200. appropriate only if it is possible to distribute a default
  8201. version that will work for most installations, although
  8202. some system administrators may choose to modify it. This
  8203. implies that the default version will be part of the
  8204. package distribution, and must not be modified by the
  8205. maintainer scripts during installation (or at any other
  8206. time).
  8207. </p>
  8208. <p>
  8209. In order to ensure that local changes are preserved
  8210. correctly, no package may contain or make hard links to
  8211. conffiles.<footnote>
  8212. Rationale: There are two problems with hard links.
  8213. The first is that some editors break the link while
  8214. editing one of the files, so that the two files may
  8215. unwittingly become unlinked and different. The second
  8216. is that <prgn>dpkg</prgn> might break the hard link
  8217. while upgrading <tt>conffile</tt>s.
  8218. </footnote>
  8219. </p>
  8220. <p>
  8221. The other way to do it is via the maintainer scripts. In
  8222. this case, the configuration file must not be listed as a
  8223. <tt>conffile</tt> and must not be part of the package
  8224. distribution. If the existence of a file is required for
  8225. the package to be sensibly configured it is the
  8226. responsibility of the package maintainer to provide
  8227. maintainer scripts which correctly create, update and
  8228. maintain the file and remove it on purge. (See <ref
  8229. id="maintainerscripts"> for more information.) These
  8230. scripts must be idempotent (i.e., must work correctly if
  8231. <prgn>dpkg</prgn> needs to re-run them due to errors
  8232. during installation or removal), must cope with all the
  8233. variety of ways <prgn>dpkg</prgn> can call maintainer
  8234. scripts, must not overwrite or otherwise mangle the user's
  8235. configuration without asking, must not ask unnecessary
  8236. questions (particularly during upgrades), and must
  8237. otherwise be good citizens.
  8238. </p>
  8239. <p>
  8240. The scripts are not required to configure every possible
  8241. option for the package, but only those necessary to get
  8242. the package running on a given system. Ideally the
  8243. sysadmin should not have to do any configuration other
  8244. than that done (semi-)automatically by the
  8245. <prgn>postinst</prgn> script.
  8246. </p>
  8247. <p>
  8248. A common practice is to create a script called
  8249. <file><var>package</var>-configure</file> and have the
  8250. package's <prgn>postinst</prgn> call it if and only if the
  8251. configuration file does not already exist. In certain
  8252. cases it is useful for there to be an example or template
  8253. file which the maintainer scripts use. Such files should
  8254. be in <file>/usr/share/<var>package</var></file> or
  8255. <file>/usr/lib/<var>package</var></file> (depending on whether
  8256. they are architecture-independent or not). There should
  8257. be symbolic links to them from
  8258. <file>/usr/share/doc/<var>package</var>/examples</file> if
  8259. they are examples, and should be perfectly ordinary
  8260. <prgn>dpkg</prgn>-handled files (<em>not</em>
  8261. configuration files).
  8262. </p>
  8263. <p>
  8264. These two styles of configuration file handling must
  8265. not be mixed, for that way lies madness:
  8266. <prgn>dpkg</prgn> will ask about overwriting the file
  8267. every time the package is upgraded.
  8268. </p>
  8269. </sect1>
  8270. <sect1>
  8271. <heading>Sharing configuration files</heading>
  8272. <p>
  8273. If two or more packages use the same configuration file
  8274. and it is reasonable for both to be installed at the same
  8275. time, one of these packages must be defined as
  8276. <em>owner</em> of the configuration file, i.e., it will be
  8277. the package which handles that file as a configuration
  8278. file. Other packages that use the configuration file must
  8279. depend on the owning package if they require the
  8280. configuration file to operate. If the other package will
  8281. use the configuration file if present, but is capable of
  8282. operating without it, no dependency need be declared.
  8283. </p>
  8284. <p>
  8285. If it is desirable for two or more related packages to
  8286. share a configuration file <em>and</em> for all of the
  8287. related packages to be able to modify that configuration
  8288. file, then the following should be done:
  8289. <enumlist compact="compact">
  8290. <item>
  8291. One of the related packages (the "owning" package)
  8292. will manage the configuration file with maintainer
  8293. scripts as described in the previous section.
  8294. </item>
  8295. <item>
  8296. The owning package should also provide a program
  8297. that the other packages may use to modify the
  8298. configuration file.
  8299. </item>
  8300. <item>
  8301. The related packages must use the provided program
  8302. to make any desired modifications to the
  8303. configuration file. They should either depend on
  8304. the core package to guarantee that the configuration
  8305. modifier program is available or accept gracefully
  8306. that they cannot modify the configuration file if it
  8307. is not. (This is in addition to the fact that the
  8308. configuration file may not even be present in the
  8309. latter scenario.)
  8310. </item>
  8311. </enumlist>
  8312. </p>
  8313. <p>
  8314. Sometimes it's appropriate to create a new package which
  8315. provides the basic infrastructure for the other packages
  8316. and which manages the shared configuration files. (The
  8317. <tt>sgml-base</tt> package is a good example.)
  8318. </p>
  8319. <p>
  8320. If the configuration file cannot be shared as described above,
  8321. the packages must be marked as conflicting with each other.
  8322. Two packages that specify the same file as
  8323. a <tt>conffile</tt> must conflict. This is an instance of the
  8324. general rule about not sharing files. Neither alternatives
  8325. nor diversions are likely to be appropriate in this case; in
  8326. particular, <prgn>dpkg</prgn> does not handle diverted
  8327. <tt>conffile</tt>s well.
  8328. </p>
  8329. <p>
  8330. When two packages both declare the same <tt>conffile</tt>, they
  8331. may see left-over configuration files from each other even
  8332. though they conflict with each other. If a user removes
  8333. (without purging) one of the packages and installs the other,
  8334. the new package will take over the <tt>conffile</tt> from the
  8335. old package. If the file was modified by the user, it will be
  8336. treated the same as any other locally
  8337. modified <tt>conffile</tt> during an upgrade.
  8338. </p>
  8339. <p>
  8340. The maintainer scripts must not alter a <tt>conffile</tt>
  8341. of <em>any</em> package, including the one the scripts
  8342. belong to.
  8343. </p>
  8344. </sect1>
  8345. <sect1>
  8346. <heading>User configuration files ("dotfiles")</heading>
  8347. <p>
  8348. The files in <file>/etc/skel</file> will automatically be
  8349. copied into new user accounts by <prgn>adduser</prgn>.
  8350. No other program should reference the files in
  8351. <file>/etc/skel</file>.
  8352. </p>
  8353. <p>
  8354. Therefore, if a program needs a dotfile to exist in
  8355. advance in <file>$HOME</file> to work sensibly, that dotfile
  8356. should be installed in <file>/etc/skel</file> and treated as a
  8357. configuration file.
  8358. </p>
  8359. <p>
  8360. However, programs that require dotfiles in order to
  8361. operate sensibly are a bad thing, unless they do create
  8362. the dotfiles themselves automatically.
  8363. </p>
  8364. <p>
  8365. Furthermore, programs should be configured by the Debian
  8366. default installation to behave as closely to the upstream
  8367. default behavior as possible.
  8368. </p>
  8369. <p>
  8370. Therefore, if a program in a Debian package needs to be
  8371. configured in some way in order to operate sensibly, that
  8372. should be done using a site-wide configuration file placed
  8373. in <file>/etc</file>. Only if the program doesn't support a
  8374. site-wide default configuration and the package maintainer
  8375. doesn't have time to add it may a default per-user file be
  8376. placed in <file>/etc/skel</file>.
  8377. </p>
  8378. <p>
  8379. <file>/etc/skel</file> should be as empty as we can make it.
  8380. This is particularly true because there is no easy (or
  8381. necessarily desirable) mechanism for ensuring that the
  8382. appropriate dotfiles are copied into the accounts of
  8383. existing users when a package is installed.
  8384. </p>
  8385. </sect1>
  8386. </sect>
  8387. <sect>
  8388. <heading>Log files</heading>
  8389. <p>
  8390. Log files should usually be named
  8391. <file>/var/log/<var>package</var>.log</file>. If you have many
  8392. log files, or need a separate directory for permission
  8393. reasons (<file>/var/log</file> is writable only by
  8394. <file>root</file>), you should usually create a directory named
  8395. <file>/var/log/<var>package</var></file> and place your log
  8396. files there.
  8397. </p>
  8398. <p>
  8399. Log files must be rotated occasionally so that they don't grow
  8400. indefinitely. The best way to do this is to install a log
  8401. rotation configuration file in the
  8402. directory <file>/etc/logrotate.d</file>, normally
  8403. named <file>/etc/logrotate.d/<var>package</var></file>, and use
  8404. the facilities provided by <prgn>logrotate</prgn>.
  8405. <footnote>
  8406. <p>
  8407. The traditional approach to log files has been to set up
  8408. <em>ad hoc</em> log rotation schemes using simple shell
  8409. scripts and cron. While this approach is highly
  8410. customizable, it requires quite a lot of sysadmin work.
  8411. Even though the original Debian system helped a little
  8412. by automatically installing a system which can be used
  8413. as a template, this was deemed not enough.
  8414. </p>
  8415. <p>
  8416. The use of <prgn>logrotate</prgn>, a program developed
  8417. by Red Hat, is better, as it centralizes log management.
  8418. It has both a configuration file
  8419. (<file>/etc/logrotate.conf</file>) and a directory where
  8420. packages can drop their individual log rotation
  8421. configurations (<file>/etc/logrotate.d</file>).
  8422. </p>
  8423. </footnote>
  8424. Here is a good example for a logrotate config
  8425. file (for more information see <manref name="logrotate"
  8426. section="8">):
  8427. <example compact="compact">
  8428. /var/log/foo/*.log {
  8429. rotate 12
  8430. weekly
  8431. compress
  8432. missingok
  8433. postrotate
  8434. start-stop-daemon -K -p /var/run/foo.pid -s HUP -x /usr/sbin/foo -q
  8435. endscript
  8436. }
  8437. </example>
  8438. This rotates all files under <file>/var/log/foo</file>, saves 12
  8439. compressed generations, and tells the daemon to reopen its log
  8440. files after the log rotation. It skips this log rotation
  8441. (via <tt>missingok</tt>) if no such log file is present, which
  8442. avoids errors if the package is removed but not purged.
  8443. </p>
  8444. <p>
  8445. Log files should be removed when the package is
  8446. purged (but not when it is only removed). This should be
  8447. done by the <prgn>postrm</prgn> script when it is called
  8448. with the argument <tt>purge</tt> (see <ref
  8449. id="removedetails">).
  8450. </p>
  8451. </sect>
  8452. <sect id="permissions-owners">
  8453. <heading>Permissions and owners</heading>
  8454. <p>
  8455. The rules in this section are guidelines for general use.
  8456. If necessary you may deviate from the details below.
  8457. However, if you do so you must make sure that what is done
  8458. is secure and you should try to be as consistent as possible
  8459. with the rest of the system. You should probably also
  8460. discuss it on <prgn>debian-devel</prgn> first.
  8461. </p>
  8462. <p>
  8463. Files should be owned by <tt>root:root</tt>, and made
  8464. writable only by the owner and universally readable (and
  8465. executable, if appropriate), that is mode 644 or 755.
  8466. </p>
  8467. <p>
  8468. Directories should be mode 755 or (for group-writability)
  8469. mode 2775. The ownership of the directory should be
  8470. consistent with its mode: if a directory is mode 2775, it
  8471. should be owned by the group that needs write access to
  8472. it.<footnote>
  8473. <p>
  8474. When a package is upgraded, and the owner or permissions
  8475. of a file included in the package has changed, dpkg
  8476. arranges for the ownership and permissions to be
  8477. correctly set upon installation. However, this does not
  8478. extend to directories; the permissions and ownership of
  8479. directories already on the system does not change on
  8480. install or upgrade of packages. This makes sense, since
  8481. otherwise common directories like <tt>/usr</tt> would
  8482. always be in flux. To correctly change permissions of a
  8483. directory the package owns, explicit action is required,
  8484. usually in the <tt>postinst</tt> script. Care must be
  8485. taken to handle downgrades as well, in that case.
  8486. </p>
  8487. </footnote>
  8488. </p>
  8489. <p>
  8490. Control information files should be owned by <tt>root:root</tt>
  8491. and either mode 644 (for most files) or mode 755 (for
  8492. executables such as <qref id="maintscripts">maintainer
  8493. scripts</qref>).
  8494. </p>
  8495. <p>
  8496. Setuid and setgid executables should be mode 4755 or 2755
  8497. respectively, and owned by the appropriate user or group.
  8498. They should not be made unreadable (modes like 4711 or
  8499. 2711 or even 4111); doing so achieves no extra security,
  8500. because anyone can find the binary in the freely available
  8501. Debian package; it is merely inconvenient. For the same
  8502. reason you should not restrict read or execute permissions
  8503. on non-set-id executables.
  8504. </p>
  8505. <p>
  8506. Some setuid programs need to be restricted to particular
  8507. sets of users, using file permissions. In this case they
  8508. should be owned by the uid to which they are set-id, and by
  8509. the group which should be allowed to execute them. They
  8510. should have mode 4754; again there is no point in making
  8511. them unreadable to those users who must not be allowed to
  8512. execute them.
  8513. </p>
  8514. <p>
  8515. It is possible to arrange that the system administrator can
  8516. reconfigure the package to correspond to their local
  8517. security policy by changing the permissions on a binary:
  8518. they can do this by using <prgn>dpkg-statoverride</prgn>, as
  8519. described below.<footnote>
  8520. Ordinary files installed by <prgn>dpkg</prgn> (as
  8521. opposed to <tt>conffile</tt>s and other similar objects)
  8522. normally have their permissions reset to the distributed
  8523. permissions when the package is reinstalled. However,
  8524. the use of <prgn>dpkg-statoverride</prgn> overrides this
  8525. default behavior.
  8526. </footnote>
  8527. Another method you should consider is to create a group for
  8528. people allowed to use the program(s) and make any setuid
  8529. executables executable only by that group.
  8530. </p>
  8531. <p>
  8532. If you need to create a new user or group for your package
  8533. there are two possibilities. Firstly, you may need to
  8534. make some files in the binary package be owned by this
  8535. user or group, or you may need to compile the user or
  8536. group id (rather than just the name) into the binary
  8537. (though this latter should be avoided if possible, as in
  8538. this case you need a statically allocated id).</p>
  8539. <p>
  8540. If you need a statically allocated id, you must ask for a
  8541. user or group id from the <tt>base-passwd</tt> maintainer,
  8542. and must not release the package until you have been
  8543. allocated one. Once you have been allocated one you must
  8544. either make the package depend on a version of the
  8545. <tt>base-passwd</tt> package with the id present in
  8546. <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
  8547. your package to create the user or group itself with the
  8548. correct id (using <tt>adduser</tt>) in its
  8549. <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
  8550. the <prgn>postinst</prgn> is to be preferred if it is
  8551. possible, otherwise a pre-dependency will be needed on the
  8552. <tt>adduser</tt> package.)
  8553. </p>
  8554. <p>
  8555. On the other hand, the program might be able to determine
  8556. the uid or gid from the user or group name at runtime, so
  8557. that a dynamically allocated id can be used. In this case
  8558. you should choose an appropriate user or group name,
  8559. discussing this on <prgn>debian-devel</prgn> and checking
  8560. with the <package/base-passwd/ maintainer that it is unique and that
  8561. they do not wish you to use a statically allocated id
  8562. instead. When this has been checked you must arrange for
  8563. your package to create the user or group if necessary using
  8564. <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
  8565. <prgn>postinst</prgn> script (again, the latter is to be
  8566. preferred if it is possible).
  8567. </p>
  8568. <p>
  8569. Note that changing the numeric value of an id associated
  8570. with a name is very difficult, and involves searching the
  8571. file system for all appropriate files. You need to think
  8572. carefully whether a static or dynamic id is required, since
  8573. changing your mind later will cause problems.
  8574. </p>
  8575. <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
  8576. <p>
  8577. This section is not intended as policy, but as a
  8578. description of the use of <prgn>dpkg-statoverride</prgn>.
  8579. </p>
  8580. <p>
  8581. If a system administrator wishes to have a file (or
  8582. directory or other such thing) installed with owner and
  8583. permissions different from those in the distributed Debian
  8584. package, they can use the <prgn>dpkg-statoverride</prgn>
  8585. program to instruct <prgn>dpkg</prgn> to use the different
  8586. settings every time the file is installed. Thus the
  8587. package maintainer should distribute the files with their
  8588. normal permissions, and leave it for the system
  8589. administrator to make any desired changes. For example, a
  8590. daemon which is normally required to be setuid root, but
  8591. in certain situations could be used without being setuid,
  8592. should be installed setuid in the <tt>.deb</tt>. Then the
  8593. local system administrator can change this if they wish.
  8594. If there are two standard ways of doing it, the package
  8595. maintainer can use <tt>debconf</tt> to find out the
  8596. preference, and call <prgn>dpkg-statoverride</prgn> in the
  8597. maintainer script if necessary to accommodate the system
  8598. administrator's choice. Care must be taken during
  8599. upgrades to not override an existing setting.
  8600. </p>
  8601. <p>
  8602. Given the above, <prgn>dpkg-statoverride</prgn> is
  8603. essentially a tool for system administrators and would not
  8604. normally be needed in the maintainer scripts. There is
  8605. one type of situation, though, where calls to
  8606. <prgn>dpkg-statoverride</prgn> would be needed in the
  8607. maintainer scripts, and that involves packages which use
  8608. dynamically allocated user or group ids. In such a
  8609. situation, something like the following idiom can be very
  8610. helpful in the package's <prgn>postinst</prgn>, where
  8611. <tt>sysuser</tt> is a dynamically allocated id:
  8612. <example>
  8613. for i in /usr/bin/foo /usr/sbin/bar
  8614. do
  8615. # only do something when no setting exists
  8616. if ! dpkg-statoverride --list $i >/dev/null 2>&1
  8617. then
  8618. #include: debconf processing, question about foo and bar
  8619. if [ "$RET" = "true" ] ; then
  8620. dpkg-statoverride --update --add sysuser root 4755 $i
  8621. fi
  8622. fi
  8623. done
  8624. </example>
  8625. The corresponding code to remove the override when the package
  8626. is purged would be:
  8627. <example>
  8628. for i in /usr/bin/foo /usr/sbin/bar
  8629. do
  8630. if dpkg-statoverride --list $i >/dev/null 2>&1
  8631. then
  8632. dpkg-statoverride --remove $i
  8633. fi
  8634. done
  8635. </example>
  8636. </p>
  8637. </sect1>
  8638. </sect>
  8639. <sect id="filenames">
  8640. <heading>File names</heading>
  8641. <p>
  8642. The name of the files installed by binary packages in the system PATH
  8643. (namely <tt>/bin</tt>, <tt>/sbin</tt>, <tt>/usr/bin</tt>,
  8644. <tt>/usr/sbin</tt> and <tt>/usr/games</tt>) must be encoded in
  8645. ASCII.
  8646. </p>
  8647. <p>
  8648. The name of the files and directories installed by binary packages
  8649. outside the system PATH must be encoded in UTF-8 and should be
  8650. restricted to ASCII when it is possible to do so.
  8651. </p>
  8652. </sect>
  8653. </chapt>
  8654. <chapt id="customized-programs">
  8655. <heading>Customized programs</heading>
  8656. <sect id="arch-spec">
  8657. <heading>Architecture specification strings</heading>
  8658. <p>
  8659. If a program needs to specify an <em>architecture specification
  8660. string</em> in some place, it should select one of the strings
  8661. provided by <tt>dpkg-architecture -L</tt>. The strings are in
  8662. the format <tt><var>os</var>-<var>arch</var></tt>, though the OS
  8663. part is sometimes elided, as when the OS is Linux.
  8664. </p>
  8665. <p>
  8666. Note that we don't want to use
  8667. <tt><var>arch</var>-debian-linux</tt> to apply to the rule
  8668. <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
  8669. since this would make our programs incompatible with other
  8670. Linux distributions. We also don't use something like
  8671. <tt><var>arch</var>-unknown-linux</tt>, since the
  8672. <tt>unknown</tt> does not look very good.
  8673. </p>
  8674. <sect1 id="arch-wildcard-spec">
  8675. <heading>Architecture wildcards</heading>
  8676. <p>
  8677. A package may specify an architecture wildcard. Architecture
  8678. wildcards are in the format <tt>any</tt> (which matches every
  8679. architecture), <tt><var>os</var></tt>-any, or
  8680. any-<tt><var>cpu</var></tt>. <footnote>
  8681. Internally, the package system normalizes the GNU triplets
  8682. and the Debian arches into Debian arch triplets (which are
  8683. kind of inverted GNU triplets), with the first component of
  8684. the triplet representing the libc and ABI in use, and then
  8685. does matching against those triplets. However, such
  8686. triplets are an internal implementation detail that should
  8687. not be used by packages directly. The libc and ABI portion
  8688. is handled internally by the package system based on
  8689. the <var>os</var> and <var>cpu</var>.
  8690. </footnote>
  8691. </p>
  8692. </sect1>
  8693. </sect>
  8694. <sect>
  8695. <heading>Daemons</heading>
  8696. <p>
  8697. The configuration files <file>/etc/services</file>,
  8698. <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
  8699. by the <prgn>netbase</prgn> package and must not be modified
  8700. by other packages.
  8701. </p>
  8702. <p>
  8703. If a package requires a new entry in one of these files, the
  8704. maintainer should get in contact with the
  8705. <prgn>netbase</prgn> maintainer, who will add the entries
  8706. and release a new version of the <prgn>netbase</prgn>
  8707. package.
  8708. </p>
  8709. <p>
  8710. The configuration file <file>/etc/inetd.conf</file> must not be
  8711. modified by the package's scripts except via the
  8712. <prgn>update-inetd</prgn> script or the
  8713. <file>DebianNet.pm</file> Perl module. See their documentation
  8714. for details on how to add entries.
  8715. </p>
  8716. <p>
  8717. If a package wants to install an example entry into
  8718. <file>/etc/inetd.conf</file>, the entry must be preceded with
  8719. exactly one hash character (<tt>#</tt>). Such lines are
  8720. treated as "commented out by user" by the
  8721. <prgn>update-inetd</prgn> script and are not changed or
  8722. activated during package updates.
  8723. </p>
  8724. </sect>
  8725. <sect>
  8726. <heading>Using pseudo-ttys and modifying wtmp, utmp and
  8727. lastlog</heading>
  8728. <p>
  8729. Some programs need to create pseudo-ttys. This should be done
  8730. using Unix98 ptys if the C library supports it. The resulting
  8731. program must not be installed setuid root, unless that
  8732. is required for other functionality.
  8733. </p>
  8734. <p>
  8735. The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
  8736. <file>/var/log/lastlog</file> must be installed writable by
  8737. group <tt>utmp</tt>. Programs which need to modify those
  8738. files must be installed setgid <tt>utmp</tt>.
  8739. </p>
  8740. </sect>
  8741. <sect>
  8742. <heading>Editors and pagers</heading>
  8743. <p>
  8744. Some programs have the ability to launch an editor or pager
  8745. program to edit or display a text document. Since there are
  8746. lots of different editors and pagers available in the Debian
  8747. distribution, the system administrator and each user should
  8748. have the possibility to choose their preferred editor and
  8749. pager.
  8750. </p>
  8751. <p>
  8752. In addition, every program should choose a good default
  8753. editor/pager if none is selected by the user or system
  8754. administrator.
  8755. </p>
  8756. <p>
  8757. Thus, every program that launches an editor or pager must
  8758. use the EDITOR or PAGER environment variable to determine
  8759. the editor or pager the user wishes to use. If these
  8760. variables are not set, the programs <file>/usr/bin/editor</file>
  8761. and <file>/usr/bin/pager</file> should be used, respectively.
  8762. </p>
  8763. <p>
  8764. These two files are managed through the <prgn>dpkg</prgn>
  8765. "alternatives" mechanism. Every package providing an editor or
  8766. pager must call the <prgn>update-alternatives</prgn> script to
  8767. register as an alternative for <file>/usr/bin/editor</file>
  8768. or <file>/usr/bin/pager</file> as appropriate. The alternative
  8769. should have a slave alternative
  8770. for <file>/usr/share/man/man1/editor.1.gz</file>
  8771. or <file>/usr/share/man/man1/pager.1.gz</file> pointing to the
  8772. corresponding manual page.
  8773. </p>
  8774. <p>
  8775. If it is very hard to adapt a program to make use of the
  8776. EDITOR or PAGER variables, that program may be configured to
  8777. use <file>/usr/bin/sensible-editor</file> and
  8778. <file>/usr/bin/sensible-pager</file> as the editor or pager
  8779. program respectively. These are two scripts provided in the
  8780. <package>sensible-utils</package> package that check the EDITOR
  8781. and PAGER variables and launch the appropriate program, and fall
  8782. back to <file>/usr/bin/editor</file>
  8783. and <file>/usr/bin/pager</file> if the variable is not set.
  8784. </p>
  8785. <p>
  8786. A program may also use the VISUAL environment variable to
  8787. determine the user's choice of editor. If it exists, it
  8788. should take precedence over EDITOR. This is in fact what
  8789. <file>/usr/bin/sensible-editor</file> does.
  8790. </p>
  8791. <p>
  8792. It is not required for a package to depend on
  8793. <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
  8794. package to provide such virtual packages.<footnote>
  8795. The Debian base system already provides an editor and a
  8796. pager program.
  8797. </footnote>
  8798. </p>
  8799. </sect>
  8800. <sect id="web-appl">
  8801. <heading>Web servers and applications</heading>
  8802. <p>
  8803. This section describes the locations and URLs that should
  8804. be used by all web servers and web applications in the
  8805. Debian system.
  8806. </p>
  8807. <p>
  8808. <enumlist>
  8809. <item>
  8810. Cgi-bin executable files are installed in the
  8811. directory
  8812. <example compact="compact">
  8813. /usr/lib/cgi-bin
  8814. </example>
  8815. or a subdirectory of that directory, and the script
  8816. <example compact="compact">
  8817. /usr/lib/cgi-bin/.../<var>cgi-bin-name</var>
  8818. </example>
  8819. should be referred to as
  8820. <example compact="compact">
  8821. http://localhost/cgi-bin/.../<var>cgi-bin-name</var>
  8822. </example>
  8823. </item>
  8824. <item>
  8825. <p>(Deleted)</p>
  8826. </item>
  8827. <item>
  8828. <p>Access to images</p>
  8829. <p>
  8830. It is recommended that images for a package be stored
  8831. in <tt>/usr/share/images/<var>package</var></tt> and
  8832. may be referred to through an alias <tt>/images/</tt>
  8833. as
  8834. <example>
  8835. http://localhost/images/&lt;package&gt;/&lt;filename&gt;
  8836. </example>
  8837. </p>
  8838. </item>
  8839. <item>
  8840. <p>Web Document Root</p>
  8841. <p>
  8842. Web Applications should try to avoid storing files in
  8843. the Web Document Root. Instead they should use the
  8844. /usr/share/doc/<var>package</var> directory for
  8845. documents and register the Web Application via the
  8846. <package>doc-base</package> package. If access to the
  8847. web document root is unavoidable then use
  8848. <example compact="compact">
  8849. /var/www/html
  8850. </example>
  8851. as the Document Root. This might be just a symbolic
  8852. link to the location where the system administrator
  8853. has put the real document root.
  8854. </p>
  8855. </item>
  8856. <item><p>Providing httpd and/or httpd-cgi</p>
  8857. <p>
  8858. All web servers should provide the virtual package
  8859. <tt>httpd</tt>. If a web server has CGI support it should
  8860. provide <tt>httpd-cgi</tt> additionally.
  8861. </p>
  8862. <p>
  8863. All web applications which do not contain CGI scripts should
  8864. depend on <tt>httpd</tt>, all those web applications which
  8865. <tt>do</tt> contain CGI scripts, should depend on
  8866. <tt>httpd-cgi</tt>.
  8867. </p>
  8868. </item>
  8869. </enumlist>
  8870. </p>
  8871. </sect>
  8872. <sect id="mail-transport-agents">
  8873. <heading>Mail transport, delivery and user agents</heading>
  8874. <p>
  8875. Debian packages which process electronic mail, whether mail
  8876. user agents (MUAs) or mail transport agents (MTAs), must
  8877. ensure that they are compatible with the configuration
  8878. decisions below. Failure to do this may result in lost
  8879. mail, broken <tt>From:</tt> lines, and other serious brain
  8880. damage!
  8881. </p>
  8882. <p>
  8883. The mail spool is <file>/var/mail</file> and the interface to
  8884. send a mail message is <file>/usr/sbin/sendmail</file> (as per
  8885. the FHS). On older systems, the mail spool may be
  8886. physically located in <file>/var/spool/mail</file>, but all
  8887. access to the mail spool should be via the
  8888. <file>/var/mail</file> symlink. The mail spool is part of the
  8889. base system and not part of the MTA package.
  8890. </p>
  8891. <p>
  8892. All Debian MUAs, MTAs, MDAs and other mailbox accessing
  8893. programs (such as IMAP daemons) must lock the mailbox in an
  8894. NFS-safe way. This means that <tt>fcntl()</tt> locking must
  8895. be combined with dot locking. To avoid deadlocks, a program
  8896. should use <tt>fcntl()</tt> first and dot locking after
  8897. this, or alternatively implement the two locking methods in
  8898. a non blocking way<footnote>
  8899. If it is not possible to establish both locks, the
  8900. system shouldn't wait for the second lock to be
  8901. established, but remove the first lock, wait a (random)
  8902. time, and start over locking again.
  8903. </footnote>. Using the functions <tt>maillock</tt> and
  8904. <tt>mailunlock</tt> provided by the
  8905. <tt>liblockfile*</tt><footnote>
  8906. You will need to depend on <tt>liblockfile1 (&gt;&gt;1.01)</tt>
  8907. to use these functions.
  8908. </footnote> packages is the recommended way to realize this.
  8909. </p>
  8910. <p>
  8911. Mailboxes are generally either mode 600 and owned by
  8912. <var>user</var> or mode 660 and owned by
  8913. <tt><var>user</var>:mail</tt><footnote>
  8914. There are two traditional permission schemes for mail spools:
  8915. mode 600 with all mail delivery done by processes running as
  8916. the destination user, or mode 660 and owned by group mail with
  8917. mail delivery done by a process running as a system user in
  8918. group mail. Historically, Debian required mode 660 mail
  8919. spools to enable the latter model, but that model has become
  8920. increasingly uncommon and the principle of least privilege
  8921. indicates that mail systems that use the first model should
  8922. use permissions of 600. If delivery to programs is permitted,
  8923. it's easier to keep the mail system secure if the delivery
  8924. agent runs as the destination user. Debian Policy therefore
  8925. permits either scheme.
  8926. </footnote>. The local system administrator may choose a
  8927. different permission scheme; packages should not make
  8928. assumptions about the permission and ownership of mailboxes
  8929. unless required (such as when creating a new mailbox). A MUA
  8930. may remove a mailbox (unless it has nonstandard permissions) in
  8931. which case the MTA or another MUA must recreate it if needed.
  8932. </p>
  8933. <p>
  8934. The mail spool is 2775 <tt>root:mail</tt>, and MUAs should
  8935. be setgid mail to do the locking mentioned above (and
  8936. must obviously avoid accessing other users' mailboxes
  8937. using this privilege).</p>
  8938. <p>
  8939. <file>/etc/aliases</file> is the source file for the system mail
  8940. aliases (e.g., postmaster, usenet, etc.), it is the one
  8941. which the sysadmin and <prgn>postinst</prgn> scripts may
  8942. edit. After <file>/etc/aliases</file> is edited the program or
  8943. human editing it must call <prgn>newaliases</prgn>. All MTA
  8944. packages must come with a <prgn>newaliases</prgn> program,
  8945. even if it does nothing, but older MTA packages did not do
  8946. this so programs should not fail if <prgn>newaliases</prgn>
  8947. cannot be found. Note that because of this, all MTA
  8948. packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
  8949. <tt>Replaces: mail-transport-agent</tt> control fields.
  8950. </p>
  8951. <p>
  8952. The convention of writing <tt>forward to
  8953. <var>address</var></tt> in the mailbox itself is not
  8954. supported. Use a <tt>.forward</tt> file instead.</p>
  8955. <p>
  8956. The <prgn>rmail</prgn> program used by UUCP
  8957. for incoming mail should be <file>/usr/sbin/rmail</file>.
  8958. Likewise, <prgn>rsmtp</prgn>, for receiving
  8959. batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
  8960. is supported.</p>
  8961. <p>
  8962. If your package needs to know what hostname to use on (for
  8963. example) outgoing news and mail messages which are generated
  8964. locally, you should use the file <file>/etc/mailname</file>. It
  8965. will contain the portion after the username and <tt>@</tt>
  8966. (at) sign for email addresses of users on the machine
  8967. (followed by a newline).
  8968. </p>
  8969. <p>
  8970. Such a package should check for the existence of this file
  8971. when it is being configured. If it exists, it should be
  8972. used without comment, although an MTA's configuration script
  8973. may wish to prompt the user even if it finds that this file
  8974. exists. If the file does not exist, the package should
  8975. prompt the user for the value (preferably using
  8976. <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
  8977. as well as using it in the package's configuration. The
  8978. prompt should make it clear that the name will not just be
  8979. used by that package. For example, in this situation the
  8980. <tt>inn</tt> package could say something like:
  8981. <example compact="compact">
  8982. Please enter the "mail name" of your system. This is the
  8983. hostname portion of the address to be shown on outgoing
  8984. news and mail messages. The default is
  8985. <var>syshostname</var>, your system's host name. Mail
  8986. name ["<var>syshostname</var>"]:
  8987. </example>
  8988. where <var>syshostname</var> is the output of <tt>hostname
  8989. --fqdn</tt>.
  8990. </p>
  8991. </sect>
  8992. <sect>
  8993. <heading>News system configuration</heading>
  8994. <p>
  8995. All the configuration files related to the NNTP (news)
  8996. servers and clients should be located under
  8997. <file>/etc/news</file>.</p>
  8998. <p>
  8999. There are some configuration issues that apply to a number
  9000. of news clients and server packages on the machine. These
  9001. are:
  9002. <taglist>
  9003. <tag><file>/etc/news/organization</file></tag>
  9004. <item>
  9005. A string which should appear as the
  9006. organization header for all messages posted
  9007. by NNTP clients on the machine
  9008. </item>
  9009. <tag><file>/etc/news/server</file></tag>
  9010. <item>
  9011. Contains the FQDN of the upstream NNTP
  9012. server, or localhost if the local machine is
  9013. an NNTP server.
  9014. </item>
  9015. </taglist>
  9016. Other global files may be added as required for cross-package news
  9017. configuration.
  9018. </p>
  9019. </sect>
  9020. <sect>
  9021. <heading>Programs for the X Window System</heading>
  9022. <sect1>
  9023. <heading>Providing X support and package priorities</heading>
  9024. <p>
  9025. Programs that can be configured with support for the X
  9026. Window System must be configured to do so and must declare
  9027. any package dependencies necessary to satisfy their
  9028. runtime requirements when using the X Window System. If
  9029. such a package is of higher priority than the X packages
  9030. on which it depends, it is required that either the
  9031. X-specific components be split into a separate package, or
  9032. that an alternative version of the package, which includes
  9033. X support, be provided, or that the package's priority be
  9034. lowered.
  9035. </p>
  9036. </sect1>
  9037. <sect1>
  9038. <heading>Packages providing an X server</heading>
  9039. <p>
  9040. Packages that provide an X server that, directly or
  9041. indirectly, communicates with real input and display
  9042. hardware should declare in their <tt>Provides</tt> control
  9043. field that they provide the virtual
  9044. package <tt>xserver</tt>.<footnote>
  9045. This implements current practice, and provides an
  9046. actual policy for usage of the <tt>xserver</tt>
  9047. virtual package which appears in the virtual packages
  9048. list. In a nutshell, X servers that interface
  9049. directly with the display and input hardware or via
  9050. another subsystem (e.g., GGI) should provide
  9051. <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
  9052. <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
  9053. </footnote>
  9054. </p>
  9055. </sect1>
  9056. <sect1>
  9057. <heading>Packages providing a terminal emulator</heading>
  9058. <p>
  9059. Packages that provide a terminal emulator for the X Window
  9060. System which meet the criteria listed below should declare in
  9061. their <tt>Provides</tt> control field that they provide the
  9062. virtual package <tt>x-terminal-emulator</tt>. They should
  9063. also register themselves as an alternative for
  9064. <file>/usr/bin/x-terminal-emulator</file>, with a priority of
  9065. 20. That alternative should have a slave alternative
  9066. for <file>/usr/share/man/man1/x-terminal-emulator.1.gz</file>
  9067. pointing to the corresponding manual page.
  9068. </p>
  9069. <p>
  9070. To be an <tt>x-terminal-emulator</tt>, a program must:
  9071. <list compact="compact">
  9072. <item>
  9073. Be able to emulate a DEC VT100 terminal, or a
  9074. compatible terminal.
  9075. </item>
  9076. <item>
  9077. Support the command-line option <tt>-e
  9078. <var>command</var></tt>, which creates a new
  9079. terminal window<footnote>
  9080. "New terminal window" does not necessarily mean
  9081. a new top-level X window directly parented by
  9082. the window manager; it could, if the terminal
  9083. emulator application were so coded, be a new
  9084. "view" in a multiple-document interface (MDI).
  9085. </footnote>
  9086. and runs the specified <var>command</var>,
  9087. interpreting the entirety of the rest of the command
  9088. line as a command to pass straight to exec, in the
  9089. manner that <tt>xterm</tt> does.
  9090. </item>
  9091. <item>
  9092. Support the command-line option <tt>-T
  9093. <var>title</var></tt>, which creates a new terminal
  9094. window with the window title <var>title</var>.
  9095. </item>
  9096. </list>
  9097. </p>
  9098. </sect1>
  9099. <sect1>
  9100. <heading>Packages providing a window manager</heading>
  9101. <p>
  9102. Packages that provide a window manager should declare in
  9103. their <tt>Provides</tt> control field that they provide the
  9104. virtual package <tt>x-window-manager</tt>. They should also
  9105. register themselves as an alternative for
  9106. <file>/usr/bin/x-window-manager</file>, with a priority
  9107. calculated as follows:
  9108. <list compact="compact">
  9109. <item>
  9110. Start with a priority of 20.
  9111. </item>
  9112. <item>
  9113. If the window manager supports the Debian menu
  9114. system, add 20 points if this support is available
  9115. in the package's default configuration (i.e., no
  9116. configuration files belonging to the system or user
  9117. have to be edited to activate the feature); if
  9118. configuration files must be modified, add only 10
  9119. points.
  9120. </p>
  9121. </item>
  9122. <item>
  9123. If the window manager complies with <url
  9124. id="http://www.freedesktop.org/wiki/Specifications/wm-spec"
  9125. name="The Window Manager Specification Project">,
  9126. written by the <url id="http://www.freedesktop.org/wiki/"
  9127. name="Free Desktop Group">, add 40 points.
  9128. </item>
  9129. <item>
  9130. If the window manager permits the X session to be
  9131. restarted using a <em>different</em> window manager
  9132. (without killing the X server) in its default
  9133. configuration, add 10 points; otherwise add none.
  9134. </item>
  9135. </list>
  9136. That alternative should have a slave alternative
  9137. for <file>/usr/share/man/man1/x-window-manager.1.gz</file>
  9138. pointing to the corresponding manual page.
  9139. </p>
  9140. </sect1>
  9141. <sect1>
  9142. <heading>Packages providing fonts</heading>
  9143. <p>
  9144. Packages that provide fonts for the X Window
  9145. System<footnote>
  9146. For the purposes of Debian Policy, a "font for the X
  9147. Window System" is one which is accessed via X protocol
  9148. requests. Fonts for the Linux console, for PostScript
  9149. renderer, or any other purpose, do not fit this
  9150. definition. Any tool which makes such fonts available
  9151. to the X Window System, however, must abide by this
  9152. font policy.
  9153. </footnote>
  9154. must do a number of things to ensure that they are both
  9155. available without modification of the X or font server
  9156. configuration, and that they do not corrupt files used by
  9157. other font packages to register information about
  9158. themselves.
  9159. <enumlist>
  9160. <item>
  9161. Fonts of any type supported by the X Window System
  9162. must be in a separate binary package from any
  9163. executables, libraries, or documentation (except
  9164. that specific to the fonts shipped, such as their
  9165. license information). If one or more of the fonts
  9166. so packaged are necessary for proper operation of
  9167. the package with which they are associated the font
  9168. package may be Recommended; if the fonts merely
  9169. provide an enhancement, a Suggests relationship may
  9170. be used. Packages must not Depend on font
  9171. packages.<footnote>
  9172. This is because the X server may retrieve fonts
  9173. from the local file system or over the network
  9174. from an X font server; the Debian package system
  9175. is empowered to deal only with the local
  9176. file system.
  9177. </footnote>
  9178. </item>
  9179. <item>
  9180. BDF fonts must be converted to PCF fonts with the
  9181. <prgn>bdftopcf</prgn> utility (available in the
  9182. <tt>xfonts-utils</tt> package, <prgn>gzip</prgn>ped, and
  9183. placed in a directory that corresponds to their
  9184. resolution:
  9185. <list compact="compact">
  9186. <item>
  9187. 100 dpi fonts must be placed in
  9188. <file>/usr/share/fonts/X11/100dpi/</file>.
  9189. </item>
  9190. <item>
  9191. 75 dpi fonts must be placed in
  9192. <file>/usr/share/fonts/X11/75dpi/</file>.
  9193. </item>
  9194. <item>
  9195. Character-cell fonts, cursor fonts, and other
  9196. low-resolution fonts must be placed in
  9197. <file>/usr/share/fonts/X11/misc/</file>.
  9198. </item>
  9199. </list>
  9200. </item>
  9201. <item>
  9202. Type 1 fonts must be placed in
  9203. <file>/usr/share/fonts/X11/Type1/</file>. If font
  9204. metric files are available, they must be placed here
  9205. as well.
  9206. </item>
  9207. <item>
  9208. Subdirectories of <file>/usr/share/fonts/X11/</file>
  9209. other than those listed above must be neither
  9210. created nor used. (The <file>PEX</file>, <file>CID</file>,
  9211. <file>Speedo</file>, and <file>cyrillic</file> directories
  9212. are excepted for historical reasons, but installation of
  9213. files into these directories remains discouraged.)
  9214. </item>
  9215. <item>
  9216. Font packages may, instead of placing files directly
  9217. in the X font directories listed above, provide
  9218. symbolic links in that font directory pointing to
  9219. the files' actual location in the filesystem. Such
  9220. a location must comply with the FHS.
  9221. </item>
  9222. <item>
  9223. Font packages should not contain both 75dpi and
  9224. 100dpi versions of a font. If both are available,
  9225. they should be provided in separate binary packages
  9226. with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
  9227. the names of the packages containing the
  9228. corresponding fonts.
  9229. </item>
  9230. <item>
  9231. Fonts destined for the <file>misc</file> subdirectory
  9232. should not be included in the same package as 75dpi
  9233. or 100dpi fonts; instead, they should be provided in
  9234. a separate package with <tt>-misc</tt> appended to
  9235. its name.
  9236. </item>
  9237. <item>
  9238. Font packages must not provide the files
  9239. <file>fonts.dir</file>, <file>fonts.alias</file>, or
  9240. <file>fonts.scale</file> in a font directory:
  9241. <list>
  9242. <item>
  9243. <file>fonts.dir</file> files must not be provided at all.
  9244. </item>
  9245. <item>
  9246. <file>fonts.alias</file> and <file>fonts.scale</file>
  9247. files, if needed, should be provided in the
  9248. directory
  9249. <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
  9250. where <var>fontdir</var> is the name of the
  9251. subdirectory of
  9252. <file>/usr/share/fonts/X11/</file> where the
  9253. package's corresponding fonts are stored
  9254. (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
  9255. <var>package</var> is the name of the package
  9256. that provides these fonts, and
  9257. <var>extension</var> is either <tt>scale</tt>
  9258. or <tt>alias</tt>, whichever corresponds to
  9259. the file contents.
  9260. </item>
  9261. </list>
  9262. </item>
  9263. <item>
  9264. Font packages must declare a dependency on
  9265. <tt>xfonts-utils</tt> in their <tt>Depends</tt>
  9266. or <tt>Pre-Depends</tt> control field.
  9267. </item>
  9268. <item>
  9269. Font packages that provide one or more
  9270. <file>fonts.scale</file> files as described above must
  9271. invoke <prgn>update-fonts-scale</prgn> on each
  9272. directory into which they installed fonts
  9273. <em>before</em> invoking
  9274. <prgn>update-fonts-dir</prgn> on that directory.
  9275. This invocation must occur in both the
  9276. <prgn>postinst</prgn> (for all arguments) and
  9277. <prgn>postrm</prgn> (for all arguments except
  9278. <tt>upgrade</tt>) scripts.
  9279. </item>
  9280. <item>
  9281. Font packages that provide one or more
  9282. <file>fonts.alias</file> files as described above must
  9283. invoke <prgn>update-fonts-alias</prgn> on each
  9284. directory into which they installed fonts. This
  9285. invocation must occur in both the
  9286. <prgn>postinst</prgn> (for all arguments) and
  9287. <prgn>postrm</prgn> (for all arguments except
  9288. <tt>upgrade</tt>) scripts.
  9289. </item>
  9290. <item>
  9291. Font packages must invoke
  9292. <prgn>update-fonts-dir</prgn> on each directory into
  9293. which they installed fonts. This invocation must
  9294. occur in both the <prgn>postinst</prgn> (for all
  9295. arguments) and <prgn>postrm</prgn> (for all
  9296. arguments except <tt>upgrade</tt>) scripts.
  9297. </item>
  9298. <item>
  9299. Font packages must not provide alias names for the
  9300. fonts they include which collide with alias names
  9301. already in use by fonts already packaged.
  9302. </item>
  9303. <item>
  9304. Font packages must not provide fonts with the same
  9305. XLFD registry name as another font already packaged.
  9306. </item>
  9307. </enumlist>
  9308. </p>
  9309. </sect1>
  9310. <sect1 id="appdefaults">
  9311. <heading>Application defaults files</heading>
  9312. <p>
  9313. Application defaults files must be installed in the
  9314. directory <file>/etc/X11/app-defaults/</file> (use of a
  9315. localized subdirectory of <file>/etc/X11/</file> as described
  9316. in the <em>X Toolkit Intrinsics - C Language
  9317. Interface</em> manual is also permitted). They must be
  9318. registered as <tt>conffile</tt>s or handled as
  9319. configuration files.
  9320. </p>
  9321. <p>
  9322. Customization of programs' X resources may also be
  9323. supported with the provision of a file with the same name
  9324. as that of the package placed in
  9325. the <file>/etc/X11/Xresources/</file> directory, which
  9326. must be registered as a <tt>conffile</tt> or handled as a
  9327. configuration file.<footnote>
  9328. Note that this mechanism is not the same as using
  9329. app-defaults; app-defaults are tied to the client
  9330. binary on the local file system, whereas X resources
  9331. are stored in the X server and affect all connecting
  9332. clients.
  9333. </footnote>
  9334. </p>
  9335. </sect1>
  9336. <sect1>
  9337. <heading>Installation directory issues</heading>
  9338. <p>
  9339. Historically, packages using the X Window System used a
  9340. separate set of installation directories from other packages.
  9341. This practice has been discontinued and packages using the X
  9342. Window System should now generally be installed in the same
  9343. directories as any other package. Specifically, packages must
  9344. not install files under the <file>/usr/X11R6/</file> directory
  9345. and the <file>/usr/X11R6/</file> directory hierarchy should be
  9346. regarded as obsolete.
  9347. </p>
  9348. <p>
  9349. Include files previously installed under
  9350. <file>/usr/X11R6/include/X11/</file> should be installed into
  9351. <file>/usr/include/X11/</file>. For files previously
  9352. installed into subdirectories of
  9353. <file>/usr/X11R6/lib/X11/</file>, package maintainers should
  9354. determine if subdirectories of <file>/usr/lib/</file> and
  9355. <file>/usr/share/</file> can be used. If not, a subdirectory
  9356. of <file>/usr/lib/X11/</file> should be used.
  9357. </p>
  9358. <p>
  9359. Configuration files for window, display, or session managers
  9360. or other applications that are tightly integrated with the X
  9361. Window System may be placed in a subdirectory
  9362. of <file>/etc/X11/</file> corresponding to the package name.
  9363. Other X Window System applications should use
  9364. the <file>/etc/</file> directory unless otherwise mandated by
  9365. policy (such as for <ref id="appdefaults">).
  9366. </p>
  9367. </sect1>
  9368. </sect>
  9369. <sect id="perl">
  9370. <heading>Perl programs and modules</heading>
  9371. <p>
  9372. Perl programs and modules should follow the current Perl policy.
  9373. </p>
  9374. <p>
  9375. The Perl policy can be found in the <tt>perl-policy</tt>
  9376. files in the <tt>debian-policy</tt> package.
  9377. It is also available from the Debian web mirrors at
  9378. <tt><url name="/doc/packaging-manuals/perl-policy/"
  9379. id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>.
  9380. </p>
  9381. </sect>
  9382. <sect id="emacs">
  9383. <heading>Emacs lisp programs</heading>
  9384. <p>
  9385. Please refer to the "Debian Emacs Policy" for details of how to
  9386. package emacs lisp programs.
  9387. </p>
  9388. <p>
  9389. The Emacs policy is available in
  9390. <file>debian-emacs-policy.gz</file> of the
  9391. <package>emacsen-common</package> package.
  9392. It is also available from the Debian web mirrors at
  9393. <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
  9394. id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
  9395. </p>
  9396. </sect>
  9397. <sect>
  9398. <heading>Games</heading>
  9399. <p>
  9400. The permissions on <file>/var/games</file> are mode 755, owner
  9401. <tt>root</tt> and group <tt>root</tt>.
  9402. </p>
  9403. <p>
  9404. Each game decides on its own security policy.</p>
  9405. <p>
  9406. Games which require protected, privileged access to
  9407. high-score files, saved games, etc., may be made
  9408. set-<em>group</em>-id (mode 2755) and owned by
  9409. <tt>root:games</tt>, and use files and directories with
  9410. appropriate permissions (770 <tt>root:games</tt>, for
  9411. example). They must not be made
  9412. set-<em>user</em>-id, as this causes security problems. (If
  9413. an attacker can subvert any set-user-id game they can
  9414. overwrite the executable of any other, causing other players
  9415. of these games to run a Trojan horse program. With a
  9416. set-group-id game the attacker only gets access to less
  9417. important game data, and if they can get at the other
  9418. players' accounts at all it will take considerably more
  9419. effort.)</p>
  9420. <p>
  9421. Some packages, for example some fortune cookie programs, are
  9422. configured by the upstream authors to install with their
  9423. data files or other static information made unreadable so
  9424. that they can only be accessed through set-id programs
  9425. provided. You should not do this in a Debian package: anyone can
  9426. download the <file>.deb</file> file and read the data from it,
  9427. so there is no point making the files unreadable. Not
  9428. making the files unreadable also means that you don't have
  9429. to make so many programs set-id, which reduces the risk of a
  9430. security hole.</p>
  9431. <p>
  9432. As described in the FHS, binaries of games should be
  9433. installed in the directory <file>/usr/games</file>. This also
  9434. applies to games that use the X Window System. Manual pages
  9435. for games (X and non-X games) should be installed in
  9436. <file>/usr/share/man/man6</file>.</p>
  9437. </sect>
  9438. </chapt>
  9439. <chapt id="docs">
  9440. <heading>Documentation</heading>
  9441. <sect>
  9442. <heading>Manual pages</heading>
  9443. <p>
  9444. You should install manual pages in <prgn>nroff</prgn> source
  9445. form, in appropriate places under <file>/usr/share/man</file>.
  9446. You should only use sections 1 to 9 (see the FHS for more
  9447. details). You must not install a pre-formatted "cat page".
  9448. </p>
  9449. <p>
  9450. Each program, utility, and function should have an
  9451. associated manual page included in the same package. It is
  9452. suggested that all configuration files also have a manual
  9453. page included as well. Manual pages for protocols and other
  9454. auxiliary things are optional.
  9455. </p>
  9456. <p>
  9457. If no manual page is available, this is considered as a bug
  9458. and should be reported to the Debian Bug Tracking System (the
  9459. maintainer of the package is allowed to write this bug report
  9460. themselves, if they so desire). Do not close the bug report
  9461. until a proper man page is available.<footnote>
  9462. It is not very hard to write a man page. See the
  9463. <url id="http://www.schweikhardt.net/man_page_howto.html"
  9464. name="Man-Page-HOWTO">,
  9465. <manref name="man" section="7">, the examples created
  9466. by <prgn>dh_make</prgn>, the helper
  9467. program <prgn>help2man</prgn>, or the
  9468. directory <file>/usr/share/doc/man-db/examples</file>.
  9469. </footnote>
  9470. </p>
  9471. <p>
  9472. You may forward a complaint about a missing man page to the
  9473. upstream authors, and mark the bug as forwarded in the
  9474. Debian bug tracking system. Even though the GNU Project do
  9475. not in general consider the lack of a man page to be a bug,
  9476. we do; if they tell you that they don't consider it a bug
  9477. you should leave the bug in our bug tracking system open
  9478. anyway.
  9479. </p>
  9480. <p>
  9481. Manual pages should be installed compressed using <tt>gzip -9</tt>.
  9482. </p>
  9483. <p>
  9484. If one man page needs to be accessible via several names it
  9485. is better to use a symbolic link than the <file>.so</file>
  9486. feature, but there is no need to fiddle with the relevant
  9487. parts of the upstream source to change from <file>.so</file> to
  9488. symlinks: don't do it unless it's easy. You should not
  9489. create hard links in the manual page directories, nor put
  9490. absolute filenames in <file>.so</file> directives. The filename
  9491. in a <file>.so</file> in a man page should be relative to the
  9492. base of the man page tree (usually
  9493. <file>/usr/share/man</file>). If you do not create any links
  9494. (whether symlinks, hard links, or <tt>.so</tt> directives)
  9495. in the file system to the alternate names of the man page,
  9496. then you should not rely on <prgn>man</prgn> finding your
  9497. man page under those names based solely on the information in
  9498. the man page's header.<footnote>
  9499. Supporting this in <prgn>man</prgn> often requires
  9500. unreasonable processing time to find a manual page or to
  9501. report that none exists, and moves knowledge into man's
  9502. database that would be better left in the file system.
  9503. This support is therefore deprecated and will cease to
  9504. be present in the future.
  9505. </footnote>
  9506. </p>
  9507. <p>
  9508. Manual pages in locale-specific subdirectories of
  9509. <file>/usr/share/man</file> should use either UTF-8 or the usual
  9510. legacy encoding for that language (normally the one corresponding
  9511. to the shortest relevant locale name in
  9512. <file>/usr/share/i18n/SUPPORTED</file>). For example, pages under
  9513. <file>/usr/share/man/fr</file> should use either UTF-8 or
  9514. ISO-8859-1.<footnote>
  9515. <prgn>man</prgn> will automatically detect whether UTF-8 is in
  9516. use. In future, all manual pages will be required to use
  9517. UTF-8.
  9518. </footnote>
  9519. </p>
  9520. <p>
  9521. A country name (the <tt>DE</tt> in <tt>de_DE</tt>) should not be
  9522. included in the subdirectory name unless it indicates a
  9523. significant difference in the language, as this excludes
  9524. speakers of the language in other countries.<footnote>
  9525. At the time of writing, Chinese and Portuguese are the main
  9526. languages with such differences, so <file>pt_BR</file>,
  9527. <file>zh_CN</file>, and <file>zh_TW</file> are all allowed.
  9528. </footnote>
  9529. </p>
  9530. <p>
  9531. If a localized version of a manual page is provided, it should
  9532. either be up-to-date or it should be obvious to the reader that
  9533. it is outdated and the original manual page should be used
  9534. instead. This can be done either by a note at the beginning of
  9535. the manual page or by showing the missing or changed portions in
  9536. the original language instead of the target language.
  9537. </p>
  9538. </sect>
  9539. <sect>
  9540. <heading>Info documents</heading>
  9541. <p>
  9542. Info documents should be installed in <file>/usr/share/info</file>.
  9543. They should be compressed with <tt>gzip -9</tt>.
  9544. </p>
  9545. <p>
  9546. The <prgn>install-info</prgn> program maintains a directory of
  9547. installed info documents in <file>/usr/share/info/dir</file> for the
  9548. use of info readers. This file must not be included in packages
  9549. other than <package>install-info</package>.
  9550. </p>
  9551. <p>
  9552. <prgn>install-info</prgn> is automatically invoked when
  9553. appropriate using dpkg triggers. Packages other than
  9554. <package>install-info</package> <em>should not</em> invoke
  9555. <prgn>install-info</prgn> directly and <em>should not</em>
  9556. depend on, recommend, or suggest <package>install-info</package>
  9557. for this purpose.
  9558. </p>
  9559. <p>
  9560. Info readers requiring the <file>/usr/share/info/dir</file> file
  9561. should depend on <package>install-info</package>.
  9562. </p>
  9563. <p>
  9564. Info documents should contain section and directory entry
  9565. information in the document for the use
  9566. of <prgn>install-info</prgn>. The section should be specified
  9567. via a line starting with <tt>INFO-DIR-SECTION</tt> followed by a
  9568. space and the section of this info page. The directory entry or
  9569. entries should be included between
  9570. a <tt>START-INFO-DIR-ENTRY</tt> line and
  9571. an <tt>END-INFO-DIR-ENTRY</tt> line. For example:
  9572. <example>
  9573. INFO-DIR-SECTION Individual utilities
  9574. START-INFO-DIR-ENTRY
  9575. * example: (example). An example info directory entry.
  9576. END-INFO-DIR-ENTRY
  9577. </example>
  9578. To determine which section to use, you should look
  9579. at <file>/usr/share/info/dir</file> on your system and choose
  9580. the most relevant (or create a new section if none of the
  9581. current sections are relevant).<footnote>
  9582. Normally, info documents are generated from Texinfo source.
  9583. To include this information in the generated info document, if
  9584. it is absent, add commands like:
  9585. <example>
  9586. @dircategory Individual utilities
  9587. @direntry
  9588. * example: (example). An example info directory entry.
  9589. @end direntry
  9590. </example>
  9591. to the Texinfo source of the document and ensure that the info
  9592. documents are rebuilt from source during the package build.
  9593. </footnote>
  9594. </p>
  9595. </sect>
  9596. <sect id="docs-additional">
  9597. <heading>Additional documentation</heading>
  9598. <p>
  9599. Any additional documentation that comes with the package may be
  9600. installed at the discretion of the package maintainer. It is
  9601. often a good idea to include text information files
  9602. (<file>README</file>s, FAQs, and so forth) that come with the
  9603. source package in the binary package. However, you don't need
  9604. to install the instructions for building and installing the
  9605. package, of course!
  9606. </p>
  9607. <p>
  9608. Plain text documentation should be compressed with <tt>gzip
  9609. -9</tt> unless it is small.
  9610. </p>
  9611. <p>
  9612. If a package comes with large amounts of documentation that many
  9613. users of the package will not require, you should create a
  9614. separate binary package to contain it so that it does not take
  9615. up disk space on the machines of users who do not need or want
  9616. it installed. As a special case of this rule, shared library
  9617. documentation of any appreciable size should always be packaged
  9618. with the library development package (<ref id="sharedlibs-dev">)
  9619. or in a separate documentation package, since shared libraries
  9620. are frequently installed as dependencies of other packages by
  9621. users who have little interest in documentation of the library
  9622. itself. The documentation package for the
  9623. package <var>package</var> is conventionally
  9624. named <var>package</var>-doc
  9625. (or <var>package</var>-doc-<var>language-code</var> if there are
  9626. separate documentation packages for multiple languages).
  9627. </p>
  9628. <p>
  9629. Additional documentation included in the package should be
  9630. installed under <file>/usr/share/doc/<var>package</var></file>.
  9631. If the documentation is packaged separately,
  9632. as <var>package</var>-doc for example, it may be installed under
  9633. either that path or into the documentation directory for the
  9634. separate documentation package
  9635. (<file>/usr/share/doc/<var>package</var>-doc</file> in this
  9636. example). However, installing the documentation into the
  9637. documentation directory of the main package is preferred since
  9638. it is independent of the packaging method and will be easier for
  9639. users to find.
  9640. </p>
  9641. <p>
  9642. Any separate package providing documentation must still install
  9643. standard documentation files in its
  9644. own <file>/usr/share/doc</file> directory as specified in the
  9645. rest of this policy. See, for example, <ref id="copyrightfile">
  9646. and <ref id="changelogs">.
  9647. </p>
  9648. <p>
  9649. Packages must not require the existence of any files in
  9650. <file>/usr/share/doc/</file> in order to function
  9651. <footnote>
  9652. The system administrator should be able to delete files
  9653. in <file>/usr/share/doc/</file> without causing any programs
  9654. to break.
  9655. </footnote>. Any files that are used or read by programs but
  9656. are also useful as stand alone documentation should be installed
  9657. elsewhere, such as
  9658. under <file>/usr/share/<var>package</var>/</file>, and then
  9659. included via symbolic links
  9660. in <file>/usr/share/doc/<var>package</var></file>.
  9661. </p>
  9662. <p>
  9663. <file>/usr/share/doc/<var>package</var></file> may be a symbolic
  9664. link to another directory in <file>/usr/share/doc</file> only if
  9665. the two packages both come from the same source and the
  9666. first package Depends on the second.<footnote>
  9667. <p>
  9668. Please note that this does not override the section on
  9669. changelog files below, so the file
  9670. <file>/usr/share/doc/<var>package</var>/changelog.Debian.gz</file>
  9671. must refer to the changelog for the current version of
  9672. <var>package</var> in question. In practice, this means
  9673. that the sources of the target and the destination of the
  9674. symlink must be the same (same source package and
  9675. version).
  9676. </p>
  9677. </footnote>
  9678. </p>
  9679. </sect>
  9680. <sect>
  9681. <heading>Preferred documentation formats</heading>
  9682. <p>
  9683. The unification of Debian documentation is being carried out
  9684. via HTML.</p>
  9685. <p>
  9686. If the package comes with extensive documentation in a
  9687. markup format that can be converted to various other formats
  9688. you should if possible ship HTML versions in a binary
  9689. package.<footnote>
  9690. Rationale: The important thing here is that HTML
  9691. documentation should be available from <em>some</em>
  9692. binary package.
  9693. </footnote>
  9694. The documentation must be installed as specified in
  9695. <ref id="docs-additional">.
  9696. </p>
  9697. <p>
  9698. Other formats such as PostScript may be provided at the
  9699. package maintainer's discretion.
  9700. </p>
  9701. </sect>
  9702. <sect id="copyrightfile">
  9703. <heading>Copyright information</heading>
  9704. <p>
  9705. Every package must be accompanied by a verbatim copy of its
  9706. copyright information and distribution license in the file
  9707. <file>/usr/share/doc/<var>package</var>/copyright</file>. This
  9708. file must neither be compressed nor be a symbolic link.
  9709. </p>
  9710. <p>
  9711. In addition, the copyright file must say where the upstream
  9712. sources (if any) were obtained, and should name the original
  9713. authors.
  9714. </p>
  9715. <p>
  9716. Packages in the <em>contrib</em> or <em>non-free</em> archive
  9717. areas should state in the copyright file that the package is not
  9718. part of the Debian distribution and briefly explain why.
  9719. </p>
  9720. <p>
  9721. A copy of the file which will be installed in
  9722. <file>/usr/share/doc/<var>package</var>/copyright</file> should
  9723. be in <file>debian/copyright</file> in the source package.
  9724. </p>
  9725. <p>
  9726. <file>/usr/share/doc/<var>package</var></file> may be a symbolic
  9727. link to another directory in <file>/usr/share/doc</file> only if
  9728. the two packages both come from the same source and the
  9729. first package Depends on the second. These rules are important
  9730. because <file>copyright</file> files must be extractable by
  9731. mechanical means.
  9732. </p>
  9733. <p>
  9734. Packages distributed under the Apache license (version 2.0), the
  9735. Artistic license, the GNU GPL (versions 1, 2, or 3), the GNU
  9736. LGPL (versions 2, 2.1, or 3), and the GNU FDL (versions 1.2 or
  9737. 1.3) should refer to the corresponding files
  9738. under <file>/usr/share/common-licenses</file>,<footnote>
  9739. <p>
  9740. In particular,
  9741. <file>/usr/share/common-licenses/Apache-2.0</file>,
  9742. <file>/usr/share/common-licenses/Artistic</file>,
  9743. <file>/usr/share/common-licenses/GPL-1</file>,
  9744. <file>/usr/share/common-licenses/GPL-2</file>,
  9745. <file>/usr/share/common-licenses/GPL-3</file>,
  9746. <file>/usr/share/common-licenses/LGPL-2</file>,
  9747. <file>/usr/share/common-licenses/LGPL-2.1</file>,
  9748. <file>/usr/share/common-licenses/LGPL-3</file>,
  9749. <file>/usr/share/common-licenses/GFDL-1.2</file>, and
  9750. <file>/usr/share/common-licenses/GFDL-1.3</file>
  9751. respectively. The University of California BSD license is
  9752. also included in <package>base-files</package> as
  9753. <file>/usr/share/common-licenses/BSD</file>, but given the
  9754. brevity of this license, its specificity to code whose
  9755. copyright is held by the Regents of the University of
  9756. California, and the frequency of minor wording changes, its
  9757. text should be included in the copyright file rather than
  9758. referencing this file.
  9759. </p>
  9760. </footnote> rather than quoting them in the copyright
  9761. file.
  9762. </p>
  9763. <p>
  9764. You should not use the copyright file as a general <file>README</file>
  9765. file. If your package has such a file it should be
  9766. installed in <file>/usr/share/doc/<var>package</var>/README</file> or
  9767. <file>README.Debian</file> or some other appropriate place.
  9768. </p>
  9769. <p>
  9770. All copyright files must be encoded in UTF-8.
  9771. </p>
  9772. <sect1 id="copyrightformat">
  9773. <heading>Machine-readable copyright information</heading>
  9774. <p>
  9775. A specification for a standard, machine-readable format
  9776. for <file>debian/copyright</file> files is maintained as part
  9777. of the <package>debian-policy</package> package. This
  9778. document may be found in the <file>copyright-format</file>
  9779. files in the <package>debian-policy</package> package. It is
  9780. also available from the Debian web mirrors at
  9781. <tt><url name="/doc/packaging-manuals/copyright-format/1.0/"
  9782. id="http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"></tt>.
  9783. </p>
  9784. <p>
  9785. Use of this format is optional.
  9786. </p>
  9787. </sect1>
  9788. </sect>
  9789. <sect>
  9790. <heading>Examples</heading>
  9791. <p>
  9792. Any examples (configurations, source files, whatever),
  9793. should be installed in a directory
  9794. <file>/usr/share/doc/<var>package</var>/examples</file>. These
  9795. files should not be referenced by any program: they're there
  9796. for the benefit of the system administrator and users as
  9797. documentation only. Architecture-specific example files
  9798. should be installed in a directory
  9799. <file>/usr/lib/<var>package</var>/examples</file> with symbolic
  9800. links to them from
  9801. <file>/usr/share/doc/<var>package</var>/examples</file>, or the
  9802. latter directory itself may be a symbolic link to the
  9803. former.
  9804. </p>
  9805. <p>
  9806. If the purpose of a package is to provide examples, then the
  9807. example files may be installed into
  9808. <file>/usr/share/doc/<var>package</var></file>.
  9809. </p>
  9810. </sect>
  9811. <sect id="changelogs">
  9812. <heading>Changelog files</heading>
  9813. <p>
  9814. Packages that are not Debian-native must contain a
  9815. compressed copy of the <file>debian/changelog</file> file from
  9816. the Debian source tree in
  9817. <file>/usr/share/doc/<var>package</var></file> with the name
  9818. <file>changelog.Debian.gz</file>.
  9819. </p>
  9820. <p>
  9821. If an upstream changelog is available, it should be accessible as
  9822. <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
  9823. plain text. If the upstream changelog is distributed in
  9824. HTML, it should be made available in that form as
  9825. <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
  9826. and a plain text <file>changelog.gz</file> should be generated
  9827. from it using, for example, <tt>lynx -dump -nolist</tt>. If
  9828. the upstream changelog files do not already conform to this
  9829. naming convention, then this may be achieved either by
  9830. renaming the files, or by adding a symbolic link, at the
  9831. maintainer's discretion.<footnote>
  9832. Rationale: People should not have to look in places for
  9833. upstream changelogs merely because they are given
  9834. different names or are distributed in HTML format.
  9835. </footnote>
  9836. </p>
  9837. <p>
  9838. All of these files should be installed compressed using
  9839. <tt>gzip -9</tt>, as they will become large with time even
  9840. if they start out small.
  9841. </p>
  9842. <p>
  9843. If the package has only one changelog which is used both as
  9844. the Debian changelog and the upstream one because there is
  9845. no separate upstream maintainer then that changelog should
  9846. usually be installed as
  9847. <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
  9848. there is a separate upstream maintainer, but no upstream
  9849. changelog, then the Debian changelog should still be called
  9850. <file>changelog.Debian.gz</file>.
  9851. </p>
  9852. <p>
  9853. For details about the format and contents of the Debian
  9854. changelog file, please see <ref id="dpkgchangelog">.
  9855. </p>
  9856. </sect>
  9857. </chapt>
  9858. <appendix id="pkg-scope">
  9859. <heading>Introduction and scope of these appendices</heading>
  9860. <p>
  9861. These appendices are taken essentially verbatim from the
  9862. now-deprecated Packaging Manual, version 3.2.1.0. They are
  9863. the chapters which are likely to be of use to package
  9864. maintainers and which have not already been included in the
  9865. policy document itself. Most of these sections are very likely
  9866. not relevant to policy; they should be treated as
  9867. documentation for the packaging system. Please note that these
  9868. appendices are included for convenience, and for historical
  9869. reasons: they used to be part of policy package, and they have
  9870. not yet been incorporated into dpkg documentation. However,
  9871. they still have value, and hence they are presented here.
  9872. </p>
  9873. <p>
  9874. They have not yet been checked to ensure that they are
  9875. compatible with the contents of policy, and if there are any
  9876. contradictions, the version in the main policy document takes
  9877. precedence. The remaining chapters of the old Packaging
  9878. Manual have also not been read in detail to ensure that there
  9879. are not parts which have been left out. Both of these will be
  9880. done in due course.
  9881. </p>
  9882. <p>
  9883. Certain parts of the Packaging manual were integrated into the
  9884. Policy Manual proper, and removed from the appendices. Links
  9885. have been placed from the old locations to the new ones.
  9886. </p>
  9887. <p>
  9888. <prgn>dpkg</prgn> is a suite of programs for creating binary
  9889. package files and installing and removing them on Unix
  9890. systems.<footnote>
  9891. <prgn>dpkg</prgn> is targeted primarily at Debian, but may
  9892. work on or be ported to other systems.
  9893. </footnote>
  9894. </p>
  9895. <p>
  9896. The binary packages are designed for the management of
  9897. installed executable programs (usually compiled binaries) and
  9898. their associated data, though source code examples and
  9899. documentation are provided as part of some packages.</p>
  9900. <p>
  9901. This manual describes the technical aspects of creating Debian
  9902. binary packages (<file>.deb</file> files). It documents the
  9903. behavior of the package management programs
  9904. <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
  9905. they interact with packages.</p>
  9906. <p>
  9907. This manual does not go into detail about the options and
  9908. usage of the package building and installation tools. It
  9909. should therefore be read in conjunction with those programs'
  9910. man pages.
  9911. </p>
  9912. <p>
  9913. The utility programs which are provided with <prgn>dpkg</prgn>
  9914. not described in detail here, are documented in their man pages.
  9915. </p>
  9916. <p>
  9917. It is assumed that the reader is reasonably familiar with the
  9918. <prgn>dpkg</prgn> System Administrators' manual.
  9919. Unfortunately this manual does not yet exist.
  9920. </p>
  9921. <p>
  9922. The Debian version of the FSF's GNU hello program is provided as
  9923. an example for people wishing to create Debian packages. However,
  9924. while the examples are helpful, they do not replace the need to
  9925. read and follow the Policy and Programmer's Manual.</p>
  9926. </appendix>
  9927. <appendix id="pkg-binarypkg">
  9928. <heading>Binary packages (from old Packaging Manual)</heading>
  9929. <p>
  9930. See <manref name="deb" section="5"> and <ref id="pkg-controlarea">.
  9931. </p>
  9932. <sect id="pkg-bincreating"><heading>Creating package files -
  9933. <prgn>dpkg-deb</prgn>
  9934. </heading>
  9935. <p>
  9936. All manipulation of binary package files is done by
  9937. <prgn>dpkg-deb</prgn>; it's the only program that has
  9938. knowledge of the format. (<prgn>dpkg-deb</prgn> may be
  9939. invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
  9940. will spot that the options requested are appropriate to
  9941. <prgn>dpkg-deb</prgn> and invoke that instead with the same
  9942. arguments.)
  9943. </p>
  9944. <p>
  9945. In order to create a binary package you must make a
  9946. directory tree which contains all the files and directories
  9947. you want to have in the file system data part of the package.
  9948. In Debian-format source packages this directory is usually
  9949. <file>debian/tmp</file>, relative to the top of the package's
  9950. source tree.
  9951. </p>
  9952. <p>
  9953. They should have the locations (relative to the root of the
  9954. directory tree you're constructing) ownerships and
  9955. permissions which you want them to have on the system when
  9956. they are installed.
  9957. </p>
  9958. <p>
  9959. With current versions of <prgn>dpkg</prgn> the uid/username
  9960. and gid/groupname mappings for the users and groups being
  9961. used should be the same on the system where the package is
  9962. built and the one where it is installed.
  9963. </p>
  9964. <p>
  9965. You need to add one special directory to the root of the
  9966. miniature file system tree you're creating:
  9967. <prgn>DEBIAN</prgn>. It should contain the control
  9968. information files, notably the binary package control file
  9969. (see <ref id="pkg-controlfile">).
  9970. </p>
  9971. <p>
  9972. The <prgn>DEBIAN</prgn> directory will not appear in the
  9973. file system archive of the package, and so won't be installed
  9974. by <prgn>dpkg</prgn> when the package is unpacked.
  9975. </p>
  9976. <p>
  9977. When you've prepared the package, you should invoke:
  9978. <example>
  9979. dpkg --build <var>directory</var>
  9980. </example>
  9981. </p>
  9982. <p>
  9983. This will build the package in
  9984. <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
  9985. that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
  9986. it invokes <prgn>dpkg-deb</prgn> with the same arguments to
  9987. build the package.)
  9988. </p>
  9989. <p>
  9990. See the man page <manref name="dpkg-deb" section="8"> for details of how
  9991. to examine the contents of this newly-created file. You may find the
  9992. output of following commands enlightening:
  9993. <example>
  9994. dpkg-deb --info <var>filename</var>.deb
  9995. dpkg-deb --contents <var>filename</var>.deb
  9996. dpkg --contents <var>filename</var>.deb
  9997. </example>
  9998. To view the copyright file for a package you could use this command:
  9999. <example>
  10000. dpkg --fsys-tarfile <var>filename</var>.deb | tar xOf - --wildcards \*/copyright | pager
  10001. </example>
  10002. </p>
  10003. </sect>
  10004. <sect id="pkg-controlarea">
  10005. <heading>Package control information files</heading>
  10006. <p>
  10007. The control information portion of a binary package is a
  10008. collection of files with names known to <prgn>dpkg</prgn>.
  10009. It will treat the contents of these files specially - some
  10010. of them contain information used by <prgn>dpkg</prgn> when
  10011. installing or removing the package; others are scripts which
  10012. the package maintainer wants <prgn>dpkg</prgn> to run.
  10013. </p>
  10014. <p>
  10015. It is possible to put other files in the package control
  10016. information file area, but this is not generally a good idea
  10017. (though they will largely be ignored).
  10018. </p>
  10019. <p>
  10020. Here is a brief list of the control information files supported
  10021. by <prgn>dpkg</prgn> and a summary of what they're used for.
  10022. </p>
  10023. <p>
  10024. <taglist>
  10025. <tag><tt>control</tt>
  10026. <item>
  10027. <p>
  10028. This is the key description file used by
  10029. <prgn>dpkg</prgn>. It specifies the package's name
  10030. and version, gives its description for the user,
  10031. states its relationships with other packages, and so
  10032. forth. See <ref id="sourcecontrolfiles"> and
  10033. <ref id="binarycontrolfiles">.
  10034. </p>
  10035. <p>
  10036. It is usually generated automatically from information
  10037. in the source package by the
  10038. <prgn>dpkg-gencontrol</prgn> program, and with
  10039. assistance from <prgn>dpkg-shlibdeps</prgn>.
  10040. See <ref id="pkg-sourcetools">.
  10041. </p>
  10042. </item>
  10043. <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
  10044. <tt>prerm</tt>
  10045. </tag>
  10046. <item>
  10047. <p>
  10048. These are executable files (usually scripts) which
  10049. <prgn>dpkg</prgn> runs during installation, upgrade
  10050. and removal of packages. They allow the package to
  10051. deal with matters which are particular to that package
  10052. or require more complicated processing than that
  10053. provided by <prgn>dpkg</prgn>. Details of when and
  10054. how they are called are in <ref id="maintainerscripts">.
  10055. </p>
  10056. <p>
  10057. It is very important to make these scripts idempotent.
  10058. See <ref id="idempotency">.
  10059. </p>
  10060. <p>
  10061. The maintainer scripts are not guaranteed to run with a
  10062. controlling terminal and may not be able to interact with
  10063. the user. See <ref id="controllingterminal">.
  10064. </p>
  10065. </item>
  10066. <tag><tt>conffiles</tt>
  10067. </tag>
  10068. <item>
  10069. This file contains a list of configuration files which
  10070. are to be handled automatically by <prgn>dpkg</prgn>
  10071. (see <ref id="pkg-conffiles">). Note that not necessarily
  10072. every configuration file should be listed here.
  10073. </item>
  10074. <tag><tt>shlibs</tt>
  10075. </tag>
  10076. <item>
  10077. This file contains a list of the shared libraries
  10078. supplied by the package, with dependency details for
  10079. each. This is used by <prgn>dpkg-shlibdeps</prgn>
  10080. when it determines what dependencies are required in a
  10081. package control file. The <tt>shlibs</tt> file format
  10082. is described on <ref id="shlibs">.
  10083. </item>
  10084. </taglist>
  10085. </p>
  10086. <sect id="pkg-controlfile">
  10087. <heading>The main control information file: <tt>control</tt></heading>
  10088. <p>
  10089. The most important control information file used by
  10090. <prgn>dpkg</prgn> when it installs a package is
  10091. <tt>control</tt>. It contains all the package's "vital
  10092. statistics".
  10093. </p>
  10094. <p>
  10095. The binary package control files of packages built from
  10096. Debian sources are made by a special tool,
  10097. <prgn>dpkg-gencontrol</prgn>, which reads
  10098. <file>debian/control</file> and <file>debian/changelog</file> to
  10099. find the information it needs. See <ref id="pkg-sourcepkg"> for
  10100. more details.
  10101. </p>
  10102. <p>
  10103. The fields in binary package control files are listed in
  10104. <ref id="binarycontrolfiles">.
  10105. </p>
  10106. <p>
  10107. A description of the syntax of control files and the purpose
  10108. of the fields is available in <ref id="controlfields">.
  10109. </p>
  10110. </sect>
  10111. <sect>
  10112. <heading>Time Stamps</heading>
  10113. <p>
  10114. See <ref id="timestamps">.
  10115. </p>
  10116. </sect>
  10117. </appendix>
  10118. <appendix id="pkg-sourcepkg">
  10119. <heading>Source packages (from old Packaging Manual) </heading>
  10120. <p>
  10121. The Debian binary packages in the distribution are generated
  10122. from Debian sources, which are in a special format to assist
  10123. the easy and automatic building of binaries.
  10124. </p>
  10125. <sect id="pkg-sourcetools">
  10126. <heading>Tools for processing source packages</heading>
  10127. <p>
  10128. Various tools are provided for manipulating source packages;
  10129. they pack and unpack sources and help build of binary
  10130. packages and help manage the distribution of new versions.
  10131. </p>
  10132. <p>
  10133. They are introduced and typical uses described here; see
  10134. <manref name="dpkg-source" section="1"> for full
  10135. documentation about their arguments and operation.
  10136. </p>
  10137. <p>
  10138. For examples of how to construct a Debian source package,
  10139. and how to use those utilities that are used by Debian
  10140. source packages, please see the <prgn>hello</prgn> example
  10141. package.
  10142. </p>
  10143. <sect1 id="pkg-dpkg-source">
  10144. <heading>
  10145. <prgn>dpkg-source</prgn> - packs and unpacks Debian source
  10146. packages
  10147. </heading>
  10148. <p>
  10149. This program is frequently used by hand, and is also
  10150. called from package-independent automated building scripts
  10151. such as <prgn>dpkg-buildpackage</prgn>.
  10152. </p>
  10153. <p>
  10154. To unpack a package it is typically invoked with
  10155. <example>
  10156. dpkg-source -x <var>.../path/to/filename</var>.dsc
  10157. </example>
  10158. </p>
  10159. <p>
  10160. with the <file><var>filename</var>.tar.gz</file> and
  10161. <file><var>filename</var>.diff.gz</file> (if applicable) in
  10162. the same directory. It unpacks into
  10163. <file><var>package</var>-<var>version</var></file>, and if
  10164. applicable
  10165. <file><var>package</var>-<var>version</var>.orig</file>, in
  10166. the current directory.
  10167. </p>
  10168. <p>
  10169. To create a packed source archive it is typically invoked:
  10170. <example>
  10171. dpkg-source -b <var>package</var>-<var>version</var>
  10172. </example>
  10173. </p>
  10174. <p>
  10175. This will create the <file>.dsc</file>, <file>.tar.gz</file> and
  10176. <file>.diff.gz</file> (if appropriate) in the current
  10177. directory. <prgn>dpkg-source</prgn> does not clean the
  10178. source tree first - this must be done separately if it is
  10179. required.
  10180. </p>
  10181. <p>
  10182. See also <ref id="pkg-sourcearchives">.</p>
  10183. </sect1>
  10184. <sect1 id="pkg-dpkg-buildpackage">
  10185. <heading>
  10186. <prgn>dpkg-buildpackage</prgn> - overall package-building
  10187. control script
  10188. </heading>
  10189. <p>
  10190. See <manref name="dpkg-buildpackage" section="1">.
  10191. </p>
  10192. </sect1>
  10193. <sect1 id="pkg-dpkg-gencontrol">
  10194. <heading>
  10195. <prgn>dpkg-gencontrol</prgn> - generates binary package
  10196. control files
  10197. </heading>
  10198. <p>
  10199. This program is usually called from <file>debian/rules</file>
  10200. (see <ref id="pkg-sourcetree">) in the top level of the source
  10201. tree.
  10202. </p>
  10203. <p>
  10204. This is usually done just before the files and directories in the
  10205. temporary directory tree where the package is being built have their
  10206. permissions and ownerships set and the package is constructed using
  10207. <prgn>dpkg-deb/</prgn>
  10208. <footnote>
  10209. This is so that the control file which is produced has
  10210. the right permissions
  10211. </footnote>.
  10212. </p>
  10213. <p>
  10214. <prgn>dpkg-gencontrol</prgn> must be called after all the
  10215. files which are to go into the package have been placed in
  10216. the temporary build directory, so that its calculation of
  10217. the installed size of a package is correct.
  10218. </p>
  10219. <p>
  10220. It is also necessary for <prgn>dpkg-gencontrol</prgn> to
  10221. be run after <prgn>dpkg-shlibdeps</prgn> so that the
  10222. variable substitutions created by
  10223. <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
  10224. are available.
  10225. </p>
  10226. <p>
  10227. For a package which generates only one binary package, and
  10228. which builds it in <file>debian/tmp</file> relative to the top
  10229. of the source package, it is usually sufficient to call
  10230. <prgn>dpkg-gencontrol</prgn>.
  10231. </p>
  10232. <p>
  10233. Sources which build several binaries will typically need
  10234. something like:
  10235. <example>
  10236. dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
  10237. </example> The <tt>-P</tt> tells
  10238. <prgn>dpkg-gencontrol</prgn> that the package is being
  10239. built in a non-default directory, and the <tt>-p</tt>
  10240. tells it which package's control file should be generated.
  10241. </p>
  10242. <p>
  10243. <prgn>dpkg-gencontrol</prgn> also adds information to the
  10244. list of files in <file>debian/files</file>, for the benefit of
  10245. (for example) a future invocation of
  10246. <prgn>dpkg-genchanges</prgn>.</p>
  10247. </sect1>
  10248. <sect1 id="pkg-dpkg-shlibdeps">
  10249. <heading>
  10250. <prgn>dpkg-shlibdeps</prgn> - calculates shared library
  10251. dependencies
  10252. </heading>
  10253. <p>
  10254. See <manref name="dpkg-shlibdeps" section="1">.
  10255. </p>
  10256. </sect1>
  10257. <sect1 id="pkg-dpkg-distaddfile">
  10258. <heading>
  10259. <prgn>dpkg-distaddfile</prgn> - adds a file to
  10260. <file>debian/files</file>
  10261. </heading>
  10262. <p>
  10263. Some packages' uploads need to include files other than
  10264. the source and binary package files.
  10265. </p>
  10266. <p>
  10267. <prgn>dpkg-distaddfile</prgn> adds a file to the
  10268. <file>debian/files</file> file so that it will be included in
  10269. the <file>.changes</file> file when
  10270. <prgn>dpkg-genchanges</prgn> is run.
  10271. </p>
  10272. <p>
  10273. It is usually invoked from the <tt>binary</tt> target of
  10274. <file>debian/rules</file>:
  10275. <example>
  10276. dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
  10277. </example>
  10278. The <var>filename</var> is relative to the directory where
  10279. <prgn>dpkg-genchanges</prgn> will expect to find it - this
  10280. is usually the directory above the top level of the source
  10281. tree. The <file>debian/rules</file> target should put the
  10282. file there just before or just after calling
  10283. <prgn>dpkg-distaddfile</prgn>.
  10284. </p>
  10285. <p>
  10286. The <var>section</var> and <var>priority</var> are passed
  10287. unchanged into the resulting <file>.changes</file> file.
  10288. </p>
  10289. </sect1>
  10290. <sect1 id="pkg-dpkg-genchanges">
  10291. <heading>
  10292. <prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file>
  10293. upload control file
  10294. </heading>
  10295. <p>
  10296. See <manref name="dpkg-genchanges" section="1">.
  10297. </p>
  10298. </sect1>
  10299. <sect1 id="pkg-dpkg-parsechangelog">
  10300. <heading>
  10301. <prgn>dpkg-parsechangelog</prgn> - produces parsed
  10302. representation of a changelog
  10303. </heading>
  10304. <p>
  10305. See <manref name="dpkg-parsechangelog" section="1">.
  10306. </p>
  10307. </sect1>
  10308. <sect1 id="pkg-dpkg-architecture">
  10309. <heading>
  10310. <prgn>dpkg-architecture</prgn> - information about the build and
  10311. host system
  10312. </heading>
  10313. <p>
  10314. See <manref name="dpkg-architecture" section="1">.
  10315. </p>
  10316. </sect1>
  10317. </sect>
  10318. <sect id="pkg-sourcetree">
  10319. <heading>The Debian package source tree</heading>
  10320. <p>
  10321. The source archive scheme described later is intended to
  10322. allow a Debian package source tree with some associated
  10323. control information to be reproduced and transported easily.
  10324. The Debian package source tree is a version of the original
  10325. program with certain files added for the benefit of the
  10326. packaging process, and with any other changes required
  10327. made to the rest of the source code and installation
  10328. scripts.
  10329. </p>
  10330. <p>
  10331. The extra files created for Debian are in the subdirectory
  10332. <file>debian</file> of the top level of the Debian package
  10333. source tree. They are described below.
  10334. </p>
  10335. <sect1 id="pkg-debianrules">
  10336. <heading><file>debian/rules</file> - the main building script</heading>
  10337. <p>
  10338. See <ref id="debianrules">.
  10339. </p>
  10340. </sect1>
  10341. <sect1 id="pkg-srcsubstvars">
  10342. <heading><file>debian/substvars</file> and variable substitutions</heading>
  10343. <p>
  10344. See <ref id="substvars">.
  10345. </p>
  10346. </sect1>
  10347. <sect1>
  10348. <heading><file>debian/files</file></heading>
  10349. <p>
  10350. See <ref id="debianfiles">.
  10351. </p>
  10352. </sect1>
  10353. <sect1><heading><file>debian/tmp</file>
  10354. </heading>
  10355. <p>
  10356. This is the canonical temporary location for the
  10357. construction of binary packages by the <tt>binary</tt>
  10358. target. The directory <file>tmp</file> serves as the root of
  10359. the file system tree as it is being constructed (for
  10360. example, by using the package's upstream makefiles install
  10361. targets and redirecting the output there), and it also
  10362. contains the <tt>DEBIAN</tt> subdirectory. See <ref
  10363. id="pkg-bincreating">.
  10364. </p>
  10365. <p>
  10366. If several binary packages are generated from the same
  10367. source tree it is usual to use several
  10368. <file>debian/tmp<var>something</var></file> directories, for
  10369. example <file>tmp-a</file> or <file>tmp-doc</file>.
  10370. </p>
  10371. <p>
  10372. Whatever <file>tmp</file> directories are created and used by
  10373. <tt>binary</tt> must of course be removed by the
  10374. <tt>clean</tt> target.</p></sect1>
  10375. </sect>
  10376. <sect id="pkg-sourcearchives"><heading>Source packages as archives
  10377. </heading>
  10378. <p>
  10379. As it exists on the FTP site, a Debian source package
  10380. consists of three related files. You must have the right
  10381. versions of all three to be able to use them.
  10382. </p>
  10383. <p>
  10384. <taglist>
  10385. <tag>Debian source control file - <tt>.dsc</tt></tag>
  10386. <item>
  10387. This file is a control file used by <prgn>dpkg-source</prgn>
  10388. to extract a source package.
  10389. See <ref id="debiansourcecontrolfiles">.
  10390. </item>
  10391. <tag>
  10392. Original source archive -
  10393. <file>
  10394. <var>package</var>_<var>upstream-version</var>.orig.tar.gz
  10395. </file>
  10396. </tag>
  10397. <item>
  10398. <p>
  10399. This is a compressed (with <tt>gzip -9</tt>)
  10400. <prgn>tar</prgn> file containing the source code from
  10401. the upstream authors of the program.
  10402. </p>
  10403. </item>
  10404. <tag>
  10405. Debian package diff -
  10406. <file>
  10407. <var>package</var>_<var>upstream_version-revision</var>.diff.gz
  10408. </file>
  10409. </tag>
  10410. <item>
  10411. <p>
  10412. This is a unified context diff (<tt>diff -u</tt>)
  10413. giving the changes which are required to turn the
  10414. original source into the Debian source. These changes
  10415. may only include editing and creating plain files.
  10416. The permissions of files, the targets of symbolic
  10417. links and the characteristics of special files or
  10418. pipes may not be changed and no files may be removed
  10419. or renamed.
  10420. </p>
  10421. <p>
  10422. All the directories in the diff must exist, except the
  10423. <file>debian</file> subdirectory of the top of the source
  10424. tree, which will be created by
  10425. <prgn>dpkg-source</prgn> if necessary when unpacking.
  10426. </p>
  10427. <p>
  10428. The <prgn>dpkg-source</prgn> program will
  10429. automatically make the <file>debian/rules</file> file
  10430. executable (see below).</p></item>
  10431. </taglist>
  10432. </p>
  10433. <p>
  10434. If there is no original source code - for example, if the
  10435. package is specially prepared for Debian or the Debian
  10436. maintainer is the same as the upstream maintainer - the
  10437. format is slightly different: then there is no diff, and the
  10438. tarfile is named
  10439. <file><var>package</var>_<var>version</var>.tar.gz</file>,
  10440. and preferably contains a directory named
  10441. <file><var>package</var>-<var>version</var></file>.
  10442. </p>
  10443. </sect>
  10444. <sect>
  10445. <heading>Unpacking a Debian source package without <prgn>dpkg-source</prgn></heading>
  10446. <p>
  10447. <tt>dpkg-source -x</tt> is the recommended way to unpack a
  10448. Debian source package. However, if it is not available it
  10449. is possible to unpack a Debian source archive as follows:
  10450. <enumlist compact="compact">
  10451. <item>
  10452. <p>
  10453. Untar the tarfile, which will create a <file>.orig</file>
  10454. directory.</p>
  10455. </item>
  10456. <item>
  10457. <p>Rename the <file>.orig</file> directory to
  10458. <file><var>package</var>-<var>version</var></file>.</p>
  10459. </item>
  10460. <item>
  10461. <p>
  10462. Create the subdirectory <file>debian</file> at the top of
  10463. the source tree.</p>
  10464. </item>
  10465. <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
  10466. </item>
  10467. <item><p>Untar the tarfile again if you want a copy of the original
  10468. source code alongside the Debian version.</p>
  10469. </item>
  10470. </enumlist>
  10471. <p>
  10472. It is not possible to generate a valid Debian source archive
  10473. without using <prgn>dpkg-source</prgn>. In particular,
  10474. attempting to use <prgn>diff</prgn> directly to generate the
  10475. <file>.diff.gz</file> file will not work.
  10476. </p>
  10477. <sect1>
  10478. <heading>Restrictions on objects in source packages</heading>
  10479. <p>
  10480. The source package may not contain any hard links
  10481. <footnote>
  10482. This is not currently detected when building source
  10483. packages, but only when extracting
  10484. them.
  10485. </footnote>
  10486. <footnote>
  10487. Hard links may be permitted at some point in the
  10488. future, but would require a fair amount of
  10489. work.
  10490. </footnote>, device special files, sockets or setuid or
  10491. setgid files.
  10492. <footnote>
  10493. Setgid directories are allowed.
  10494. </footnote>
  10495. </p>
  10496. <p>
  10497. The source packaging tools manage the changes between the
  10498. original and Debian source using <prgn>diff</prgn> and
  10499. <prgn>patch</prgn>. Turning the original source tree as
  10500. included in the <file>.orig.tar.gz</file> into the Debian
  10501. package source must not involve any changes which cannot be
  10502. handled by these tools. Problematic changes which cause
  10503. <prgn>dpkg-source</prgn> to halt with an error when
  10504. building the source package are:
  10505. <list compact="compact">
  10506. <item><p>Adding or removing symbolic links, sockets or pipes.</p>
  10507. </item>
  10508. <item><p>Changing the targets of symbolic links.</p>
  10509. </item>
  10510. <item><p>Creating directories, other than <file>debian</file>.</p>
  10511. </item>
  10512. <item><p>Changes to the contents of binary files.</p></item>
  10513. </list> Changes which cause <prgn>dpkg-source</prgn> to
  10514. print a warning but continue anyway are:
  10515. <list compact="compact">
  10516. <item>
  10517. <p>
  10518. Removing files, directories or symlinks.
  10519. <footnote>
  10520. Renaming a file is not treated specially - it is
  10521. seen as the removal of the old file (which
  10522. generates a warning, but is otherwise ignored),
  10523. and the creation of the new one.
  10524. </footnote>
  10525. </p>
  10526. </item>
  10527. <item>
  10528. <p>
  10529. Changed text files which are missing the usual final
  10530. newline (either in the original or the modified
  10531. source tree).
  10532. </p>
  10533. </item>
  10534. </list>
  10535. Changes which are not represented, but which are not detected by
  10536. <prgn>dpkg-source</prgn>, are:
  10537. <list compact="compact">
  10538. <item><p>Changing the permissions of files (other than
  10539. <file>debian/rules</file>) and directories.</p></item>
  10540. </list>
  10541. </p>
  10542. <p>
  10543. The <file>debian</file> directory and <file>debian/rules</file>
  10544. are handled specially by <prgn>dpkg-source</prgn> - before
  10545. applying the changes it will create the <file>debian</file>
  10546. directory, and afterwards it will make
  10547. <file>debian/rules</file> world-executable.
  10548. </p>
  10549. </sect1>
  10550. </sect>
  10551. </appendix>
  10552. <appendix id="pkg-controlfields">
  10553. <heading>Control files and their fields (from old Packaging Manual)</heading>
  10554. <p>
  10555. Many of the tools in the <prgn>dpkg</prgn> suite manipulate
  10556. data in a common format, known as control files. Binary and
  10557. source packages have control data as do the <file>.changes</file>
  10558. files which control the installation of uploaded files, and
  10559. <prgn>dpkg</prgn>'s internal databases are in a similar
  10560. format.
  10561. </p>
  10562. <sect>
  10563. <heading>Syntax of control files</heading>
  10564. <p>
  10565. See <ref id="controlsyntax">.
  10566. </p>
  10567. <p>
  10568. It is important to note that there are several fields which
  10569. are optional as far as <prgn>dpkg</prgn> and the related
  10570. tools are concerned, but which must appear in every Debian
  10571. package, or whose omission may cause problems.
  10572. </p>
  10573. </sect>
  10574. <sect>
  10575. <heading>List of fields</heading>
  10576. <p>
  10577. See <ref id="controlfieldslist">.
  10578. </p>
  10579. <p>
  10580. This section now contains only the fields that didn't belong
  10581. to the Policy manual.
  10582. </p>
  10583. <sect1 id="pkg-f-Filename">
  10584. <heading><tt>Filename</tt> and <tt>MSDOS-Filename</tt></heading>
  10585. <p>
  10586. These fields in <tt>Packages</tt> files give the
  10587. filename(s) of (the parts of) a package in the
  10588. distribution directories, relative to the root of the
  10589. Debian hierarchy. If the package has been split into
  10590. several parts the parts are all listed in order, separated
  10591. by spaces.
  10592. </p>
  10593. </sect1>
  10594. <sect1 id="pkg-f-Size">
  10595. <heading><tt>Size</tt> and <tt>MD5sum</tt></heading>
  10596. <p>
  10597. These fields in <file>Packages</file> files give the size (in
  10598. bytes, expressed in decimal) and MD5 checksum of the
  10599. file(s) which make(s) up a binary package in the
  10600. distribution. If the package is split into several parts
  10601. the values for the parts are listed in order, separated by
  10602. spaces.
  10603. </p>
  10604. </sect1>
  10605. <sect1 id="pkg-f-Status">
  10606. <heading><tt>Status</tt></heading>
  10607. <p>
  10608. This field in <prgn>dpkg</prgn>'s status file records
  10609. whether the user wants a package installed, removed or
  10610. left alone, whether it is broken (requiring
  10611. re-installation) or not and what its current state on the
  10612. system is. Each of these pieces of information is a
  10613. single word.
  10614. </p>
  10615. </sect1>
  10616. <sect1 id="pkg-f-Config-Version">
  10617. <heading><tt>Config-Version</tt></heading>
  10618. <p>
  10619. If a package is not installed or not configured, this
  10620. field in <prgn>dpkg</prgn>'s status file records the last
  10621. version of the package which was successfully
  10622. configured.
  10623. </p>
  10624. </sect1>
  10625. <sect1 id="pkg-f-Conffiles">
  10626. <heading><tt>Conffiles</tt></heading>
  10627. <p>
  10628. This field in <prgn>dpkg</prgn>'s status file contains
  10629. information about the automatically-managed configuration
  10630. files held by a package. This field should <em>not</em>
  10631. appear anywhere in a package!
  10632. </p>
  10633. </sect1>
  10634. <sect1>
  10635. <heading>Obsolete fields</heading>
  10636. <p>
  10637. These are still recognized by <prgn>dpkg</prgn> but should
  10638. not appear anywhere any more.
  10639. <taglist compact="compact">
  10640. <tag><tt>Revision</tt></tag>
  10641. <tag><tt>Package-Revision</tt></tag>
  10642. <tag><tt>Package_Revision</tt></tag>
  10643. <item>
  10644. The Debian revision part of the package version was
  10645. at one point in a separate control field. This
  10646. field went through several names.
  10647. </item>
  10648. <tag><tt>Recommended</tt></tag>
  10649. <item>Old name for <tt>Recommends</tt>.</item>
  10650. <tag><tt>Optional</tt></tag>
  10651. <item>Old name for <tt>Suggests</tt>.</item>
  10652. <tag><tt>Class</tt></tag>
  10653. <item>Old name for <tt>Priority</tt>.</item>
  10654. </taglist>
  10655. </p>
  10656. </sect1>
  10657. </sect>
  10658. </appendix>
  10659. <appendix id="pkg-conffiles">
  10660. <heading>Configuration file handling (from old Packaging Manual)</heading>
  10661. <p>
  10662. <prgn>dpkg</prgn> can do a certain amount of automatic
  10663. handling of package configuration files.
  10664. </p>
  10665. <p>
  10666. Whether this mechanism is appropriate depends on a number of
  10667. factors, but basically there are two approaches to any
  10668. particular configuration file.
  10669. </p>
  10670. <p>
  10671. The easy method is to ship a best-effort configuration in the
  10672. package, and use <prgn>dpkg</prgn>'s conffile mechanism to
  10673. handle updates. If the user is unlikely to want to edit the
  10674. file, but you need them to be able to without losing their
  10675. changes, and a new package with a changed version of the file
  10676. is only released infrequently, this is a good approach.
  10677. </p>
  10678. <p>
  10679. The hard method is to build the configuration file from
  10680. scratch in the <prgn>postinst</prgn> script, and to take the
  10681. responsibility for fixing any mistakes made in earlier
  10682. versions of the package automatically. This will be
  10683. appropriate if the file is likely to need to be different on
  10684. each system.
  10685. </p>
  10686. <sect><heading>Automatic handling of configuration files by
  10687. <prgn>dpkg</prgn>
  10688. </heading>
  10689. <p>
  10690. A package may contain a control information file called
  10691. <tt>conffiles</tt>. This file should be a list of filenames
  10692. of configuration files needing automatic handling, separated
  10693. by newlines. The filenames should be absolute pathnames,
  10694. and the files referred to should actually exist in the
  10695. package.
  10696. </p>
  10697. <p>
  10698. When a package is upgraded <prgn>dpkg</prgn> will process
  10699. the configuration files during the configuration stage,
  10700. shortly before it runs the package's <prgn>postinst</prgn>
  10701. script,
  10702. </p>
  10703. <p>
  10704. For each file it checks to see whether the version of the
  10705. file included in the package is the same as the one that was
  10706. included in the last version of the package (the one that is
  10707. being upgraded from); it also compares the version currently
  10708. installed on the system with the one shipped with the last
  10709. version.
  10710. </p>
  10711. <p>
  10712. If neither the user nor the package maintainer has changed
  10713. the file, it is left alone. If one or the other has changed
  10714. their version, then the changed version is preferred - i.e.,
  10715. if the user edits their file, but the package maintainer
  10716. doesn't ship a different version, the user's changes will
  10717. stay, silently, but if the maintainer ships a new version
  10718. and the user hasn't edited it the new version will be
  10719. installed (with an informative message). If both have
  10720. changed their version the user is prompted about the problem
  10721. and must resolve the differences themselves.
  10722. </p>
  10723. <p>
  10724. The comparisons are done by calculating the MD5 message
  10725. digests of the files, and storing the MD5 of the file as it
  10726. was included in the most recent version of the package.
  10727. </p>
  10728. <p>
  10729. When a package is installed for the first time
  10730. <prgn>dpkg</prgn> will install the file that comes with it,
  10731. unless that would mean overwriting a file already on the
  10732. file system.
  10733. </p>
  10734. <p>
  10735. However, note that <prgn>dpkg</prgn> will <em>not</em>
  10736. replace a conffile that was removed by the user (or by a
  10737. script). This is necessary because with some programs a
  10738. missing file produces an effect hard or impossible to
  10739. achieve in another way, so that a missing file needs to be
  10740. kept that way if the user did it.
  10741. </p>
  10742. <p>
  10743. Note that a package should <em>not</em> modify a
  10744. <prgn>dpkg</prgn>-handled conffile in its maintainer
  10745. scripts. Doing this will lead to <prgn>dpkg</prgn> giving
  10746. the user confusing and possibly dangerous options for
  10747. conffile update when the package is upgraded.</p>
  10748. </sect>
  10749. <sect><heading>Fully-featured maintainer script configuration
  10750. handling
  10751. </heading>
  10752. <p>
  10753. For files which contain site-specific information such as
  10754. the hostname and networking details and so forth, it is
  10755. better to create the file in the package's
  10756. <prgn>postinst</prgn> script.
  10757. </p>
  10758. <p>
  10759. This will typically involve examining the state of the rest
  10760. of the system to determine values and other information, and
  10761. may involve prompting the user for some information which
  10762. can't be obtained some other way.
  10763. </p>
  10764. <p>
  10765. When using this method there are a couple of important
  10766. issues which should be considered:
  10767. </p>
  10768. <p>
  10769. If you discover a bug in the program which generates the
  10770. configuration file, or if the format of the file changes
  10771. from one version to the next, you will have to arrange for
  10772. the postinst script to do something sensible - usually this
  10773. will mean editing the installed configuration file to remove
  10774. the problem or change the syntax. You will have to do this
  10775. very carefully, since the user may have changed the file,
  10776. perhaps to fix the very problem that your script is trying
  10777. to deal with - you will have to detect these situations and
  10778. deal with them correctly.
  10779. </p>
  10780. <p>
  10781. If you do go down this route it's probably a good idea to
  10782. make the program that generates the configuration file(s) a
  10783. separate program in <file>/usr/sbin</file>, by convention called
  10784. <file><var>package</var>config</file> and then run that if
  10785. appropriate from the post-installation script. The
  10786. <tt><var>package</var>config</tt> program should not
  10787. unquestioningly overwrite an existing configuration - if its
  10788. mode of operation is geared towards setting up a package for
  10789. the first time (rather than any arbitrary reconfiguration
  10790. later) you should have it check whether the configuration
  10791. already exists, and require a <tt>--force</tt> flag to
  10792. overwrite it.</p></sect>
  10793. </appendix>
  10794. <appendix id="pkg-alternatives"><heading>Alternative versions of
  10795. an interface - <prgn>update-alternatives</prgn> (from old
  10796. Packaging Manual)
  10797. </heading>
  10798. <p>
  10799. When several packages all provide different versions of the
  10800. same program or file it is useful to have the system select a
  10801. default, but to allow the system administrator to change it
  10802. and have their decisions respected.
  10803. </p>
  10804. <p>
  10805. For example, there are several versions of the <prgn>vi</prgn>
  10806. editor, and there is no reason to prevent all of them from
  10807. being installed at once, each under their own name
  10808. (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
  10809. Nevertheless it is desirable to have the name <tt>vi</tt>
  10810. refer to something, at least by default.
  10811. </p>
  10812. <p>
  10813. If all the packages involved cooperate, this can be done with
  10814. <prgn>update-alternatives</prgn>.
  10815. </p>
  10816. <p>
  10817. Each package provides its own version under its own name, and
  10818. calls <prgn>update-alternatives</prgn> in its postinst to
  10819. register its version (and again in its prerm to deregister
  10820. it).
  10821. </p>
  10822. <p>
  10823. See the man page <manref name="update-alternatives"
  10824. section="8"> for details.
  10825. </p>
  10826. <p>
  10827. If <prgn>update-alternatives</prgn> does not seem appropriate
  10828. you may wish to consider using diversions instead.</p>
  10829. </appendix>
  10830. <appendix id="pkg-diversions"><heading>Diversions - overriding a
  10831. package's version of a file (from old Packaging Manual)
  10832. </heading>
  10833. <p>
  10834. It is possible to have <prgn>dpkg</prgn> not overwrite a file
  10835. when it reinstalls the package it belongs to, and to have it
  10836. put the file from the package somewhere else instead.
  10837. </p>
  10838. <p>
  10839. This can be used locally to override a package's version of a
  10840. file, or by one package to override another's version (or
  10841. provide a wrapper for it).
  10842. </p>
  10843. <p>
  10844. Before deciding to use a diversion, read <ref
  10845. id="pkg-alternatives"> to see if you really want a diversion
  10846. rather than several alternative versions of a program.
  10847. </p>
  10848. <p>
  10849. There is a diversion list, which is read by <prgn>dpkg</prgn>,
  10850. and updated by a special program <prgn>dpkg-divert</prgn>.
  10851. Please see <manref name="dpkg-divert" section="8"> for full
  10852. details of its operation.
  10853. </p>
  10854. <p>
  10855. When a package wishes to divert a file from another, it should
  10856. call <prgn>dpkg-divert</prgn> in its preinst to add the
  10857. diversion and rename the existing file. For example,
  10858. supposing that a <prgn>smailwrapper</prgn> package wishes to
  10859. install a wrapper around <file>/usr/sbin/smail</file>:
  10860. <example>
  10861. dpkg-divert --package smailwrapper --add --rename \
  10862. --divert /usr/sbin/smail.real /usr/sbin/smail
  10863. </example> The <tt>--package smailwrapper</tt> ensures that
  10864. <prgn>smailwrapper</prgn>'s copy of <file>/usr/sbin/smail</file>
  10865. can bypass the diversion and get installed as the true version.
  10866. It's safe to add the diversion unconditionally on upgrades since
  10867. it will be left unchanged if it already exists, but
  10868. <prgn>dpkg-divert</prgn> will display a message. To suppress that
  10869. message, make the command conditional on the version from which
  10870. the package is being upgraded:
  10871. <example>
  10872. if [ upgrade != "$1" ] || dpkg --compare-versions "$2" lt 1.0-2; then
  10873. dpkg-divert --package smailwrapper --add --rename \
  10874. --divert /usr/sbin/smail.real /usr/sbin/smail
  10875. fi
  10876. </example> where <tt>1.0-2</tt> is the version at which the
  10877. diversion was first added to the package. Running the command
  10878. during abort-upgrade is pointless but harmless.
  10879. </p>
  10880. <p>
  10881. The postrm has to do the reverse:
  10882. <example>
  10883. if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then
  10884. dpkg-divert --package smailwrapper --remove --rename \
  10885. --divert /usr/sbin/smail.real /usr/sbin/smail
  10886. fi
  10887. </example> If the diversion was added at a particular version, the
  10888. postrm should also handle the failure case of upgrading from an
  10889. older version (unless the older version is so old that direct
  10890. upgrades are no longer supported):
  10891. <example>
  10892. if [ abort-upgrade = "$1" ] && dpkg --compare-versions "$2" lt 1.0-2; then
  10893. dpkg-divert --package smailwrapper --remove --rename \
  10894. --divert /usr/sbin/smail.real /usr/sbin/smail
  10895. fi
  10896. </example> where <tt>1.0-2</tt> is the version at which the
  10897. diversion was first added to the package. The postrm should not
  10898. remove the diversion on upgrades both because there's no reason to
  10899. remove the diversion only to immediately re-add it and since the
  10900. postrm of the old package is run after unpacking so the removal of
  10901. the diversion will fail.
  10902. </p>
  10903. <p>
  10904. Do not attempt to divert a file which is vitally important for
  10905. the system's operation - when using <prgn>dpkg-divert</prgn>
  10906. there is a time, after it has been diverted but before
  10907. <prgn>dpkg</prgn> has installed the new version, when the file
  10908. does not exist.</p>
  10909. <p>
  10910. Do not attempt to divert a conffile, as <prgn>dpkg</prgn> does not
  10911. handle it well.
  10912. </p>
  10913. </appendix>
  10914. </book>
  10915. </debiandoc>
  10916. <!-- Local variables: -->
  10917. <!-- indent-tabs-mode: t -->
  10918. <!-- End: -->
  10919. <!-- vim:set ai sts=2 sw=2 tw=76: -->