dev-manual-common-tasks.xml 495 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
  3. [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
  4. <chapter id='extendpoky'>
  5. <title>Common Tasks</title>
  6. <para>
  7. This chapter describes fundamental procedures such as creating layers,
  8. adding new software packages, extending or customizing images,
  9. porting work to new hardware (adding a new machine), and so forth.
  10. You will find that the procedures documented here occur often in the
  11. development cycle using the Yocto Project.
  12. </para>
  13. <section id="understanding-and-creating-layers">
  14. <title>Understanding and Creating Layers</title>
  15. <para>
  16. The OpenEmbedded build system supports organizing
  17. <link linkend='metadata'>Metadata</link> into multiple layers.
  18. Layers allow you to isolate different types of customizations from
  19. each other.
  20. You might find it tempting to keep everything in one layer when
  21. working on a single project.
  22. However, the more modular your Metadata, the easier
  23. it is to cope with future changes.
  24. </para>
  25. <para>
  26. To illustrate how layers are used to keep things modular, consider
  27. machine customizations.
  28. These types of customizations typically reside in a special layer,
  29. rather than a general layer, called a Board Support Package (BSP)
  30. Layer.
  31. Furthermore, the machine customizations should be isolated from
  32. recipes and Metadata that support a new GUI environment,
  33. for example.
  34. This situation gives you a couple of layers: one for the machine
  35. configurations, and one for the GUI environment.
  36. It is important to understand, however, that the BSP layer can
  37. still make machine-specific additions to recipes within the GUI
  38. environment layer without polluting the GUI layer itself
  39. with those machine-specific changes.
  40. You can accomplish this through a recipe that is a BitBake append
  41. (<filename>.bbappend</filename>) file, which is described later
  42. in this section.
  43. </para>
  44. <para>
  45. </para>
  46. <section id='yocto-project-layers'>
  47. <title>Layers</title>
  48. <para>
  49. The <link linkend='source-directory'>Source Directory</link>
  50. contains both general layers and BSP
  51. layers right out of the box.
  52. You can easily identify layers that ship with a
  53. Yocto Project release in the Source Directory by their
  54. folder names.
  55. Folders that represent layers typically have names that begin with
  56. the string <filename>meta-</filename>.
  57. <note>
  58. It is not a requirement that a layer name begin with the
  59. prefix <filename>meta-</filename>, but it is a commonly
  60. accepted standard in the Yocto Project community.
  61. </note>
  62. For example, when you set up the Source Directory structure,
  63. you will see several layers:
  64. <filename>meta</filename>,
  65. <filename>meta-skeleton</filename>,
  66. <filename>meta-selftest</filename>,
  67. <filename>meta-yocto</filename>, and
  68. <filename>meta-yocto-bsp</filename>.
  69. Each of these folders represents a distinct layer.
  70. </para>
  71. <para>
  72. As another example, if you set up a local copy of the
  73. <filename>meta-intel</filename> Git repository
  74. and then explore the folder of that general layer,
  75. you will discover many Intel-specific BSP layers inside.
  76. For more information on BSP layers, see the
  77. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  78. section in the Yocto Project Board Support Package (BSP)
  79. Developer's Guide.
  80. </para>
  81. </section>
  82. <section id='creating-your-own-layer'>
  83. <title>Creating Your Own Layer</title>
  84. <para>
  85. It is very easy to create your own layers to use with the
  86. OpenEmbedded build system.
  87. The Yocto Project ships with scripts that speed up creating
  88. general layers and BSP layers.
  89. This section describes the steps you perform by hand to create
  90. a layer so that you can better understand them.
  91. For information about the layer-creation scripts, see the
  92. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
  93. section in the Yocto Project Board Support Package (BSP)
  94. Developer's Guide and the
  95. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  96. section further down in this manual.
  97. </para>
  98. <para>
  99. Follow these general steps to create your layer:
  100. <orderedlist>
  101. <listitem><para><emphasis>Check Existing Layers:</emphasis>
  102. Before creating a new layer, you should be sure someone
  103. has not already created a layer containing the Metadata
  104. you need.
  105. You can see the
  106. <ulink url='http://layers.openembedded.org/layerindex/layers/'><filename>OpenEmbedded Metadata Index</filename></ulink>
  107. for a list of layers from the OpenEmbedded community
  108. that can be used in the Yocto Project.
  109. </para></listitem>
  110. <listitem><para><emphasis>Create a Directory:</emphasis>
  111. Create the directory for your layer.
  112. While not strictly required, prepend the name of the
  113. folder with the string <filename>meta-</filename>.
  114. For example:
  115. <literallayout class='monospaced'>
  116. meta-mylayer
  117. meta-GUI_xyz
  118. meta-mymachine
  119. </literallayout>
  120. </para></listitem>
  121. <listitem><para><emphasis>Create a Layer Configuration
  122. File:</emphasis>
  123. Inside your new layer folder, you need to create a
  124. <filename>conf/layer.conf</filename> file.
  125. It is easiest to take an existing layer configuration
  126. file and copy that to your layer's
  127. <filename>conf</filename> directory and then modify the
  128. file as needed.</para>
  129. <para>The
  130. <filename>meta-yocto-bsp/conf/layer.conf</filename> file
  131. demonstrates the required syntax:
  132. <literallayout class='monospaced'>
  133. # We have a conf and classes directory, add to BBPATH
  134. BBPATH .= ":${LAYERDIR}"
  135. # We have recipes-* directories, add to BBFILES
  136. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  137. ${LAYERDIR}/recipes-*/*/*.bbappend"
  138. BBFILE_COLLECTIONS += "yoctobsp"
  139. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  140. BBFILE_PRIORITY_yoctobsp = "5"
  141. LAYERVERSION_yoctobsp = "3"
  142. </literallayout></para>
  143. <para>Here is an explanation of the example:
  144. <itemizedlist>
  145. <listitem><para>The configuration and
  146. classes directory is appended to
  147. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>.
  148. <note>
  149. All non-distro layers, which include all BSP
  150. layers, are expected to append the layer
  151. directory to the
  152. <filename>BBPATH</filename>.
  153. On the other hand, distro layers, such as
  154. <filename>meta-yocto</filename>, can choose
  155. to enforce their own precedence over
  156. <filename>BBPATH</filename>.
  157. For an example of that syntax, see the
  158. <filename>layer.conf</filename> file for
  159. the <filename>meta-yocto</filename> layer.
  160. </note></para></listitem>
  161. <listitem><para>The recipes for the layers are
  162. appended to
  163. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'>BBFILES</ulink></filename>.
  164. </para></listitem>
  165. <listitem><para>The
  166. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</ulink></filename>
  167. variable is then appended with the layer name.
  168. </para></listitem>
  169. <listitem><para>The
  170. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'>BBFILE_PATTERN</ulink></filename>
  171. variable is set to a regular expression and is
  172. used to match files from
  173. <filename>BBFILES</filename> into a particular
  174. layer.
  175. In this case,
  176. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  177. is used to make <filename>BBFILE_PATTERN</filename> match within the
  178. layer's path.</para></listitem>
  179. <listitem><para>The
  180. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'>BBFILE_PRIORITY</ulink></filename>
  181. variable then assigns a priority to the layer.
  182. Applying priorities is useful in situations
  183. where the same recipe might appear in multiple
  184. layers and allows you to choose the layer
  185. that takes precedence.</para></listitem>
  186. <listitem><para>The
  187. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'>LAYERVERSION</ulink></filename>
  188. variable optionally specifies the version of a
  189. layer as a single number.</para></listitem>
  190. </itemizedlist></para>
  191. <para>Note the use of the
  192. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  193. variable, which expands to the directory of the current
  194. layer.</para>
  195. <para>Through the use of the <filename>BBPATH</filename>
  196. variable, BitBake locates class files
  197. (<filename>.bbclass</filename>),
  198. configuration files, and files that are included
  199. with <filename>include</filename> and
  200. <filename>require</filename> statements.
  201. For these cases, BitBake uses the first file that
  202. matches the name found in <filename>BBPATH</filename>.
  203. This is similar to the way the <filename>PATH</filename>
  204. variable is used for binaries.
  205. It is recommended, therefore, that you use unique
  206. class and configuration
  207. filenames in your custom layer.</para></listitem>
  208. <listitem><para><emphasis>Add Content:</emphasis> Depending
  209. on the type of layer, add the content.
  210. If the layer adds support for a machine, add the machine
  211. configuration in a <filename>conf/machine/</filename>
  212. file within the layer.
  213. If the layer adds distro policy, add the distro
  214. configuration in a <filename>conf/distro/</filename>
  215. file within the layer.
  216. If the layer introduces new recipes, put the recipes
  217. you need in <filename>recipes-*</filename>
  218. subdirectories within the layer.
  219. <note>In order to be compliant with the Yocto Project,
  220. a layer must contain a
  221. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout-readme'>README file.</ulink>
  222. </note></para></listitem>
  223. </orderedlist>
  224. </para>
  225. </section>
  226. <section id='best-practices-to-follow-when-creating-layers'>
  227. <title>Best Practices to Follow When Creating Layers</title>
  228. <para>
  229. To create layers that are easier to maintain and that will
  230. not impact builds for other machines, you should consider the
  231. information in the following sections.
  232. </para>
  233. <section id='avoid-overlaying-entire-recipes'>
  234. <title>Avoid "Overlaying" Entire Recipes</title>
  235. <para>
  236. Avoid "overlaying" entire recipes from other layers in your
  237. configuration.
  238. In other words, do not copy an entire recipe into your
  239. layer and then modify it.
  240. Rather, use an append file (<filename>.bbappend</filename>)
  241. to override
  242. only those parts of the original recipe you need to modify.
  243. </para>
  244. </section>
  245. <section id='avoid-duplicating-include-files'>
  246. <title>Avoid Duplicating Include Files</title>
  247. <para>
  248. Avoid duplicating include files.
  249. Use append files (<filename>.bbappend</filename>)
  250. for each recipe
  251. that uses an include file.
  252. Or, if you are introducing a new recipe that requires
  253. the included file, use the path relative to the original
  254. layer directory to refer to the file.
  255. For example, use
  256. <filename>require recipes-core/somepackage/somefile.inc</filename>
  257. instead of <filename>require somefile.inc</filename>.
  258. If you're finding you have to overlay the include file,
  259. it could indicate a deficiency in the include file in
  260. the layer to which it originally belongs.
  261. If this is the case, you need to address that deficiency
  262. instead of overlaying the include file.
  263. </para>
  264. <para>
  265. For example, consider how support plug-ins for the Qt 4
  266. database are configured.
  267. The Source Directory does not have MySQL or PostgreSQL.
  268. However, OpenEmbedded's layer <filename>meta-oe</filename>
  269. does.
  270. Consequently, <filename>meta-oe</filename> uses
  271. append files to modify the
  272. <filename>QT_SQL_DRIVER_FLAGS</filename> variable to
  273. enable the appropriate plug-ins.
  274. This variable was added to the <filename>qt4.inc</filename>
  275. include file in the Source Directory specifically to allow
  276. the <filename>meta-oe</filename> layer to be able to control
  277. which plug-ins are built.
  278. </para>
  279. </section>
  280. <section id='structure-your-layers'>
  281. <title>Structure Your Layers</title>
  282. <para>
  283. Proper use of overrides within append files and placement
  284. of machine-specific files within your layer can ensure that
  285. a build is not using the wrong Metadata and negatively
  286. impacting a build for a different machine.
  287. Following are some examples:
  288. <itemizedlist>
  289. <listitem><para><emphasis>Modifying Variables to Support
  290. a Different Machine:</emphasis>
  291. Suppose you have a layer named
  292. <filename>meta-one</filename> that adds support
  293. for building machine "one".
  294. To do so, you use an append file named
  295. <filename>base-files.bbappend</filename> and
  296. create a dependency on "foo" by altering the
  297. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  298. variable:
  299. <literallayout class='monospaced'>
  300. DEPENDS = "foo"
  301. </literallayout>
  302. The dependency is created during any build that
  303. includes the layer
  304. <filename>meta-one</filename>.
  305. However, you might not want this dependency
  306. for all machines.
  307. For example, suppose you are building for
  308. machine "two" but your
  309. <filename>bblayers.conf</filename> file has the
  310. <filename>meta-one</filename> layer included.
  311. During the build, the
  312. <filename>base-files</filename> for machine
  313. "two" will also have the dependency on
  314. <filename>foo</filename>.</para>
  315. <para>To make sure your changes apply only when
  316. building machine "one", use a machine override
  317. with the <filename>DEPENDS</filename> statement:
  318. <literallayout class='monospaced'>
  319. DEPENDS_one = "foo"
  320. </literallayout>
  321. You should follow the same strategy when using
  322. <filename>_append</filename> and
  323. <filename>_prepend</filename> operations:
  324. <literallayout class='monospaced'>
  325. DEPENDS_append_one = " foo"
  326. DEPENDS_prepend_one = "foo "
  327. </literallayout>
  328. As an actual example, here's a line from the recipe for
  329. the OProfile profiler, which lists an extra build-time
  330. dependency when building specifically for 64-bit PowerPC:
  331. <literallayout class='monospaced'>
  332. DEPENDS_append_powerpc64 = " libpfm4"
  333. </literallayout>
  334. <note>
  335. Avoiding "+=" and "=+" and using
  336. machine-specific
  337. <filename>_append</filename>
  338. and <filename>_prepend</filename> operations
  339. is recommended as well.
  340. </note></para></listitem>
  341. <listitem><para><emphasis>Place Machine-Specific Files
  342. in Machine-Specific Locations:</emphasis>
  343. When you have a base recipe, such as
  344. <filename>base-files.bb</filename>, that
  345. contains a
  346. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  347. statement to a file, you can use an append file
  348. to cause the build to use your own version of
  349. the file.
  350. For example, an append file in your layer at
  351. <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename>
  352. could extend
  353. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  354. using
  355. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  356. as follows:
  357. <literallayout class='monospaced'>
  358. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  359. </literallayout>
  360. The build for machine "one" will pick up your
  361. machine-specific file as long as you have the
  362. file in
  363. <filename>meta-one/recipes-core/base-files/base-files/</filename>.
  364. However, if you are building for a different
  365. machine and the
  366. <filename>bblayers.conf</filename> file includes
  367. the <filename>meta-one</filename> layer and
  368. the location of your machine-specific file is
  369. the first location where that file is found
  370. according to <filename>FILESPATH</filename>,
  371. builds for all machines will also use that
  372. machine-specific file.</para>
  373. <para>You can make sure that a machine-specific
  374. file is used for a particular machine by putting
  375. the file in a subdirectory specific to the
  376. machine.
  377. For example, rather than placing the file in
  378. <filename>meta-one/recipes-core/base-files/base-files/</filename>
  379. as shown above, put it in
  380. <filename>meta-one/recipes-core/base-files/base-files/one/</filename>.
  381. Not only does this make sure the file is used
  382. only when building for machine "one", but the
  383. build process locates the file more quickly.</para>
  384. <para>In summary, you need to place all files
  385. referenced from <filename>SRC_URI</filename>
  386. in a machine-specific subdirectory within the
  387. layer in order to restrict those files to
  388. machine-specific builds.</para></listitem>
  389. </itemizedlist>
  390. </para>
  391. </section>
  392. <section id='other-recommendations'>
  393. <title>Other Recommendations</title>
  394. <para>
  395. We also recommend the following:
  396. <itemizedlist>
  397. <listitem><para>Store custom layers in a Git repository
  398. that uses the
  399. <filename>meta-<replaceable>layer_name</replaceable></filename> format.
  400. </para></listitem>
  401. <listitem><para>Clone the repository alongside other
  402. <filename>meta</filename> directories in the
  403. <link linkend='source-directory'>Source Directory</link>.
  404. </para></listitem>
  405. </itemizedlist>
  406. Following these recommendations keeps your Source Directory and
  407. its configuration entirely inside the Yocto Project's core
  408. base.
  409. </para>
  410. </section>
  411. </section>
  412. <section id='enabling-your-layer'>
  413. <title>Enabling Your Layer</title>
  414. <para>
  415. Before the OpenEmbedded build system can use your new layer,
  416. you need to enable it.
  417. To enable your layer, simply add your layer's path to the
  418. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename>
  419. variable in your <filename>conf/bblayers.conf</filename> file,
  420. which is found in the
  421. <link linkend='build-directory'>Build Directory</link>.
  422. The following example shows how to enable a layer named
  423. <filename>meta-mylayer</filename>:
  424. <literallayout class='monospaced'>
  425. LCONF_VERSION = "6"
  426. BBPATH = "${TOPDIR}"
  427. BBFILES ?= ""
  428. BBLAYERS ?= " \
  429. $HOME/poky/meta \
  430. $HOME/poky/meta-yocto \
  431. $HOME/poky/meta-yocto-bsp \
  432. $HOME/poky/meta-mylayer \
  433. "
  434. BBLAYERS_NON_REMOVABLE ?= " \
  435. $HOME/poky/meta \
  436. $HOME/poky/meta-yocto \
  437. "
  438. </literallayout>
  439. </para>
  440. <para>
  441. BitBake parses each <filename>conf/layer.conf</filename> file
  442. as specified in the <filename>BBLAYERS</filename> variable
  443. within the <filename>conf/bblayers.conf</filename> file.
  444. During the processing of each
  445. <filename>conf/layer.conf</filename> file, BitBake adds the
  446. recipes, classes and configurations contained within the
  447. particular layer to the source directory.
  448. </para>
  449. </section>
  450. <section id='using-bbappend-files'>
  451. <title>Using .bbappend Files</title>
  452. <para>
  453. Recipes used to append Metadata to other recipes are called
  454. BitBake append files.
  455. BitBake append files use the <filename>.bbappend</filename> file
  456. type suffix, while the corresponding recipes to which Metadata
  457. is being appended use the <filename>.bb</filename> file type
  458. suffix.
  459. </para>
  460. <para>
  461. A <filename>.bbappend</filename> file allows your layer to make
  462. additions or changes to the content of another layer's recipe
  463. without having to copy the other recipe into your layer.
  464. Your <filename>.bbappend</filename> file resides in your layer,
  465. while the main <filename>.bb</filename> recipe file to
  466. which you are appending Metadata resides in a different layer.
  467. </para>
  468. <para>
  469. Append files must have the same root names as their corresponding
  470. recipes.
  471. For example, the append file
  472. <filename>someapp_&DISTRO;.bbappend</filename> must apply to
  473. <filename>someapp_&DISTRO;.bb</filename>.
  474. This means the original recipe and append file names are version
  475. number-specific.
  476. If the corresponding recipe is renamed to update to a newer
  477. version, the corresponding <filename>.bbappend</filename> file must
  478. be renamed (and possibly updated) as well.
  479. During the build process, BitBake displays an error on starting
  480. if it detects a <filename>.bbappend</filename> file that does
  481. not have a corresponding recipe with a matching name.
  482. See the
  483. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink>
  484. variable for information on how to handle this error.
  485. </para>
  486. <para>
  487. Being able to append information to an existing recipe not only
  488. avoids duplication, but also automatically applies recipe
  489. changes in a different layer to your layer.
  490. If you were copying recipes, you would have to manually merge
  491. changes as they occur.
  492. </para>
  493. <para>
  494. As an example, consider the main formfactor recipe and a
  495. corresponding formfactor append file both from the
  496. <link linkend='source-directory'>Source Directory</link>.
  497. Here is the main formfactor recipe, which is named
  498. <filename>formfactor_0.0.bb</filename> and located in the
  499. "meta" layer at
  500. <filename>meta/recipes-bsp/formfactor</filename>:
  501. <literallayout class='monospaced'>
  502. SUMMARY = "Device formfactor information"
  503. SECTION = "base"
  504. LICENSE = "MIT"
  505. LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
  506. file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  507. PR = "r45"
  508. SRC_URI = "file://config file://machconfig"
  509. S = "${WORKDIR}"
  510. PACKAGE_ARCH = "${MACHINE_ARCH}"
  511. INHIBIT_DEFAULT_DEPS = "1"
  512. do_install() {
  513. # Install file only if it has contents
  514. install -d ${D}${sysconfdir}/formfactor/
  515. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  516. if [ -s "${S}/machconfig" ]; then
  517. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  518. fi
  519. }
  520. </literallayout>
  521. In the main recipe, note the
  522. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  523. variable, which tells the OpenEmbedded build system where to
  524. find files during the build.
  525. </para>
  526. <para>
  527. Following is the append file, which is named
  528. <filename>formfactor_0.0.bbappend</filename> and is from the
  529. Crown Bay BSP Layer named
  530. <filename>meta-intel/meta-crownbay</filename>.
  531. The file is in <filename>recipes-bsp/formfactor</filename>:
  532. <literallayout class='monospaced'>
  533. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  534. </literallayout>
  535. </para>
  536. <para>
  537. By default, the build system uses the
  538. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  539. variable to locate files.
  540. This append file extends the locations by setting the
  541. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  542. variable.
  543. Setting this variable in the <filename>.bbappend</filename>
  544. file is the most reliable and recommended method for adding
  545. directories to the search path used by the build system
  546. to find files.
  547. </para>
  548. <para>
  549. The statement in this example extends the directories to include
  550. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-THISDIR'><filename>THISDIR</filename></ulink><filename>}/${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>,
  551. which resolves to a directory named
  552. <filename>formfactor</filename> in the same directory
  553. in which the append file resides (i.e.
  554. <filename>meta-intel/meta-crownbay/recipes-bsp/formfactor/formfactor</filename>.
  555. This implies that you must have the supporting directory
  556. structure set up that will contain any files or patches you
  557. will be including from the layer.
  558. </para>
  559. <para>
  560. Using the immediate expansion assignment operator
  561. <filename>:=</filename> is important because of the reference to
  562. <filename>THISDIR</filename>.
  563. The trailing colon character is important as it ensures that
  564. items in the list remain colon-separated.
  565. <note>
  566. <para>
  567. BitBake automatically defines the
  568. <filename>THISDIR</filename> variable.
  569. You should never set this variable yourself.
  570. Using "_prepend" ensures your path will
  571. be searched prior to other paths in the final list.
  572. </para>
  573. <para>
  574. Also, not all append files add extra files.
  575. Many append files simply exist to add build options
  576. (e.g. <filename>systemd</filename>).
  577. For these cases, it is not necessary to use the
  578. "_prepend" part of the statement.
  579. </para>
  580. </note>
  581. </para>
  582. </section>
  583. <section id='prioritizing-your-layer'>
  584. <title>Prioritizing Your Layer</title>
  585. <para>
  586. Each layer is assigned a priority value.
  587. Priority values control which layer takes precedence if there
  588. are recipe files with the same name in multiple layers.
  589. For these cases, the recipe file from the layer with a higher
  590. priority number takes precedence.
  591. Priority values also affect the order in which multiple
  592. <filename>.bbappend</filename> files for the same recipe are
  593. applied.
  594. You can either specify the priority manually, or allow the
  595. build system to calculate it based on the layer's dependencies.
  596. </para>
  597. <para>
  598. To specify the layer's priority manually, use the
  599. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  600. variable.
  601. For example:
  602. <literallayout class='monospaced'>
  603. BBFILE_PRIORITY_mylayer = "1"
  604. </literallayout>
  605. </para>
  606. <note>
  607. <para>It is possible for a recipe with a lower version number
  608. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  609. in a layer that has a higher priority to take precedence.</para>
  610. <para>Also, the layer priority does not currently affect the
  611. precedence order of <filename>.conf</filename>
  612. or <filename>.bbclass</filename> files.
  613. Future versions of BitBake might address this.</para>
  614. </note>
  615. </section>
  616. <section id='managing-layers'>
  617. <title>Managing Layers</title>
  618. <para>
  619. You can use the BitBake layer management tool to provide a view
  620. into the structure of recipes across a multi-layer project.
  621. Being able to generate output that reports on configured layers
  622. with their paths and priorities and on
  623. <filename>.bbappend</filename> files and their applicable
  624. recipes can help to reveal potential problems.
  625. </para>
  626. <para>
  627. Use the following form when running the layer management tool.
  628. <literallayout class='monospaced'>
  629. $ bitbake-layers <replaceable>command</replaceable> [<replaceable>arguments</replaceable>]
  630. </literallayout>
  631. The following list describes the available commands:
  632. <itemizedlist>
  633. <listitem><para><filename><emphasis>help:</emphasis></filename>
  634. Displays general help or help on a specified command.
  635. </para></listitem>
  636. <listitem><para><filename><emphasis>show-layers:</emphasis></filename>
  637. Shows the current configured layers.
  638. </para></listitem>
  639. <listitem><para><filename><emphasis>show-recipes:</emphasis></filename>
  640. Lists available recipes and the layers that provide them.
  641. </para></listitem>
  642. <listitem><para><filename><emphasis>show-overlayed:</emphasis></filename>
  643. Lists overlayed recipes.
  644. A recipe is overlayed when a recipe with the same name
  645. exists in another layer that has a higher layer
  646. priority.
  647. </para></listitem>
  648. <listitem><para><filename><emphasis>show-appends:</emphasis></filename>
  649. Lists <filename>.bbappend</filename> files and the
  650. recipe files to which they apply.
  651. </para></listitem>
  652. <listitem><para><filename><emphasis>show-cross-depends:</emphasis></filename>
  653. Lists dependency relationships between recipes that
  654. cross layer boundaries.
  655. </para></listitem>
  656. <listitem><para><filename><emphasis>flatten:</emphasis></filename>
  657. Flattens the layer configuration into a separate output
  658. directory.
  659. Flattening your layer configuration builds a "flattened"
  660. directory that contains the contents of all layers,
  661. with any overlayed recipes removed and any
  662. <filename>.bbappend</filename> files appended to the
  663. corresponding recipes.
  664. You might have to perform some manual cleanup of the
  665. flattened layer as follows:
  666. <itemizedlist>
  667. <listitem><para>Non-recipe files (such as patches)
  668. are overwritten.
  669. The flatten command shows a warning for these
  670. files.
  671. </para></listitem>
  672. <listitem><para>Anything beyond the normal layer
  673. setup has been added to the
  674. <filename>layer.conf</filename> file.
  675. Only the lowest priority layer's
  676. <filename>layer.conf</filename> is used.
  677. </para></listitem>
  678. <listitem><para>Overridden and appended items from
  679. <filename>.bbappend</filename> files need to be
  680. cleaned up.
  681. The contents of each
  682. <filename>.bbappend</filename> end up in the
  683. flattened recipe.
  684. However, if there are appended or changed
  685. variable values, you need to tidy these up
  686. yourself.
  687. Consider the following example.
  688. Here, the <filename>bitbake-layers</filename>
  689. command adds the line
  690. <filename>#### bbappended ...</filename> so that
  691. you know where the following lines originate:
  692. <literallayout class='monospaced'>
  693. ...
  694. DESCRIPTION = "A useful utility"
  695. ...
  696. EXTRA_OECONF = "&dash;&dash;enable-something"
  697. ...
  698. #### bbappended from meta-anotherlayer ####
  699. DESCRIPTION = "Customized utility"
  700. EXTRA_OECONF += "&dash;&dash;enable-somethingelse"
  701. </literallayout>
  702. Ideally, you would tidy up these utilities as
  703. follows:
  704. <literallayout class='monospaced'>
  705. ...
  706. DESCRIPTION = "Customized utility"
  707. ...
  708. EXTRA_OECONF = "&dash;&dash;enable-something &dash;&dash;enable-somethingelse"
  709. ...
  710. </literallayout></para></listitem>
  711. </itemizedlist></para></listitem>
  712. </itemizedlist>
  713. </para>
  714. </section>
  715. <section id='creating-a-general-layer-using-the-yocto-layer-script'>
  716. <title>Creating a General Layer Using the yocto-layer Script</title>
  717. <para>
  718. The <filename>yocto-layer</filename> script simplifies
  719. creating a new general layer.
  720. <note>
  721. For information on BSP layers, see the
  722. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  723. section in the Yocto Project Board Specific (BSP)
  724. Developer's Guide.
  725. </note>
  726. The default mode of the script's operation is to prompt you for
  727. information needed to generate the layer:
  728. <itemizedlist>
  729. <listitem><para>The layer priority.
  730. </para></listitem>
  731. <listitem><para>Whether or not to create a sample recipe.
  732. </para></listitem>
  733. <listitem><para>Whether or not to create a sample
  734. append file.
  735. </para></listitem>
  736. </itemizedlist>
  737. </para>
  738. <para>
  739. Use the <filename>yocto-layer create</filename> sub-command
  740. to create a new general layer.
  741. In its simplest form, you can create a layer as follows:
  742. <literallayout class='monospaced'>
  743. $ yocto-layer create mylayer
  744. </literallayout>
  745. The previous example creates a layer named
  746. <filename>meta-mylayer</filename> in the current directory.
  747. </para>
  748. <para>
  749. As the <filename>yocto-layer create</filename> command runs,
  750. default values for the prompts appear in brackets.
  751. Pressing enter without supplying anything for the prompts
  752. or pressing enter and providing an invalid response causes the
  753. script to accept the default value.
  754. Once the script completes, the new layer
  755. is created in the current working directory.
  756. The script names the layer by prepending
  757. <filename>meta-</filename> to the name you provide.
  758. </para>
  759. <para>
  760. Minimally, the script creates the following within the layer:
  761. <itemizedlist>
  762. <listitem><para><emphasis>The <filename>conf</filename>
  763. directory:</emphasis>
  764. This directory contains the layer's configuration file.
  765. The root name for the file is the same as the root name
  766. your provided for the layer (e.g.
  767. <filename><replaceable>layer</replaceable>.conf</filename>).
  768. </para></listitem>
  769. <listitem><para><emphasis>The
  770. <filename>COPYING.MIT</filename> file:</emphasis>
  771. The copyright and use notice for the software.
  772. </para></listitem>
  773. <listitem><para><emphasis>The <filename>README</filename>
  774. file:</emphasis>
  775. A file describing the contents of your new layer.
  776. </para></listitem>
  777. </itemizedlist>
  778. </para>
  779. <para>
  780. If you choose to generate a sample recipe file, the script
  781. prompts you for the name for the recipe and then creates it
  782. in <filename><replaceable>layer</replaceable>/recipes-example/example/</filename>.
  783. The script creates a <filename>.bb</filename> file and a
  784. directory, which contains a sample
  785. <filename>helloworld.c</filename> source file, along with
  786. a sample patch file.
  787. If you do not provide a recipe name, the script uses
  788. "example".
  789. </para>
  790. <para>
  791. If you choose to generate a sample append file, the script
  792. prompts you for the name for the file and then creates it
  793. in <filename><replaceable>layer</replaceable>/recipes-example-bbappend/example-bbappend/</filename>.
  794. The script creates a <filename>.bbappend</filename> file and a
  795. directory, which contains a sample patch file.
  796. If you do not provide a recipe name, the script uses
  797. "example".
  798. The script also prompts you for the version of the append file.
  799. The version should match the recipe to which the append file
  800. is associated.
  801. </para>
  802. <para>
  803. The easiest way to see how the <filename>yocto-layer</filename>
  804. script works is to experiment with the script.
  805. You can also read the usage information by entering the
  806. following:
  807. <literallayout class='monospaced'>
  808. $ yocto-layer help
  809. </literallayout>
  810. </para>
  811. <para>
  812. Once you create your general layer, you must add it to your
  813. <filename>bblayers.conf</filename> file.
  814. Here is an example where a layer named
  815. <filename>meta-mylayer</filename> is added:
  816. <literallayout class='monospaced'>
  817. BBLAYERS = ?" \
  818. /usr/local/src/yocto/meta \
  819. /usr/local/src/yocto/meta-yocto \
  820. /usr/local/src/yocto/meta-yocto-bsp \
  821. /usr/local/src/yocto/meta-mylayer \
  822. "
  823. BBLAYERS_NON_REMOVABLE ?= " \
  824. /usr/local/src/yocto/meta \
  825. /usr/local/src/yocto/meta-yocto \
  826. "
  827. </literallayout>
  828. Adding the layer to this file enables the build system to
  829. locate the layer during the build.
  830. </para>
  831. </section>
  832. </section>
  833. <section id='usingpoky-extend-customimage'>
  834. <title>Customizing Images</title>
  835. <para>
  836. You can customize images to satisfy particular requirements.
  837. This section describes several methods and provides guidelines for each.
  838. </para>
  839. <section id='usingpoky-extend-customimage-localconf'>
  840. <title>Customizing Images Using <filename>local.conf</filename></title>
  841. <para>
  842. Probably the easiest way to customize an image is to add a
  843. package by way of the <filename>local.conf</filename>
  844. configuration file.
  845. Because it is limited to local use, this method generally only
  846. allows you to add packages and is not as flexible as creating
  847. your own customized image.
  848. When you add packages using local variables this way, you need
  849. to realize that these variable changes are in effect for every
  850. build and consequently affect all images, which might not
  851. be what you require.
  852. </para>
  853. <para>
  854. To add a package to your image using the local configuration
  855. file, use the
  856. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  857. variable with the <filename>_append</filename> operator:
  858. <literallayout class='monospaced'>
  859. IMAGE_INSTALL_append = " strace"
  860. </literallayout>
  861. Use of the syntax is important - specifically, the space between
  862. the quote and the package name, which is
  863. <filename>strace</filename> in this example.
  864. This space is required since the <filename>_append</filename>
  865. operator does not add the space.
  866. </para>
  867. <para>
  868. Furthermore, you must use <filename>_append</filename> instead
  869. of the <filename>+=</filename> operator if you want to avoid
  870. ordering issues.
  871. The reason for this is because doing so unconditionally appends
  872. to the variable and avoids ordering problems due to the
  873. variable being set in image recipes and
  874. <filename>.bbclass</filename> files with operators like
  875. <filename>?=</filename>.
  876. Using <filename>_append</filename> ensures the operation takes
  877. affect.
  878. </para>
  879. <para>
  880. As shown in its simplest use,
  881. <filename>IMAGE_INSTALL_append</filename> affects all images.
  882. It is possible to extend the syntax so that the variable
  883. applies to a specific image only.
  884. Here is an example:
  885. <literallayout class='monospaced'>
  886. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  887. </literallayout>
  888. This example adds <filename>strace</filename> to the
  889. <filename>core-image-minimal</filename> image only.
  890. </para>
  891. <para>
  892. You can add packages using a similar approach through the
  893. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename>
  894. variable.
  895. If you use this variable, only
  896. <filename>core-image-*</filename> images are affected.
  897. </para>
  898. </section>
  899. <section id='usingpoky-extend-customimage-imagefeatures'>
  900. <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and
  901. <filename>EXTRA_IMAGE_FEATURES</filename></title>
  902. <para>
  903. Another method for customizing your image is to enable or
  904. disable high-level image features by using the
  905. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  906. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  907. variables.
  908. Although the functions for both variables are nearly equivalent,
  909. best practices dictate using <filename>IMAGE_FEATURES</filename>
  910. from within a recipe and using
  911. <filename>EXTRA_IMAGE_FEATURES</filename> from within
  912. your <filename>local.conf</filename> file, which is found in the
  913. <link linkend='build-directory'>Build Directory</link>.
  914. </para>
  915. <para>
  916. To understand how these features work, the best reference is
  917. <filename>meta/classes/core-image.bbclass</filename>.
  918. In summary, the file looks at the contents of the
  919. <filename>IMAGE_FEATURES</filename> variable and then maps
  920. those contents into a set of package groups.
  921. Based on this information, the build system automatically
  922. adds the appropriate packages to the
  923. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  924. variable.
  925. Effectively, you are enabling extra features by extending the
  926. class or creating a custom class for use with specialized image
  927. <filename>.bb</filename> files.
  928. </para>
  929. <para>
  930. Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable
  931. from within your local configuration file.
  932. Using a separate area from which to enable features with
  933. this variable helps you avoid overwriting the features in the
  934. image recipe that are enabled with
  935. <filename>IMAGE_FEATURES</filename>.
  936. The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added
  937. to <filename>IMAGE_FEATURES</filename> within
  938. <filename>meta/conf/bitbake.conf</filename>.
  939. </para>
  940. <para>
  941. To illustrate how you can use these variables to modify your
  942. image, consider an example that selects the SSH server.
  943. The Yocto Project ships with two SSH servers you can use
  944. with your images: Dropbear and OpenSSH.
  945. Dropbear is a minimal SSH server appropriate for
  946. resource-constrained environments, while OpenSSH is a
  947. well-known standard SSH server implementation.
  948. By default, the <filename>core-image-sato</filename> image
  949. is configured to use Dropbear.
  950. The <filename>core-image-full-cmdline</filename> and
  951. <filename>core-image-lsb</filename> images both
  952. include OpenSSH.
  953. The <filename>core-image-minimal</filename> image does not
  954. contain an SSH server.
  955. </para>
  956. <para>
  957. You can customize your image and change these defaults.
  958. Edit the <filename>IMAGE_FEATURES</filename> variable
  959. in your recipe or use the
  960. <filename>EXTRA_IMAGE_FEATURES</filename> in your
  961. <filename>local.conf</filename> file so that it configures the
  962. image you are working with to include
  963. <filename>ssh-server-dropbear</filename> or
  964. <filename>ssh-server-openssh</filename>.
  965. </para>
  966. <note>
  967. See the
  968. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  969. section in the Yocto Project Reference Manual for a complete
  970. list of image features that ship with the Yocto Project.
  971. </note>
  972. </section>
  973. <section id='usingpoky-extend-customimage-custombb'>
  974. <title>Customizing Images Using Custom .bb Files</title>
  975. <para>
  976. You can also customize an image by creating a custom recipe
  977. that defines additional software as part of the image.
  978. The following example shows the form for the two lines you need:
  979. <literallayout class='monospaced'>
  980. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  981. inherit core-image
  982. </literallayout>
  983. </para>
  984. <para>
  985. Defining the software using a custom recipe gives you total
  986. control over the contents of the image.
  987. It is important to use the correct names of packages in the
  988. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  989. variable.
  990. You must use the OpenEmbedded notation and not the Debian notation for the names
  991. (e.g. <filename>eglibc-dev</filename> instead of <filename>libc6-dev</filename>).
  992. </para>
  993. <para>
  994. The other method for creating a custom image is to base it on an existing image.
  995. For example, if you want to create an image based on <filename>core-image-sato</filename>
  996. but add the additional package <filename>strace</filename> to the image,
  997. copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a
  998. new <filename>.bb</filename> and add the following line to the end of the copy:
  999. <literallayout class='monospaced'>
  1000. IMAGE_INSTALL += "strace"
  1001. </literallayout>
  1002. </para>
  1003. </section>
  1004. <section id='usingpoky-extend-customimage-customtasks'>
  1005. <title>Customizing Images Using Custom Package Groups</title>
  1006. <para>
  1007. For complex custom images, the best approach for customizing
  1008. an image is to create a custom package group recipe that is
  1009. used to build the image or images.
  1010. A good example of a package group recipe is
  1011. <filename>meta/recipes-core/packagegroups/packagegroup-core-boot.bb</filename>.
  1012. The
  1013. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename>
  1014. variable lists the package group packages you wish to produce.
  1015. <filename>inherit packagegroup</filename> sets appropriate
  1016. default values and automatically adds <filename>-dev</filename>,
  1017. <filename>-dbg</filename>, and <filename>-ptest</filename>
  1018. complementary packages for every package specified in
  1019. <filename>PACKAGES</filename>.
  1020. Note that the inherit line should be towards
  1021. the top of the recipe, certainly before you set
  1022. <filename>PACKAGES</filename>.
  1023. For each package you specify in <filename>PACKAGES</filename>,
  1024. you can use
  1025. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename>
  1026. and
  1027. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename>
  1028. entries to provide a list of packages the parent task package
  1029. should contain.
  1030. Following is an example:
  1031. <literallayout class='monospaced'>
  1032. DESCRIPTION = "My Custom Package Groups"
  1033. inherit packagegroup
  1034. PACKAGES = "\
  1035. packagegroup-custom-apps \
  1036. packagegroup-custom-tools \
  1037. "
  1038. RDEPENDS_packagegroup-custom-apps = "\
  1039. dropbear \
  1040. portmap \
  1041. psplash"
  1042. RDEPENDS_packagegroup-custom-tools = "\
  1043. oprofile \
  1044. oprofileui-server \
  1045. lttng-control \
  1046. lttng-viewer"
  1047. RRECOMMENDS_packagegroup-custom-tools = "\
  1048. kernel-module-oprofile"
  1049. </literallayout>
  1050. </para>
  1051. <para>
  1052. In the previous example, two package group packages are created with their dependencies and their
  1053. recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and
  1054. <filename>packagegroup-custom-tools</filename>.
  1055. To build an image using these package group packages, you need to add
  1056. <filename>packagegroup-custom-apps</filename> and/or
  1057. <filename>packagegroup-custom-tools</filename> to
  1058. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>.
  1059. For other forms of image dependencies see the other areas of this section.
  1060. </para>
  1061. </section>
  1062. </section>
  1063. <section id='new-recipe-writing-a-new-recipe'>
  1064. <title>Writing a New Recipe</title>
  1065. <para>
  1066. Recipes (<filename>.bb</filename> files) are fundamental components
  1067. in the Yocto Project environment.
  1068. Each software component built by the OpenEmbedded build system
  1069. requires a recipe to define the component.
  1070. This section describes how to create, write, and test a new
  1071. recipe.
  1072. <note>
  1073. For information on variables that are useful for recipes and
  1074. for information about recipe naming issues, see the
  1075. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>"
  1076. section of the Yocto Project Reference Manual.
  1077. </note>
  1078. </para>
  1079. <section id='new-recipe-overview'>
  1080. <title>Overview</title>
  1081. <para>
  1082. The following figure shows the basic process for creating a
  1083. new recipe.
  1084. The remainder of the section provides details for the steps.
  1085. <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" />
  1086. </para>
  1087. </section>
  1088. <section id='new-recipe-locate-a-base-recipe'>
  1089. <title>Locate a Base Recipe</title>
  1090. <para>
  1091. Before writing a recipe from scratch, it is often useful to
  1092. discover whether someone else has already written one that
  1093. meets (or comes close to meeting) your needs.
  1094. The Yocto Project and OpenEmbedded communities maintain many
  1095. recipes that might be candidates for what you are doing.
  1096. You can find a good central index of these recipes in the
  1097. <ulink url='http://layers.openembedded.org'>OpenEmbedded metadata index</ulink>.
  1098. </para>
  1099. <para>
  1100. Working from an existing recipe or a skeleton recipe is the
  1101. best way to get started.
  1102. Here are some points on both methods:
  1103. <itemizedlist>
  1104. <listitem><para><emphasis>Locate and modify a recipe that
  1105. is close to what you want to do:</emphasis>
  1106. This method works when you are familiar with the
  1107. current recipe space.
  1108. The method does not work so well for those new to
  1109. the Yocto Project or writing recipes.</para>
  1110. <para>Some risks associated with this method are
  1111. using a recipe that has areas totally unrelated to
  1112. what you are trying to accomplish with your recipe,
  1113. not recognizing areas of the recipe that you might
  1114. have to add from scratch, and so forth.
  1115. All these risks stem from unfamiliarity with the
  1116. existing recipe space.</para></listitem>
  1117. <listitem><para><emphasis>Use and modify the following
  1118. skeleton recipe:</emphasis>
  1119. <literallayout class='monospaced'>
  1120. SUMMARY = ""
  1121. HOMEPAGE = ""
  1122. LICENSE = ""
  1123. LIC_FILES_CHKSUM = ""
  1124. SRC_URI = ""
  1125. SRC_URI[md5sum] = ""
  1126. SRC_URI[sha256sum] = ""
  1127. S = "${WORKDIR}/${PN}-${PV}"
  1128. inherit <replaceable>stuff</replaceable>
  1129. </literallayout>
  1130. Modifying this recipe is the recommended method for
  1131. creating a new recipe.
  1132. The recipe provides the fundamental areas that you need
  1133. to include, exclude, or alter to fit your needs.
  1134. </para></listitem>
  1135. </itemizedlist>
  1136. </para>
  1137. </section>
  1138. <section id='new-recipe-storing-and-naming-the-recipe'>
  1139. <title>Storing and Naming the Recipe</title>
  1140. <para>
  1141. Once you have your base recipe, you should put it in your
  1142. own layer and name it appropriately.
  1143. Locating it correctly ensures that the OpenEmbedded build
  1144. system can find it when you use BitBake to process the
  1145. recipe.
  1146. </para>
  1147. <itemizedlist>
  1148. <listitem><para><emphasis>Storing Your Recipe:</emphasis>
  1149. The OpenEmbedded build system locates your recipe
  1150. through the layer's <filename>conf/layer.conf</filename>
  1151. file and the
  1152. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>
  1153. variable.
  1154. This variable sets up a path from which the build system can
  1155. locate recipes.
  1156. Here is the typical use:
  1157. <literallayout class='monospaced'>
  1158. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  1159. ${LAYERDIR}/recipes-*/*/*.bbappend"
  1160. </literallayout>
  1161. Consequently, you need to be sure you locate your new recipe
  1162. inside your layer such that it can be found.</para>
  1163. <para>You can find more information on how layers are
  1164. structured in the
  1165. "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
  1166. section.</para></listitem>
  1167. <listitem><para><emphasis>Naming Your Recipe:</emphasis>
  1168. When you name your recipe, you need to follow this naming
  1169. convention:
  1170. <literallayout class='monospaced'>
  1171. <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb
  1172. </literallayout>
  1173. Use lower-cased characters and do not include the reserved
  1174. suffixes <filename>-native</filename>,
  1175. <filename>-cross</filename>, <filename>-initial</filename>,
  1176. or <filename>-dev</filename> casually (i.e. do not use them
  1177. as part of your recipe name unless the string applies).
  1178. Here are some examples:
  1179. <literallayout class='monospaced'>
  1180. cups_1.7.0.bb
  1181. gawk_4.0.2.bb
  1182. irssi_0.8.16-rc1.bb
  1183. </literallayout></para></listitem>
  1184. </itemizedlist>
  1185. </section>
  1186. <section id='understanding-recipe-syntax'>
  1187. <title>Understanding Recipe Syntax</title>
  1188. <para>
  1189. Understanding recipe file syntax is important for
  1190. writing recipes.
  1191. The following list overviews the basic items that make up a
  1192. BitBake recipe file.
  1193. For more complete BitBake syntax descriptions, see the
  1194. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  1195. chapter of the BitBake User Manual.
  1196. <itemizedlist>
  1197. <listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis>
  1198. Variable assignments allow a value to be assigned to a
  1199. variable.
  1200. The assignment can be static text or might include
  1201. the contents of other variables.
  1202. In addition to the assignment, appending and prepending
  1203. operations are also supported.</para>
  1204. <para>The following example shows some of the ways
  1205. you can use variables in recipes:
  1206. <literallayout class='monospaced'>
  1207. S = "${WORKDIR}/postfix-${PV}"
  1208. CFLAGS += "-DNO_ASM"
  1209. SRC_URI_append = " file://fixup.patch"
  1210. </literallayout>
  1211. </para></listitem>
  1212. <listitem><para><emphasis>Functions:</emphasis>
  1213. Functions provide a series of actions to be performed.
  1214. You usually use functions to override the default
  1215. implementation of a task function or to complement
  1216. a default function (i.e. append or prepend to an
  1217. existing function).
  1218. Standard functions use <filename>sh</filename> shell
  1219. syntax, although access to OpenEmbedded variables and
  1220. internal methods are also available.</para>
  1221. <para>The following is an example function from the
  1222. <filename>sed</filename> recipe:
  1223. <literallayout class='monospaced'>
  1224. do_install () {
  1225. autotools_do_install
  1226. install -d ${D}${base_bindir}
  1227. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  1228. rmdir ${D}${bindir}/
  1229. }
  1230. </literallayout>
  1231. It is also possible to implement new functions that
  1232. are called between existing tasks as long as the
  1233. new functions are not replacing or complementing the
  1234. default functions.
  1235. You can implement functions in Python
  1236. instead of shell.
  1237. Both of these options are not seen in the majority of
  1238. recipes.</para></listitem>
  1239. <listitem><para><emphasis>Keywords:</emphasis>
  1240. BitBake recipes use only a few keywords.
  1241. You use keywords to include common
  1242. functions (<filename>inherit</filename>), load parts
  1243. of a recipe from other files
  1244. (<filename>include</filename> and
  1245. <filename>require</filename>) and export variables
  1246. to the environment (<filename>export</filename>).</para>
  1247. <para>The following example shows the use of some of
  1248. these keywords:
  1249. <literallayout class='monospaced'>
  1250. export POSTCONF = "${STAGING_BINDIR}/postconf"
  1251. inherit autoconf
  1252. require otherfile.inc
  1253. </literallayout>
  1254. </para></listitem>
  1255. <listitem><para><emphasis>Comments:</emphasis>
  1256. Any lines that begin with the hash character
  1257. (<filename>#</filename>) are treated as comment lines
  1258. and are ignored:
  1259. <literallayout class='monospaced'>
  1260. # This is a comment
  1261. </literallayout>
  1262. </para></listitem>
  1263. </itemizedlist>
  1264. </para>
  1265. <para>
  1266. This next list summarizes the most important and most commonly
  1267. used parts of the recipe syntax.
  1268. For more information on these parts of the syntax, you can
  1269. reference the
  1270. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>
  1271. chapter in the BitBake User Manual.
  1272. <itemizedlist>
  1273. <listitem><para><emphasis>Line Continuation: <filename>\</filename></emphasis> -
  1274. Use the backward slash (<filename>\</filename>)
  1275. character to split a statement over multiple lines.
  1276. Place the slash character at the end of the line that
  1277. is to be continued on the next line:
  1278. <literallayout class='monospaced'>
  1279. VAR = "A really long \
  1280. line"
  1281. </literallayout>
  1282. <note>
  1283. You cannot have any characters including spaces
  1284. or tabs after the slash character.
  1285. </note>
  1286. </para></listitem>
  1287. <listitem><para><emphasis>Using Variables: <filename>${...}</filename></emphasis> -
  1288. Use the <filename>${<replaceable>varname</replaceable>}</filename> syntax to
  1289. access the contents of a variable:
  1290. <literallayout class='monospaced'>
  1291. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  1292. </literallayout>
  1293. </para></listitem>
  1294. <listitem><para><emphasis>Quote All Assignments: <filename>"<replaceable>value</replaceable>"</filename></emphasis> -
  1295. Use double quotes around the value in all variable
  1296. assignments.
  1297. <literallayout class='monospaced'>
  1298. VAR1 = "${OTHERVAR}"
  1299. VAR2 = "The version is ${PV}"
  1300. </literallayout>
  1301. </para></listitem>
  1302. <listitem><para><emphasis>Conditional Assignment: <filename>?=</filename></emphasis> -
  1303. Conditional assignment is used to assign a value to
  1304. a variable, but only when the variable is currently
  1305. unset.
  1306. Use the question mark followed by the equal sign
  1307. (<filename>?=</filename>) to make a "soft" assignment
  1308. used for conditional assignment.
  1309. Typically, "soft" assignments are used in the
  1310. <filename>local.conf</filename> file for variables
  1311. that are allowed to come through from the external
  1312. environment.
  1313. </para>
  1314. <para>Here is an example where
  1315. <filename>VAR1</filename> is set to "New value" if
  1316. it is currently empty.
  1317. However, if <filename>VAR1</filename> has already been
  1318. set, it remains unchanged:
  1319. <literallayout class='monospaced'>
  1320. VAR1 ?= "New value"
  1321. </literallayout>
  1322. In this next example, <filename>VAR1</filename>
  1323. is left with the value "Original value":
  1324. <literallayout class='monospaced'>
  1325. VAR1 = "Original value"
  1326. VAR1 ?= "New value"
  1327. </literallayout>
  1328. </para></listitem>
  1329. <listitem><para><emphasis>Appending: <filename>+=</filename></emphasis> -
  1330. Use the plus character followed by the equals sign
  1331. (<filename>+=</filename>) to append values to existing
  1332. variables.
  1333. <note>
  1334. This operator adds a space between the existing
  1335. content of the variable and the new content.
  1336. </note></para>
  1337. <para>Here is an example:
  1338. <literallayout class='monospaced'>
  1339. SRC_URI += "file://fix-makefile.patch"
  1340. </literallayout>
  1341. </para></listitem>
  1342. <listitem><para><emphasis>Prepending: <filename>=+</filename></emphasis> -
  1343. Use the equals sign followed by the plus character
  1344. (<filename>=+</filename>) to prepend values to existing
  1345. variables.
  1346. <note>
  1347. This operator adds a space between the new content
  1348. and the existing content of the variable.
  1349. </note></para>
  1350. <para>Here is an example:
  1351. <literallayout class='monospaced'>
  1352. VAR =+ "Starts"
  1353. </literallayout>
  1354. </para></listitem>
  1355. <listitem><para><emphasis>Appending: <filename>_append</filename></emphasis> -
  1356. Use the <filename>_append</filename> operator to
  1357. append values to existing variables.
  1358. This operator does not add any additional space.
  1359. Also, the operator is applied after all the
  1360. <filename>+=</filename>, and
  1361. <filename>=+</filename> operators have been applied and
  1362. after all <filename>=</filename> assignments have
  1363. occurred.
  1364. </para>
  1365. <para>The following example shows the space being
  1366. explicitly added to the start to ensure the appended
  1367. value is not merged with the existing value:
  1368. <literallayout class='monospaced'>
  1369. SRC_URI_append = " file://fix-makefile.patch"
  1370. </literallayout>
  1371. You can also use the <filename>_append</filename>
  1372. operator with overrides, which results in the actions
  1373. only being performed for the specified target or
  1374. machine:
  1375. <literallayout class='monospaced'>
  1376. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  1377. </literallayout>
  1378. </para></listitem>
  1379. <listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> -
  1380. Use the <filename>_prepend</filename> operator to
  1381. prepend values to existing variables.
  1382. This operator does not add any additional space.
  1383. Also, the operator is applied after all the
  1384. <filename>+=</filename>, and
  1385. <filename>=+</filename> operators have been applied and
  1386. after all <filename>=</filename> assignments have
  1387. occurred.
  1388. </para>
  1389. <para>The following example shows the space being
  1390. explicitly added to the end to ensure the prepended
  1391. value is not merged with the existing value:
  1392. <literallayout class='monospaced'>
  1393. CFLAGS_prepend = "-I${S}/myincludes "
  1394. </literallayout>
  1395. You can also use the <filename>_prepend</filename>
  1396. operator with overrides, which results in the actions
  1397. only being performed for the specified target or
  1398. machine:
  1399. <literallayout class='monospaced'>
  1400. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  1401. </literallayout>
  1402. </para></listitem>
  1403. <listitem><para><emphasis>Overrides:</emphasis> -
  1404. You can use overrides to set a value conditionally,
  1405. typically based on how the recipe is being built.
  1406. For example, to set the
  1407. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  1408. variable's value to "standard/base" for any target
  1409. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  1410. except for qemuarm where it should be set to
  1411. "standard/arm-versatile-926ejs", you would do the
  1412. following:
  1413. <literallayout class='monospaced'>
  1414. KBRANCH = "standard/base"
  1415. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  1416. </literallayout>
  1417. Overrides are also used to separate alternate values
  1418. of a variable in other situations.
  1419. For example, when setting variables such as
  1420. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  1421. and
  1422. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  1423. that are specific to individual packages produced by
  1424. a recipe, you should always use an override that
  1425. specifies the name of the package.
  1426. </para></listitem>
  1427. <listitem><para><emphasis>Indentation:</emphasis>
  1428. Use spaces for indentation rather than than tabs.
  1429. For shell functions, both currently work.
  1430. However, it is a policy decision of the Yocto Project
  1431. to use tabs in shell functions.
  1432. Realize that some layers have a policy to use spaces
  1433. for all indentation.
  1434. </para></listitem>
  1435. <listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<replaceable>python_code</replaceable>}</filename></emphasis> -
  1436. For more advanced processing, it is possible to use
  1437. Python code during variable assignments (e.g.
  1438. search and replacement on a variable).</para>
  1439. <para>You indicate Python code using the
  1440. <filename>${@<replaceable>python_code</replaceable>}</filename>
  1441. syntax for the variable assignment:
  1442. <literallayout class='monospaced'>
  1443. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  1444. </literallayout>
  1445. </para></listitem>
  1446. <listitem><para><emphasis>Shell Function Syntax:</emphasis>
  1447. Write shell functions as if you were writing a shell
  1448. script when you describe a list of actions to take.
  1449. You should ensure that your script works with a generic
  1450. <filename>sh</filename> and that it does not require
  1451. any <filename>bash</filename> or other shell-specific
  1452. functionality.
  1453. The same considerations apply to various system
  1454. utilities (e.g. <filename>sed</filename>,
  1455. <filename>grep</filename>, <filename>awk</filename>,
  1456. and so forth) that you might wish to use.
  1457. If in doubt, you should check with multiple
  1458. implementations - including those from BusyBox.
  1459. </para></listitem>
  1460. </itemizedlist>
  1461. </para>
  1462. </section>
  1463. <section id='new-recipe-running-a-build-on-the-recipe'>
  1464. <title>Running a Build on the Recipe</title>
  1465. <para>
  1466. Creating a new recipe is usually an iterative process that
  1467. requires using BitBake to process the recipe multiple times in
  1468. order to progressively discover and add information to the
  1469. recipe file.
  1470. </para>
  1471. <para>
  1472. Assuming you have sourced a build environment setup script (i.e.
  1473. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  1474. or
  1475. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  1476. and you are in the
  1477. <link linkend='build-directory'>Build Directory</link>,
  1478. use BitBake to process your recipe.
  1479. All you need to provide is the
  1480. <filename><replaceable>basename</replaceable></filename> of the recipe as described
  1481. in the previous section:
  1482. <literallayout class='monospaced'>
  1483. $ bitbake <replaceable>basename</replaceable>
  1484. </literallayout>
  1485. </para>
  1486. <para>
  1487. During the build, the OpenEmbedded build system creates a
  1488. temporary work directory for each recipe
  1489. (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>)
  1490. where it keeps extracted source files, log files, intermediate
  1491. compilation and packaging files, and so forth.
  1492. </para>
  1493. <para>
  1494. The per-recipe temporary work directory is constructed as follows and
  1495. depends on several factors:
  1496. <literallayout class='monospaced'>
  1497. BASE_WORKDIR ?= "${TMPDIR}/work"
  1498. WORKDIR = "${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}"
  1499. </literallayout>
  1500. As an example, assume a Source Directory top-level folder named
  1501. <filename>poky</filename>, a default Build Directory at
  1502. <filename>poky/build</filename>, and a
  1503. <filename>qemux86-poky-linux</filename> machine target system.
  1504. Furthermore, suppose your recipe is named
  1505. <filename>foo_1.3.0.bb</filename>.
  1506. In this case, the work directory the build system uses to
  1507. build the package would be as follows:
  1508. <literallayout class='monospaced'>
  1509. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1510. </literallayout>
  1511. Inside this directory you can find sub-directories such as
  1512. <filename>image</filename>, <filename>packages-split</filename>,
  1513. and <filename>temp</filename>.
  1514. After the build, you can examine these to determine how well
  1515. the build went.
  1516. <note>
  1517. You can find log files for each task in the recipe's
  1518. <filename>temp</filename> directory (e.g.
  1519. <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>).
  1520. Log files are named <filename>log.<replaceable>taskname</replaceable></filename>
  1521. (e.g. <filename>log.do_configure</filename>,
  1522. <filename>log.do_fetch</filename>, and
  1523. <filename>log.do_compile</filename>).
  1524. </note>
  1525. </para>
  1526. <para>
  1527. You can find more information about the build process in the
  1528. "<ulink url='&YOCTO_DOCS_REF_URL;#closer-look'>A Closer Look at the Yocto Project Development Environment</ulink>"
  1529. chapter of the Yocto Project Reference Manual.
  1530. </para>
  1531. <para>
  1532. You can also reference the following variables in the
  1533. Yocto Project Reference Manual's glossary for more information:
  1534. <itemizedlist>
  1535. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  1536. The top-level build output directory</listitem>
  1537. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
  1538. The target system identifier</listitem>
  1539. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  1540. The recipe name</listitem>
  1541. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
  1542. The epoch - (if
  1543. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
  1544. is not specified, which is usually the case for most
  1545. recipes, then <filename>EXTENDPE</filename> is blank)</listitem>
  1546. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  1547. The recipe version</listitem>
  1548. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  1549. The recipe revision</listitem>
  1550. </itemizedlist>
  1551. </para>
  1552. </section>
  1553. <section id='new-recipe-fetching-code'>
  1554. <title>Fetching Code</title>
  1555. <para>
  1556. The first thing your recipe must do is specify how to fetch
  1557. the source files.
  1558. Fetching is controlled mainly through the
  1559. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1560. variable.
  1561. Your recipe must have a <filename>SRC_URI</filename> variable
  1562. that points to where the source is located.
  1563. For a graphical representation of source locations, see the
  1564. "<ulink url='&YOCTO_DOCS_REF_URL;#sources-dev-environment'>Sources</ulink>"
  1565. section in the Yocto Project Reference Manual.
  1566. </para>
  1567. <para>
  1568. The
  1569. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1570. task uses the prefix of each entry in the
  1571. <filename>SRC_URI</filename> variable value to determine which
  1572. fetcher to use to get your source files.
  1573. It is the <filename>SRC_URI</filename> variable that triggers
  1574. the fetcher.
  1575. The
  1576. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1577. task uses the variable after source is fetched to apply
  1578. patches.
  1579. The OpenEmbedded build system uses
  1580. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink>
  1581. for scanning directory locations for local files in
  1582. <filename>SRC_URI</filename>.
  1583. </para>
  1584. <para>
  1585. The <filename>SRC_URI</filename> variable in your recipe must
  1586. define each unique location for your source files.
  1587. It is good practice to not hard-code pathnames in an URL used
  1588. in <filename>SRC_URI</filename>.
  1589. Rather than hard-code these paths, use
  1590. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1591. which causes the fetch process to use the version specified in
  1592. the recipe filename.
  1593. Specifying the version in this manner means that upgrading the
  1594. recipe to a future version is as simple as renaming the recipe
  1595. to match the new version.
  1596. </para>
  1597. <para>
  1598. Here is a simple example from the
  1599. <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename>
  1600. recipe where the source comes from a single tarball.
  1601. Notice the use of the
  1602. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1603. variable:
  1604. <literallayout class='monospaced'>
  1605. SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2"
  1606. </literallayout>
  1607. </para>
  1608. <para>
  1609. Files mentioned in <filename>SRC_URI</filename> whose names end
  1610. in a typical archive extension (e.g. <filename>.tar</filename>,
  1611. <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>,
  1612. <filename>.zip</filename>, and so forth), are automatically
  1613. extracted during the
  1614. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1615. task.
  1616. For another example that specifies these types of files, see
  1617. the
  1618. "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>"
  1619. section.
  1620. </para>
  1621. <para>
  1622. Another way of specifying source is from an SCM.
  1623. For Git repositories, you must specify
  1624. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  1625. and you should specify
  1626. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1627. to include the revision with
  1628. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  1629. Here is an example from the recipe
  1630. <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>:
  1631. <literallayout class='monospaced'>
  1632. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1633. PR = "r6"
  1634. PV = "1.0.5+git${SRCPV}"
  1635. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1636. file://ldflags.patch"
  1637. </literallayout>
  1638. </para>
  1639. <para>
  1640. If your <filename>SRC_URI</filename> statement includes
  1641. URLs pointing to individual files fetched from a remote server
  1642. other than a version control system, BitBake attempts to
  1643. verify the files against checksums defined in your recipe to
  1644. ensure they have not been tampered with or otherwise modified
  1645. since the recipe was written.
  1646. Two checksums are used:
  1647. <filename>SRC_URI[md5sum]</filename> and
  1648. <filename>SRC_URI[sha256sum]</filename>.
  1649. </para>
  1650. <para>
  1651. If your <filename>SRC_URI</filename> variable points to
  1652. more than a single URL (excluding SCM URLs), you need to
  1653. provide the <filename>md5</filename> and
  1654. <filename>sha256</filename> checksums for each URL.
  1655. For these cases, you provide a name for each URL as part of
  1656. the <filename>SRC_URI</filename> and then reference that name
  1657. in the subsequent checksum statements.
  1658. Here is an example:
  1659. <literallayout class='monospaced'>
  1660. SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \
  1661. ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch
  1662. SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
  1663. SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
  1664. SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92"
  1665. SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
  1666. </literallayout>
  1667. </para>
  1668. <para>
  1669. Proper values for <filename>md5</filename> and
  1670. <filename>sha256</filename> checksums might be available
  1671. with other signatures on the download page for the upstream
  1672. source (e.g. <filename>md5</filename>,
  1673. <filename>sha1</filename>, <filename>sha256</filename>,
  1674. <filename>GPG</filename>, and so forth).
  1675. Because the OpenEmbedded build system only deals with
  1676. <filename>sha256sum</filename> and <filename>md5sum</filename>,
  1677. you should verify all the signatures you find by hand.
  1678. </para>
  1679. <para>
  1680. If no <filename>SRC_URI</filename> checksums are specified
  1681. when you attempt to build the recipe, the build will produce
  1682. an error for each missing checksum.
  1683. As part of the error message, the build system provides
  1684. the checksum string corresponding to the fetched file.
  1685. Once you have the correct checksums, you can copy and paste
  1686. them into your recipe and then run the build again to continue.
  1687. <note>
  1688. As mentioned, if the upstream source provides signatures
  1689. for verifying the downloaded source code, you should
  1690. verify those manually before setting the checksum values
  1691. in the recipe and continuing with the build.
  1692. </note>
  1693. </para>
  1694. <para>
  1695. This final example is a bit more complicated and is from the
  1696. <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename>
  1697. recipe.
  1698. The example's <filename>SRC_URI</filename> statement identifies
  1699. multiple files as the source files for the recipe: a tarball, a
  1700. patch file, a desktop file, and an icon.
  1701. <literallayout class='monospaced'>
  1702. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1703. file://xwc.patch \
  1704. file://rxvt.desktop \
  1705. file://rxvt.png"
  1706. </literallayout>
  1707. </para>
  1708. <para>
  1709. When you specify local files using the
  1710. <filename>file://</filename> URI protocol, the build system
  1711. fetches files from the local machine.
  1712. The path is relative to the
  1713. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1714. variable and searches specific directories in a certain order:
  1715. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>,
  1716. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>,
  1717. and <filename>files</filename>.
  1718. The directories are assumed to be subdirectories of the
  1719. directory in which the recipe or append file resides.
  1720. For another example that specifies these types of files, see the
  1721. "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>"
  1722. section.
  1723. </para>
  1724. <para>
  1725. The previous example also specifies a patch file.
  1726. Patch files are files whose names end in
  1727. <filename>.patch</filename> or <filename>.diff</filename>.
  1728. The build system automatically applies patches as described
  1729. in the
  1730. "<link linkend='new-recipe-patching-code'>Patching Code</link>" section.
  1731. </para>
  1732. </section>
  1733. <section id='new-recipe-unpacking-code'>
  1734. <title>Unpacking Code</title>
  1735. <para>
  1736. During the build, the
  1737. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1738. task unpacks the source with
  1739. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>
  1740. pointing to where it is unpacked.
  1741. </para>
  1742. <para>
  1743. If you are fetching your source files from an upstream source
  1744. archived tarball and the tarball's internal structure matches
  1745. the common convention of a top-level subdirectory named
  1746. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}-${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1747. then you do not need to set <filename>S</filename>.
  1748. However, if <filename>SRC_URI</filename> specifies to fetch
  1749. source from an archive that does not use this convention,
  1750. or from an SCM like Git or Subversion, your recipe needs to
  1751. define <filename>S</filename>.
  1752. </para>
  1753. <para>
  1754. If processing your recipe using BitBake successfully unpacks
  1755. the source files, you need to be sure that the directory
  1756. pointed to by <filename>${S}</filename> matches the structure
  1757. of the source.
  1758. </para>
  1759. </section>
  1760. <section id='new-recipe-patching-code'>
  1761. <title>Patching Code</title>
  1762. <para>
  1763. Sometimes it is necessary to patch code after it has been
  1764. fetched.
  1765. Any files mentioned in <filename>SRC_URI</filename> whose
  1766. names end in <filename>.patch</filename> or
  1767. <filename>.diff</filename> are treated as patches.
  1768. The
  1769. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1770. task automatically applies these patches.
  1771. </para>
  1772. <para>
  1773. The build system should be able to apply patches with the "-p1"
  1774. option (i.e. one directory level in the path will be stripped
  1775. off).
  1776. If your patch needs to have more directory levels stripped off,
  1777. specify the number of levels using the "striplevel" option in
  1778. the <filename>SRC_URI</filename> entry for the patch.
  1779. Alternatively, if your patch needs to be applied in a specific
  1780. subdirectory that is not specified in the patch file, use the
  1781. "patchdir" option in the entry.
  1782. </para>
  1783. <para>
  1784. As with all local files referenced in
  1785. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1786. using <filename>file://</filename>, you should place
  1787. patch files in a directory next to the recipe either
  1788. named the same as the base name of the recipe
  1789. (<ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>),
  1790. or "files".
  1791. </para>
  1792. </section>
  1793. <section id='new-recipe-licensing'>
  1794. <title>Licensing</title>
  1795. <para>
  1796. Your recipe needs to have both the
  1797. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  1798. and
  1799. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  1800. variables:
  1801. <itemizedlist>
  1802. <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis>
  1803. This variable specifies the license for the software.
  1804. If you do not know the license under which the software
  1805. you are building is distributed, you should go to the
  1806. source code and look for that information.
  1807. Typical files containing this information include
  1808. <filename>COPYING</filename>,
  1809. <filename>LICENSE</filename>, and
  1810. <filename>README</filename> files.
  1811. You could also find the information near the top of
  1812. a source file.
  1813. For example, given a piece of software licensed under
  1814. the GNU General Public License version 2, you would
  1815. set <filename>LICENSE</filename> as follows:
  1816. <literallayout class='monospaced'>
  1817. LICENSE = "GPLv2"
  1818. </literallayout></para>
  1819. <para>The licenses you specify within
  1820. <filename>LICENSE</filename> can have any name as long
  1821. as you do not use spaces, since spaces are used as
  1822. separators between license names.
  1823. For standard licenses, use the names of the files in
  1824. <filename>meta/files/common-licenses/</filename>
  1825. or the <filename>SPDXLICENSEMAP</filename> flag names
  1826. defined in <filename>meta/conf/licenses.conf</filename>.
  1827. </para></listitem>
  1828. <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis>
  1829. The OpenEmbedded build system uses this variable to
  1830. make sure the license text has not changed.
  1831. If it has, the build produces an error and it affords
  1832. you the chance to figure it out and correct the problem.
  1833. </para>
  1834. <para>You need to specify all applicable licensing
  1835. files for the software.
  1836. At the end of the configuration step, the build process
  1837. will compare the checksums of the files to be sure
  1838. the text has not changed.
  1839. Any differences result in an error with the message
  1840. containing the current checksum.
  1841. For more explanation and examples of how to set the
  1842. <filename>LIC_FILES_CHKSUM</filename> variable, see the
  1843. "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  1844. section in the Yocto Project Reference Manual.</para>
  1845. <para>To determine the correct checksum string, you
  1846. can list the appropriate files in the
  1847. <filename>LIC_FILES_CHKSUM</filename> variable with
  1848. incorrect md5 strings, attempt to build the software,
  1849. and then note the resulting error messages that will
  1850. report the correct md5 strings.
  1851. See the
  1852. "<link linkend='new-recipe-fetching-code'>Fetching Code</link>"
  1853. section for additional information.
  1854. </para>
  1855. <para>
  1856. Here is an example that assumes the software has a
  1857. <filename>COPYING</filename> file:
  1858. <literallayout class='monospaced'>
  1859. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  1860. </literallayout>
  1861. When you try to build the software, the build system
  1862. will produce an error and give you the correct string
  1863. that you can substitute into the recipe file for a
  1864. subsequent build.
  1865. </para></listitem>
  1866. </itemizedlist>
  1867. </para>
  1868. <!--
  1869. <para>
  1870. For trying this out I created a new recipe named
  1871. <filename>htop_1.0.2.bb</filename> and put it in
  1872. <filename>poky/meta/recipes-extended/htop</filename>.
  1873. There are two license type statements in my very simple
  1874. recipe:
  1875. <literallayout class='monospaced'>
  1876. LICENSE = ""
  1877. LIC_FILES_CHKSUM = ""
  1878. SRC_URI[md5sum] = ""
  1879. SRC_URI[sha256sum] = ""
  1880. </literallayout>
  1881. Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>.
  1882. Next, you delete or comment out the two <filename>SRC_URI</filename>
  1883. lines at the end and then attempt to build the software with
  1884. <filename>bitbake htop</filename>.
  1885. Doing so causes BitBake to report some errors and and give
  1886. you the actual strings you need for the last two
  1887. <filename>SRC_URI</filename> lines.
  1888. Prior to this, you have to dig around in the home page of the
  1889. source for <filename>htop</filename> and determine that the
  1890. software is released under GPLv2.
  1891. You can provide that in the <filename>LICENSE</filename>
  1892. statement.
  1893. Now you edit your recipe to have those two strings for
  1894. the <filename>SRC_URI</filename> statements:
  1895. <literallayout class='monospaced'>
  1896. LICENSE = "GPLv2"
  1897. LIC_FILES_CHKSUM = ""
  1898. SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz"
  1899. SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e"
  1900. SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1"
  1901. </literallayout>
  1902. At this point, you can build the software again using the
  1903. <filename>bitbake htop</filename> command.
  1904. There is just a set of errors now associated with the
  1905. empty <filename>LIC_FILES_CHKSUM</filename> variable now.
  1906. </para>
  1907. -->
  1908. </section>
  1909. <section id='new-recipe-configuring-the-recipe'>
  1910. <title>Configuring the Recipe</title>
  1911. <para>
  1912. Most software provides some means of setting build-time
  1913. configuration options before compilation.
  1914. Typically, setting these options is accomplished by running a
  1915. configure script with some options, or by modifying a build
  1916. configuration file.
  1917. </para>
  1918. <para>
  1919. A major part of build-time configuration is about checking for
  1920. build-time dependencies and possibly enabling optional
  1921. functionality as a result.
  1922. You need to specify any build-time dependencies for the
  1923. software you are building in your recipe's
  1924. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  1925. value, in terms of other recipes that satisfy those
  1926. dependencies.
  1927. You can often find build-time or runtime
  1928. dependencies described in the software's documentation.
  1929. </para>
  1930. <para>
  1931. The following list provides configuration items of note based
  1932. on how your software is built:
  1933. <itemizedlist>
  1934. <listitem><para><emphasis>Autotools:</emphasis>
  1935. If your source files have a
  1936. <filename>configure.ac</filename> file, then your
  1937. software is built using Autotools.
  1938. If this is the case, you just need to worry about
  1939. modifying the configuration.</para>
  1940. <para>When using Autotools, your recipe needs to inherit
  1941. the
  1942. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  1943. class and your recipe does not have to contain a
  1944. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  1945. task.
  1946. However, you might still want to make some adjustments.
  1947. For example, you can set
  1948. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  1949. to pass any needed configure options that are specific
  1950. to the recipe.</para></listitem>
  1951. <listitem><para><emphasis>CMake:</emphasis>
  1952. If your source files have a
  1953. <filename>CMakeLists.txt</filename> file, then your
  1954. software is built using CMake.
  1955. If this is the case, you just need to worry about
  1956. modifying the configuration.</para>
  1957. <para>When you use CMake, your recipe needs to inherit
  1958. the
  1959. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  1960. class and your recipe does not have to contain a
  1961. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  1962. task.
  1963. You can make some adjustments by setting
  1964. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
  1965. to pass any needed configure options that are specific
  1966. to the recipe.</para></listitem>
  1967. <listitem><para><emphasis>Other:</emphasis>
  1968. If your source files do not have a
  1969. <filename>configure.ac</filename> or
  1970. <filename>CMakeLists.txt</filename> file, then your
  1971. software is built using some method other than Autotools
  1972. or CMake.
  1973. If this is the case, you normally need to provide a
  1974. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  1975. task in your recipe
  1976. unless, of course, there is nothing to configure.
  1977. </para>
  1978. <para>Even if your software is not being built by
  1979. Autotools or CMake, you still might not need to deal
  1980. with any configuration issues.
  1981. You need to determine if configuration is even a required step.
  1982. You might need to modify a Makefile or some configuration file
  1983. used for the build to specify necessary build options.
  1984. Or, perhaps you might need to run a provided, custom
  1985. configure script with the appropriate options.</para>
  1986. <para>For the case involving a custom configure
  1987. script, you would run
  1988. <filename>./configure &dash;&dash;help</filename> and look for
  1989. the options you need to set.</para></listitem>
  1990. </itemizedlist>
  1991. </para>
  1992. <para>
  1993. Once configuration succeeds, it is always good practice to
  1994. look at the <filename>log.do_configure</filename> file to
  1995. ensure that the appropriate options have been enabled and no
  1996. additional build-time dependencies need to be added to
  1997. <filename>DEPENDS</filename>.
  1998. For example, if the configure script reports that it found
  1999. something not mentioned in <filename>DEPENDS</filename>, or
  2000. that it did not find something that it needed for some
  2001. desired optional functionality, then you would need to add
  2002. those to <filename>DEPENDS</filename>.
  2003. Looking at the log might also reveal items being checked for,
  2004. enabled, or both that you do not want, or items not being found
  2005. that are in <filename>DEPENDS</filename>, in which case
  2006. you would need to look at passing extra options to the
  2007. configure script as needed.
  2008. For reference information on configure options specific to the
  2009. software you are building, you can consult the output of the
  2010. <filename>./configure &dash;&dash;help</filename> command within
  2011. <filename>${S}</filename> or consult the software's upstream
  2012. documentation.
  2013. </para>
  2014. </section>
  2015. <section id='new-recipe-compilation'>
  2016. <title>Compilation</title>
  2017. <para>
  2018. During a build, the <filename>do_compile</filename> task
  2019. happens after source is fetched, unpacked, and configured.
  2020. If the recipe passes through <filename>do_compile</filename>
  2021. successfully, nothing needs to be done.
  2022. </para>
  2023. <para>
  2024. However, if the compile step fails, you need to diagnose the
  2025. failure.
  2026. Here are some common issues that cause failures:
  2027. <itemizedlist>
  2028. <listitem><para><emphasis>Parallel build failures:</emphasis>
  2029. These failures manifest themselves as intermittent
  2030. errors, or errors reporting that a file or directory
  2031. that should be created by some other part of the build
  2032. process could not be found.
  2033. This type of failure can occur even if, upon inspection,
  2034. the file or directory does exist after the build has
  2035. failed, because that part of the build process happened
  2036. in the wrong order.</para>
  2037. <para>To fix the problem, you need to either satisfy
  2038. the missing dependency in the Makefile or whatever
  2039. script produced the Makefile, or (as a workaround)
  2040. set
  2041. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  2042. to an empty string:
  2043. <literallayout class='monospaced'>
  2044. PARALLEL_MAKE = ""
  2045. </literallayout></para>
  2046. <para>
  2047. For information on parallel Makefile issues, see the
  2048. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  2049. section.
  2050. </para></listitem>
  2051. <listitem><para><emphasis>Improper host path usage:</emphasis>
  2052. This failure applies to recipes building for the target
  2053. or <filename>nativesdk</filename> only.
  2054. The failure occurs when the compilation process uses
  2055. improper headers, libraries, or other files from the
  2056. host system when cross-compiling for the target.
  2057. </para>
  2058. <para>To fix the problem, examine the
  2059. <filename>log.do_compile</filename> file to identify
  2060. the host paths being used (e.g.
  2061. <filename>/usr/include</filename>,
  2062. <filename>/usr/lib</filename>, and so forth) and then
  2063. either add configure options, apply a patch, or do both.
  2064. </para></listitem>
  2065. <listitem><para><emphasis>Failure to find required
  2066. libraries/headers:</emphasis>
  2067. If a build-time dependency is missing because it has
  2068. not been declared in
  2069. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  2070. or because the dependency exists but the path used by
  2071. the build process to find the file is incorrect and the
  2072. configure step did not detect it, the compilation
  2073. process could fail.
  2074. For either of these failures, the compilation process
  2075. notes that files could not be found.
  2076. In these cases, you need to go back and add additional
  2077. options to the configure script as well as possibly
  2078. add additional build-time dependencies to
  2079. <filename>DEPENDS</filename>.</para>
  2080. <para>Occasionally, it is necessary to apply a patch
  2081. to the source to ensure the correct paths are used.
  2082. If you need to specify paths to find files staged
  2083. into the sysroot from other recipes, use the variables
  2084. that the OpenEmbedded build system provides
  2085. (e.g.
  2086. <filename>STAGING_BINDIR</filename>,
  2087. <filename>STAGING_INCDIR</filename>,
  2088. <filename>STAGING_DATADIR</filename>, and so forth).
  2089. <!--
  2090. (e.g.
  2091. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>,
  2092. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>,
  2093. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>,
  2094. and so forth).
  2095. -->
  2096. </para></listitem>
  2097. </itemizedlist>
  2098. </para>
  2099. </section>
  2100. <section id='new-recipe-installing'>
  2101. <title>Installing</title>
  2102. <para>
  2103. During <filename>do_install</filename>, the task copies the
  2104. built files along with their hierarchy to locations that
  2105. would mirror their locations on the target device.
  2106. The installation process copies files from the
  2107. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  2108. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>,
  2109. and
  2110. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  2111. directories to the
  2112. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2113. directory to create the structure as it should appear on the
  2114. target system.
  2115. </para>
  2116. <para>
  2117. How your software is built affects what you must do to be
  2118. sure your software is installed correctly.
  2119. The following list describes what you must do for installation
  2120. depending on the type of build system used by the software
  2121. being built:
  2122. <itemizedlist>
  2123. <listitem><para><emphasis>Autotools and CMake:</emphasis>
  2124. If the software your recipe is building uses Autotools
  2125. or CMake, the OpenEmbedded build
  2126. system understands how to install the software.
  2127. Consequently, you do not have to have a
  2128. <filename>do_install</filename> task as part of your
  2129. recipe.
  2130. You just need to make sure the install portion of the
  2131. build completes with no issues.
  2132. However, if you wish to install additional files not
  2133. already being installed by
  2134. <filename>make install</filename>, you should do this
  2135. using a <filename>do_install_append</filename> function
  2136. using the install command as described in
  2137. the "Manual" bulleted item later in this list.
  2138. </para></listitem>
  2139. <listitem><para><emphasis>Other (using
  2140. <filename>make install</filename>):</emphasis>
  2141. You need to define a
  2142. <filename>do_install</filename> function in your
  2143. recipe.
  2144. The function should call
  2145. <filename>oe_runmake install</filename> and will likely
  2146. need to pass in the destination directory as well.
  2147. How you pass that path is dependent on how the
  2148. <filename>Makefile</filename> being run is written
  2149. (e.g. <filename>DESTDIR=${D}</filename>,
  2150. <filename>PREFIX=${D}</filename>,
  2151. <filename>INSTALLROOT=${D}</filename>, and so forth).
  2152. </para>
  2153. <para>For an example recipe using
  2154. <filename>make install</filename>, see the
  2155. "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>"
  2156. section.</para></listitem>
  2157. <listitem><para><emphasis>Manual:</emphasis>
  2158. You need to define a
  2159. <filename>do_install</filename> function in your
  2160. recipe.
  2161. The function must first use
  2162. <filename>install -d</filename> to create the
  2163. directories under
  2164. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
  2165. Once the directories exist, your function can use
  2166. <filename>install</filename> to manually install the
  2167. built software into the directories.</para>
  2168. <para>You can find more information on
  2169. <filename>install</filename> at
  2170. <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>.
  2171. </para></listitem>
  2172. </itemizedlist>
  2173. </para>
  2174. <para>
  2175. For the scenarios that do not use Autotools or
  2176. CMake, you need to track the installation
  2177. and diagnose and fix any issues until everything installs
  2178. correctly.
  2179. You need to look in the default location of
  2180. <filename>${D}</filename>, which is
  2181. <filename>${WORKDIR}/image</filename>, to be sure your
  2182. files have been installed correctly.
  2183. </para>
  2184. <note><title>Notes</title>
  2185. <itemizedlist>
  2186. <listitem><para>
  2187. During the installation process, you might need to
  2188. modify some of the installed files to suit the target
  2189. layout.
  2190. For example, you might need to replace hard-coded paths
  2191. in an initscript with values of variables provided by
  2192. the build system, such as replacing
  2193. <filename>/usr/bin/</filename> with
  2194. <filename>${bindir}</filename>.
  2195. If you do perform such modifications during
  2196. <filename>do_install</filename>, be sure to modify the
  2197. destination file after copying rather than before
  2198. copying.
  2199. Modifying after copying ensures that the build system
  2200. can re-execute <filename>do_install</filename> if
  2201. needed.
  2202. </para></listitem>
  2203. <listitem><para>
  2204. <filename>oe_runmake install</filename>, which can be
  2205. run directly or can be run indirectly by the
  2206. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2207. and
  2208. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2209. classes, runs <filename>make install</filename> in
  2210. parallel.
  2211. Sometimes, a Makefile can have missing dependencies
  2212. between targets that can result in race conditions.
  2213. If you experience intermittent failures during
  2214. <filename>do_install</filename>, you might be able to
  2215. work around them by disabling parallel Makefile
  2216. installs by adding the following to the recipe:
  2217. <literallayout class='monospaced'>
  2218. PARALLEL_MAKEINST = ""
  2219. </literallayout>
  2220. See
  2221. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  2222. for additional information.
  2223. </para></listitem>
  2224. </itemizedlist>
  2225. </note>
  2226. </section>
  2227. <section id='new-recipe-enabling-system-services'>
  2228. <title>Enabling System Services</title>
  2229. <para>
  2230. If you want to install a service, which is a process that
  2231. usually starts on boot and runs in the background, then
  2232. you must include some additional definitions in your recipe.
  2233. </para>
  2234. <para>
  2235. If you are adding services and the service initialization
  2236. script or the service file itself is not installed, you must
  2237. provide for that installation in your recipe using a
  2238. <filename>do_install_append</filename> function.
  2239. If your recipe already has a <filename>do_install</filename>
  2240. function, update the function near its end rather than
  2241. adding an additional <filename>do_install_append</filename>
  2242. function.
  2243. </para>
  2244. <para>
  2245. When you create the installation for your services, you need
  2246. to accomplish what is normally done by
  2247. <filename>make install</filename>.
  2248. In other words, make sure your installation arranges the output
  2249. similar to how it is arranged on the target system.
  2250. </para>
  2251. <para>
  2252. The OpenEmbedded build system provides support for starting
  2253. services two different ways:
  2254. <itemizedlist>
  2255. <listitem><para><emphasis>SysVinit:</emphasis>
  2256. SysVinit is a system and service manager that
  2257. manages the init system used to control the very basic
  2258. functions of your system.
  2259. The init program is the first program
  2260. started by the Linux kernel when the system boots.
  2261. Init then controls the startup, running and shutdown
  2262. of all other programs.</para>
  2263. <para>To enable a service using SysVinit, your recipe
  2264. needs to inherit the
  2265. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink>
  2266. class.
  2267. The class helps facilitate safely installing the
  2268. package on the target.</para>
  2269. <para>You will need to set the
  2270. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>,
  2271. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>,
  2272. and
  2273. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink>
  2274. variables within your recipe.</para></listitem>
  2275. <listitem><para><emphasis>systemd:</emphasis>
  2276. System Management Daemon (systemd) was designed to
  2277. replace SysVinit and to provide
  2278. enhanced management of services.
  2279. For more information on systemd, see the systemd
  2280. homepage at
  2281. <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>.
  2282. </para>
  2283. <para>To enable a service using systemd, your recipe
  2284. needs to inherit the
  2285. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink>
  2286. class.
  2287. See the <filename>systemd.bbclass</filename> file
  2288. located in your
  2289. <link linkend='source-directory'>Source Directory</link>.
  2290. section for more information.
  2291. </para></listitem>
  2292. </itemizedlist>
  2293. </para>
  2294. </section>
  2295. <section id='new-recipe-packaging'>
  2296. <title>Packaging</title>
  2297. <para>
  2298. Successful packaging is a combination of automated processes
  2299. performed by the OpenEmbedded build system and some
  2300. specific steps you need to take.
  2301. The following list describes the process:
  2302. <itemizedlist>
  2303. <listitem><para><emphasis>Splitting Files</emphasis>:
  2304. The <filename>do_package</filename> task splits the
  2305. files produced by the recipe into logical components.
  2306. Even software that produces a single binary might
  2307. still have debug symbols, documentation, and other
  2308. logical components that should be split out.
  2309. The <filename>do_package</filename> task ensures
  2310. that files are split up and packaged correctly.
  2311. </para></listitem>
  2312. <listitem><para><emphasis>Running QA Checks</emphasis>:
  2313. The
  2314. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2315. class adds a step to
  2316. the package generation process so that output quality
  2317. assurance checks are generated by the OpenEmbedded
  2318. build system.
  2319. This step performs a range of checks to be sure the
  2320. build's output is free of common problems that show
  2321. up during runtime.
  2322. For information on these checks, see the
  2323. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2324. class and the
  2325. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>"
  2326. chapter in the Yocto Project Reference Manual.
  2327. </para></listitem>
  2328. <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>:
  2329. After you build your software, you need to be sure
  2330. your packages are correct.
  2331. Examine the
  2332. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  2333. directory and make sure files are where you expect
  2334. them to be.
  2335. If you discover problems, you can set
  2336. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>,
  2337. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2338. <filename>do_install(_append)</filename>, and so forth as
  2339. needed.
  2340. </para></listitem>
  2341. <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>:
  2342. If you need to split an application into several
  2343. packages, see the
  2344. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2345. section for an example.
  2346. </para></listitem>
  2347. <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>:
  2348. For an example showing how to install a
  2349. post-installation script, see the
  2350. "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>"
  2351. section.
  2352. </para></listitem>
  2353. <listitem><para><emphasis>Marking Package Architecture</emphasis>:
  2354. Depending on what your recipe is building and how it
  2355. is configured, it might be important to mark the
  2356. packages produced as being specific to a particular
  2357. machine, or to mark them as not being specific to
  2358. a particular machine or architecture at all.
  2359. By default, packages produced for the target are
  2360. marked as being specific to the architecture of the
  2361. target machine because that is usually the desired
  2362. result.
  2363. However, if the recipe configures the software to be
  2364. built specific to the target machine (e.g. the
  2365. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  2366. value is passed into the configure script or a patch
  2367. is applied only for a particular machine), then you
  2368. should mark the packages produced as being
  2369. machine-specific by adding the following to the
  2370. recipe:
  2371. <literallayout class='monospaced'>
  2372. PACKAGE_ARCH = "${MACHINE_ARCH}"
  2373. </literallayout>
  2374. On the other hand, if the recipe produces packages
  2375. that do not contain anything specific to the target
  2376. machine or architecture at all (e.g. recipes
  2377. that simply package script files or configuration
  2378. files), you should use the
  2379. <ulink url='&YOCTO_DOCS_REF_URL;#allarch'><filename>allarch</filename></ulink>
  2380. class to do this for you by adding this to your
  2381. recipe:
  2382. <literallayout class='monospaced'>
  2383. inherit allarch
  2384. </literallayout>
  2385. Ensuring that the package architecture is correct is
  2386. not critical while you are doing the first few builds
  2387. of your recipe.
  2388. However, it is important in order
  2389. to ensure that your recipe rebuilds (or does not
  2390. rebuild) appropriately in response to changes in
  2391. configuration, and to ensure that you get the
  2392. appropriate packages installed on the target machine,
  2393. particularly if you run separate builds for more
  2394. than one target machine.
  2395. </para></listitem>
  2396. </itemizedlist>
  2397. </para>
  2398. </section>
  2399. <section id='properly-versioning-pre-release-recipes'>
  2400. <title>Properly Versioning Pre-Release Recipes</title>
  2401. <para>
  2402. Sometimes the name of a recipe can lead to versioning
  2403. problems when the recipe is upgraded to a final release.
  2404. For example, consider the
  2405. <filename>irssi_0.8.16-rc1.bb</filename> recipe file in
  2406. the list of example recipes in the
  2407. "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>"
  2408. section.
  2409. This recipe is at a release candidate stage (i.e.
  2410. "rc1").
  2411. When the recipe is released, the recipe filename becomes
  2412. <filename>irssi_0.8.16.bb</filename>.
  2413. The version change from <filename>0.8.16-rc1</filename>
  2414. to <filename>0.8.16</filename> is seen as a decrease by the
  2415. build system and package managers, so the resulting packages
  2416. will not correctly trigger an upgrade.
  2417. </para>
  2418. <para>
  2419. In order to ensure the versions compare properly, the
  2420. recommended convention is to set
  2421. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2422. within the recipe to
  2423. "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>".
  2424. You can use an additional variable so that you can use the
  2425. current version elsewhere.
  2426. Here is an example:
  2427. <literallayout class='monospaced'>
  2428. REALPV = "0.8.16-rc1"
  2429. PV = "0.8.15+${REALPV}"
  2430. </literallayout>
  2431. </para>
  2432. </section>
  2433. <section id='new-recipe-post-installation-scripts'>
  2434. <title>Post-Installation Scripts</title>
  2435. <para>
  2436. Post-installation scripts run immediately after installing
  2437. a package on the target or during image creation when a
  2438. package is included in an image.
  2439. To add a post-installation script to a package, add a
  2440. <filename>pkg_postinst_PACKAGENAME()</filename> function to
  2441. the recipe file (<filename>.bb</filename>) and replace
  2442. <filename>PACKAGENAME</filename> with the name of the package
  2443. you want to attach to the <filename>postinst</filename>
  2444. script.
  2445. To apply the post-installation script to the main package
  2446. for the recipe, which is usually what is required, specify
  2447. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2448. in place of <filename>PACKAGENAME</filename>.
  2449. </para>
  2450. <para>
  2451. A post-installation function has the following structure:
  2452. <literallayout class='monospaced'>
  2453. pkg_postinst_PACKAGENAME() {
  2454. #!/bin/sh -e
  2455. # Commands to carry out
  2456. }
  2457. </literallayout>
  2458. </para>
  2459. <para>
  2460. The script defined in the post-installation function is
  2461. called when the root filesystem is created.
  2462. If the script succeeds, the package is marked as installed.
  2463. If the script fails, the package is marked as unpacked and
  2464. the script is executed when the image boots again.
  2465. </para>
  2466. <para>
  2467. Sometimes it is necessary for the execution of a
  2468. post-installation script to be delayed until the first boot.
  2469. For example, the script might need to be executed on the
  2470. device itself.
  2471. To delay script execution until boot time, use the following
  2472. structure in the post-installation script:
  2473. <literallayout class='monospaced'>
  2474. pkg_postinst_PACKAGENAME() {
  2475. #!/bin/sh -e
  2476. if [ x"$D" = "x" ]; then
  2477. # Actions to carry out on the device go here
  2478. else
  2479. exit 1
  2480. fi
  2481. }
  2482. </literallayout>
  2483. </para>
  2484. <para>
  2485. The previous example delays execution until the image boots
  2486. again because the environment variable <filename>D</filename>
  2487. points to the directory containing the image when
  2488. the root filesystem is created at build time but is unset
  2489. when executed on the first boot.
  2490. </para>
  2491. <note>
  2492. Equivalent support for pre-install, pre-uninstall, and
  2493. post-uninstall scripts exist by way of
  2494. <filename>pkg_preinst</filename>,
  2495. <filename>pkg_prerm</filename>, and
  2496. <filename>pkg_postrm</filename>, respectively.
  2497. These scrips work in exactly the same way as does
  2498. <filename>pkg_postinst</filename> with the exception that they
  2499. run at different times.
  2500. Also, because of when they run, they are not applicable to
  2501. being run at image creation time like
  2502. <filename>pkg_postinst</filename>.
  2503. </note>
  2504. </section>
  2505. <section id='new-recipe-testing'>
  2506. <title>Testing</title>
  2507. <para>
  2508. The final step for completing your recipe is to be sure that
  2509. the software you built runs correctly.
  2510. To accomplish runtime testing, add the build's output
  2511. packages to your image and test them on the target.
  2512. </para>
  2513. <para>
  2514. For information on how to customize your image by adding
  2515. specific packages, see the
  2516. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  2517. section.
  2518. </para>
  2519. </section>
  2520. <section id='new-recipe-testing-examples'>
  2521. <title>Examples</title>
  2522. <para>
  2523. To help summarize how to write a recipe, this section provides
  2524. some examples given various scenarios:
  2525. <itemizedlist>
  2526. <listitem><para>Recipes that use local files</para></listitem>
  2527. <listitem><para>Using an Autotooled package</para></listitem>
  2528. <listitem><para>Using a Makefile-based package</para></listitem>
  2529. <listitem><para>Splitting an application into multiple packages</para></listitem>
  2530. <listitem><para>Adding binaries to an image</para></listitem>
  2531. </itemizedlist>
  2532. </para>
  2533. <section id='new-recipe-single-c-file-package-hello-world'>
  2534. <title>Single .c File Package (Hello World!)</title>
  2535. <para>
  2536. Building an application from a single file that is stored
  2537. locally (e.g. under <filename>files</filename>) requires
  2538. a recipe that has the file listed in the
  2539. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  2540. variable.
  2541. Additionally, you need to manually write the
  2542. <filename>do_compile</filename> and
  2543. <filename>do_install</filename> tasks.
  2544. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  2545. variable defines the directory containing the source code,
  2546. which is set to
  2547. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  2548. in this case - the directory BitBake uses for the build.
  2549. <literallayout class='monospaced'>
  2550. SUMMARY = "Simple helloworld application"
  2551. SECTION = "examples"
  2552. LICENSE = "MIT"
  2553. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  2554. SRC_URI = "file://helloworld.c"
  2555. S = "${WORKDIR}"
  2556. do_compile() {
  2557. ${CC} helloworld.c -o helloworld
  2558. }
  2559. do_install() {
  2560. install -d ${D}${bindir}
  2561. install -m 0755 helloworld ${D}${bindir}
  2562. }
  2563. </literallayout>
  2564. </para>
  2565. <para>
  2566. By default, the <filename>helloworld</filename>,
  2567. <filename>helloworld-dbg</filename>, and
  2568. <filename>helloworld-dev</filename> packages are built.
  2569. For information on how to customize the packaging process,
  2570. see the
  2571. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2572. section.
  2573. </para>
  2574. </section>
  2575. <section id='new-recipe-autotooled-package'>
  2576. <title>Autotooled Package</title>
  2577. <para>
  2578. Applications that use Autotools such as <filename>autoconf</filename> and
  2579. <filename>automake</filename> require a recipe that has a source archive listed in
  2580. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  2581. also inherit the
  2582. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2583. class, which contains the definitions of all the steps
  2584. needed to build an Autotool-based application.
  2585. The result of the build is automatically packaged.
  2586. And, if the application uses NLS for localization, packages with local information are
  2587. generated (one package per language).
  2588. Following is one example: (<filename>hello_2.3.bb</filename>)
  2589. <literallayout class='monospaced'>
  2590. SUMMARY = "GNU Helloworld application"
  2591. SECTION = "examples"
  2592. LICENSE = "GPLv2+"
  2593. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  2594. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  2595. inherit autotools gettext
  2596. </literallayout>
  2597. </para>
  2598. <para>
  2599. The variable
  2600. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  2601. is used to track source license changes as described in the
  2602. "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" section.
  2603. You can quickly create Autotool-based recipes in a manner similar to the previous example.
  2604. </para>
  2605. </section>
  2606. <section id='new-recipe-makefile-based-package'>
  2607. <title>Makefile-Based Package</title>
  2608. <para>
  2609. Applications that use GNU <filename>make</filename> also require a recipe that has
  2610. the source archive listed in
  2611. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  2612. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  2613. starts the <filename>make</filename> command to compile the application.
  2614. If you need additional <filename>make</filename> options, you should store them in the
  2615. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'>EXTRA_OEMAKE</ulink></filename>
  2616. variable.
  2617. BitBake passes these options into the GNU <filename>make</filename> invocation.
  2618. Note that a <filename>do_install</filename> task is still required.
  2619. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  2620. </para>
  2621. <para>
  2622. Some applications might require extra parameters to be passed to the compiler.
  2623. For example, the application might need an additional header path.
  2624. You can accomplish this by adding to the
  2625. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  2626. The following example shows this:
  2627. <literallayout class='monospaced'>
  2628. CFLAGS_prepend = "-I ${S}/include "
  2629. </literallayout>
  2630. </para>
  2631. <para>
  2632. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  2633. <literallayout class='monospaced'>
  2634. SUMMARY = "Tools for managing memory technology devices"
  2635. SECTION = "base"
  2636. DEPENDS = "zlib lzo e2fsprogs util-linux"
  2637. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  2638. LICENSE = "GPLv2+"
  2639. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  2640. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  2641. # Use the latest version at 26 Oct, 2013
  2642. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  2643. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  2644. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  2645. "
  2646. PV = "1.5.1+git${SRCPV}"
  2647. S = "${WORKDIR}/git/"
  2648. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  2649. do_install () {
  2650. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  2651. }
  2652. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  2653. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  2654. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  2655. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  2656. PARALLEL_MAKE = ""
  2657. BBCLASSEXTEND = "native"
  2658. </literallayout>
  2659. </para>
  2660. </section>
  2661. <section id='splitting-an-application-into-multiple-packages'>
  2662. <title>Splitting an Application into Multiple Packages</title>
  2663. <para>
  2664. You can use the variables
  2665. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  2666. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  2667. to split an application into multiple packages.
  2668. </para>
  2669. <para>
  2670. Following is an example that uses the <filename>libxpm</filename> recipe.
  2671. By default, this recipe generates a single package that contains the library along
  2672. with a few binaries.
  2673. You can modify the recipe to split the binaries into separate packages:
  2674. <literallayout class='monospaced'>
  2675. require xorg-lib-common.inc
  2676. SUMMARY = "X11 Pixmap library"
  2677. LICENSE = "X-BSD"
  2678. LIC_FILES_CHKSUM = "file://COPYING;md5=3e07763d16963c3af12db271a31abaa5"
  2679. DEPENDS += "libxext libsm libxt"
  2680. PR = "r3"
  2681. PE = "1"
  2682. XORG_PN = "libXpm"
  2683. PACKAGES =+ "sxpm cxpm"
  2684. FILES_cxpm = "${bindir}/cxpm"
  2685. FILES_sxpm = "${bindir}/sxpm"
  2686. </literallayout>
  2687. </para>
  2688. <para>
  2689. In the previous example, we want to ship the <filename>sxpm</filename>
  2690. and <filename>cxpm</filename> binaries in separate packages.
  2691. Since <filename>bindir</filename> would be packaged into the main
  2692. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  2693. package by default, we prepend the <filename>PACKAGES</filename>
  2694. variable so additional package names are added to the start of list.
  2695. This results in the extra <filename>FILES_*</filename>
  2696. variables then containing information that define which files and
  2697. directories go into which packages.
  2698. Files included by earlier packages are skipped by latter packages.
  2699. Thus, the main <filename>PN</filename> package
  2700. does not include the above listed files.
  2701. </para>
  2702. </section>
  2703. <section id='packaging-externally-produced-binaries'>
  2704. <title>Packaging Externally Produced Binaries</title>
  2705. <para>
  2706. Sometimes, you need to add pre-compiled binaries to an
  2707. image.
  2708. For example, suppose that binaries for proprietary code
  2709. exist, which are created by a particular division of a
  2710. company.
  2711. Your part of the company needs to use those binaries as
  2712. part of an image that you are building using the
  2713. OpenEmbedded build system.
  2714. Since you only have the binaries and not the source code,
  2715. you cannot use a typical recipe that expects to fetch the
  2716. source specified in
  2717. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  2718. and then compile it.
  2719. </para>
  2720. <para>
  2721. One method is to package the binaries and then install them
  2722. as part of the image.
  2723. Generally, it is not a good idea to package binaries
  2724. since, among other things, it can hinder the ability to
  2725. reproduce builds and could lead to compatibility problems
  2726. with ABI in the future.
  2727. However, sometimes you have no choice.
  2728. </para>
  2729. <para>
  2730. The easiest solution is to create a recipe that uses
  2731. the
  2732. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  2733. class and to be sure that you are using default locations
  2734. for build artifacts.
  2735. In most cases, the <filename>bin_package</filename> class
  2736. handles "skipping" the configure and compile steps as well
  2737. as sets things up to grab packages from the appropriate
  2738. area.
  2739. In particular, this class sets <filename>noexec</filename>
  2740. on both the
  2741. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2742. and
  2743. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  2744. tasks, sets
  2745. <filename>FILES_${PN}</filename> to "/" so that it picks
  2746. up all files, and sets up a
  2747. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2748. task, which effectively copies all files from
  2749. <filename>${S}</filename> to <filename>${D}</filename>.
  2750. The <filename>bin_package</filename> class works well when
  2751. the files extracted into <filename>${S}</filename> are
  2752. already laid out in the way they should be laid out
  2753. on the target.
  2754. For more information on these variables, see the
  2755. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2756. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  2757. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  2758. and
  2759. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  2760. variables in the Yocto Project Reference Manual's variable
  2761. glossary.
  2762. </para>
  2763. <para>
  2764. If you can't use the <filename>bin_package</filename>
  2765. class, you need to be sure you are doing the following:
  2766. <itemizedlist>
  2767. <listitem><para>Create a recipe where the
  2768. <filename>do_configure</filename> and
  2769. <filename>do_compile</filename> tasks do nothing:
  2770. <literallayout class='monospaced'>
  2771. do_configure[noexec] = "1"
  2772. do_compile[noexec] = "1"
  2773. </literallayout>
  2774. Alternatively, you can make these tasks an empty
  2775. function.
  2776. </para></listitem>
  2777. <listitem><para>Make sure your
  2778. <filename>do_install</filename> task installs the
  2779. binaries appropriately.
  2780. </para></listitem>
  2781. <listitem><para>Ensure that you set up
  2782. <filename>FILES</filename> (usually
  2783. <filename>FILES_${PN}</filename>) to point to the
  2784. files you have installed, which of course depends
  2785. on where you have installed them and whether
  2786. those files are in different locations than the
  2787. defaults.
  2788. </para></listitem>
  2789. </itemizedlist>
  2790. </para>
  2791. </section>
  2792. </section>
  2793. </section>
  2794. <section id="platdev-newmachine">
  2795. <title>Adding a New Machine</title>
  2796. <para>
  2797. Adding a new machine to the Yocto Project is a straightforward
  2798. process.
  2799. This section describes how to add machines that are similar
  2800. to those that the Yocto Project already supports.
  2801. <note>
  2802. Although well within the capabilities of the Yocto Project,
  2803. adding a totally new architecture might require
  2804. changes to <filename>gcc/eglibc</filename> and to the site
  2805. information, which is beyond the scope of this manual.
  2806. </note>
  2807. </para>
  2808. <para>
  2809. For a complete example that shows how to add a new machine,
  2810. see the
  2811. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
  2812. section in the Yocto Project Board Support Package (BSP) Developer's Guide.
  2813. </para>
  2814. <section id="platdev-newmachine-conffile">
  2815. <title>Adding the Machine Configuration File</title>
  2816. <para>
  2817. To add a new machine, you need to add a new machine
  2818. configuration file to the layer's
  2819. <filename>conf/machine</filename> directory.
  2820. This configuration file provides details about the device
  2821. you are adding.
  2822. </para>
  2823. <para>
  2824. The OpenEmbedded build system uses the root name of the
  2825. machine configuration file to reference the new machine.
  2826. For example, given a machine configuration file named
  2827. <filename>crownbay.conf</filename>, the build system
  2828. recognizes the machine as "crownbay".
  2829. </para>
  2830. <para>
  2831. The most important variables you must set in your machine
  2832. configuration file or include from a lower-level configuration
  2833. file are as follows:
  2834. <itemizedlist>
  2835. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  2836. (e.g. "arm")</para></listitem>
  2837. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  2838. </para></listitem>
  2839. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  2840. (e.g. "apm screen wifi")</para></listitem>
  2841. </itemizedlist>
  2842. </para>
  2843. <para>
  2844. You might also need these variables:
  2845. <itemizedlist>
  2846. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  2847. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  2848. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  2849. (e.g. "zImage")</para></listitem>
  2850. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  2851. (e.g. "tar.gz jffs2")</para></listitem>
  2852. </itemizedlist>
  2853. </para>
  2854. <para>
  2855. You can find full details on these variables in the reference
  2856. section.
  2857. You can leverage existing machine <filename>.conf</filename>
  2858. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  2859. </para>
  2860. </section>
  2861. <section id="platdev-newmachine-kernel">
  2862. <title>Adding a Kernel for the Machine</title>
  2863. <para>
  2864. The OpenEmbedded build system needs to be able to build a kernel
  2865. for the machine.
  2866. You need to either create a new kernel recipe for this machine,
  2867. or extend an existing kernel recipe.
  2868. You can find several kernel recipe examples in the
  2869. Source Directory at
  2870. <filename>meta/recipes-kernel/linux</filename>
  2871. that you can use as references.
  2872. </para>
  2873. <para>
  2874. If you are creating a new kernel recipe, normal recipe-writing
  2875. rules apply for setting up a
  2876. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  2877. Thus, you need to specify any necessary patches and set
  2878. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  2879. to point at the source code.
  2880. You need to create a <filename>do_configure</filename> task that
  2881. configures the unpacked kernel with a
  2882. <filename>defconfig</filename> file.
  2883. You can do this by using a <filename>make defconfig</filename>
  2884. command or, more commonly, by copying in a suitable
  2885. <filename>defconfig</filename> file and then running
  2886. <filename>make oldconfig</filename>.
  2887. By making use of <filename>inherit kernel</filename> and
  2888. potentially some of the <filename>linux-*.inc</filename> files,
  2889. most other functionality is centralized and the defaults of the
  2890. class normally work well.
  2891. </para>
  2892. <para>
  2893. If you are extending an existing kernel recipe, it is usually
  2894. a matter of adding a suitable <filename>defconfig</filename>
  2895. file.
  2896. The file needs to be added into a location similar to
  2897. <filename>defconfig</filename> files used for other machines
  2898. in a given kernel recipe.
  2899. A possible way to do this is by listing the file in the
  2900. <filename>SRC_URI</filename> and adding the machine to the
  2901. expression in
  2902. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  2903. <literallayout class='monospaced'>
  2904. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  2905. </literallayout>
  2906. </para>
  2907. </section>
  2908. <section id="platdev-newmachine-formfactor">
  2909. <title>Adding a Formfactor Configuration File</title>
  2910. <para>
  2911. A formfactor configuration file provides information about the
  2912. target hardware for which the image is being built and information that
  2913. the build system cannot obtain from other sources such as the kernel.
  2914. Some examples of information contained in a formfactor configuration file include
  2915. framebuffer orientation, whether or not the system has a keyboard,
  2916. the positioning of the keyboard in relation to the screen, and
  2917. the screen resolution.
  2918. </para>
  2919. <para>
  2920. The build system uses reasonable defaults in most cases.
  2921. However, if customization is
  2922. necessary, you need to create a <filename>machconfig</filename> file
  2923. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  2924. directory.
  2925. This directory contains directories for specific machines such as
  2926. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  2927. For information about the settings available and the defaults, see the
  2928. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  2929. same area.
  2930. </para>
  2931. <para>
  2932. Following is an example for "qemuarm" machine:
  2933. <literallayout class='monospaced'>
  2934. HAVE_TOUCHSCREEN=1
  2935. HAVE_KEYBOARD=1
  2936. DISPLAY_CAN_ROTATE=0
  2937. DISPLAY_ORIENTATION=0
  2938. #DISPLAY_WIDTH_PIXELS=640
  2939. #DISPLAY_HEIGHT_PIXELS=480
  2940. #DISPLAY_BPP=16
  2941. DISPLAY_DPI=150
  2942. DISPLAY_SUBPIXEL_ORDER=vrgb
  2943. </literallayout>
  2944. </para>
  2945. </section>
  2946. </section>
  2947. <section id="platdev-working-with-libraries">
  2948. <title>Working With Libraries</title>
  2949. <para>
  2950. Libraries are an integral part of your system.
  2951. This section describes some common practices you might find
  2952. helpful when working with libraries to build your system:
  2953. <itemizedlist>
  2954. <listitem><para><link linkend='including-static-library-files'>How to include static library files</link>
  2955. </para></listitem>
  2956. <listitem><para><link linkend='combining-multiple-versions-library-files-into-one-image'>How to use the Multilib feature to combine multiple versions of library files into a single image</link>
  2957. </para></listitem>
  2958. <listitem><para><link linkend='installing-multiple-versions-of-the-same-library'>How to install multiple versions of the same library in parallel on the same system</link>
  2959. </para></listitem>
  2960. </itemizedlist>
  2961. </para>
  2962. <section id='including-static-library-files'>
  2963. <title>Including Static Library Files</title>
  2964. <para>
  2965. If you are building a library and the library offers static linking, you can control
  2966. which static library files (<filename>*.a</filename> files) get included in the
  2967. built library.
  2968. </para>
  2969. <para>
  2970. The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  2971. and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink>
  2972. variables in the
  2973. <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed
  2974. by the <filename>do_install</filename> task are packaged.
  2975. By default, the <filename>PACKAGES</filename> variable includes
  2976. <filename>${PN}-staticdev</filename>, which represents all static library files.
  2977. <note>
  2978. Some previously released versions of the Yocto Project
  2979. defined the static library files through
  2980. <filename>${PN}-dev</filename>.
  2981. </note>
  2982. Following is part of the BitBake configuration file, where
  2983. you can see how the static library files are defined:
  2984. <literallayout class='monospaced'>
  2985. PACKAGE_BEFORE_PN ?= ""
  2986. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  2987. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  2988. FILES = ""
  2989. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  2990. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  2991. ${base_bindir}/* ${base_sbindir}/* \
  2992. ${base_libdir}/*${SOLIBS} \
  2993. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  2994. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  2995. ${datadir}/pixmaps ${datadir}/applications \
  2996. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  2997. ${libdir}/bonobo/servers"
  2998. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  2999. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  3000. ${datadir}/gnome/help"
  3001. SECTION_${PN}-doc = "doc"
  3002. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  3003. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  3004. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  3005. ${datadir}/aclocal ${base_libdir}/*.o \
  3006. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  3007. SECTION_${PN}-dev = "devel"
  3008. ALLOW_EMPTY_${PN}-dev = "1"
  3009. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  3010. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  3011. SECTION_${PN}-staticdev = "devel"
  3012. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  3013. </literallayout>
  3014. </para>
  3015. </section>
  3016. <section id="combining-multiple-versions-library-files-into-one-image">
  3017. <title>Combining Multiple Versions of Library Files into One Image</title>
  3018. <para>
  3019. The build system offers the ability to build libraries with different
  3020. target optimizations or architecture formats and combine these together
  3021. into one system image.
  3022. You can link different binaries in the image
  3023. against the different libraries as needed for specific use cases.
  3024. This feature is called "Multilib."
  3025. </para>
  3026. <para>
  3027. An example would be where you have most of a system compiled in 32-bit
  3028. mode using 32-bit libraries, but you have something large, like a database
  3029. engine, that needs to be a 64-bit application and uses 64-bit libraries.
  3030. Multilib allows you to get the best of both 32-bit and 64-bit libraries.
  3031. </para>
  3032. <para>
  3033. While the Multilib feature is most commonly used for 32 and 64-bit differences,
  3034. the approach the build system uses facilitates different target optimizations.
  3035. You could compile some binaries to use one set of libraries and other binaries
  3036. to use a different set of libraries.
  3037. The libraries could differ in architecture, compiler options, or other
  3038. optimizations.
  3039. </para>
  3040. <para>
  3041. This section overviews the Multilib process only.
  3042. For more details on how to implement Multilib, see the
  3043. <ulink url='&YOCTO_WIKI_URL;/wiki/Multilib'>Multilib</ulink> wiki
  3044. page.
  3045. </para>
  3046. <para>
  3047. Aside from this wiki page, several examples exist in the
  3048. <filename>meta-skeleton</filename> layer found in the
  3049. <link linkend='source-directory'>Source Directory</link>:
  3050. <itemizedlist>
  3051. <listitem><para><filename>conf/multilib-example.conf</filename>
  3052. configuration file</para></listitem>
  3053. <listitem><para><filename>conf/multilib-example2.conf</filename>
  3054. configuration file</para></listitem>
  3055. <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename>
  3056. recipe</para></listitem>
  3057. </itemizedlist>
  3058. </para>
  3059. <section id='preparing-to-use-multilib'>
  3060. <title>Preparing to Use Multilib</title>
  3061. <para>
  3062. User-specific requirements drive the Multilib feature.
  3063. Consequently, there is no one "out-of-the-box" configuration that likely
  3064. exists to meet your needs.
  3065. </para>
  3066. <para>
  3067. In order to enable Multilib, you first need to ensure your recipe is
  3068. extended to support multiple libraries.
  3069. Many standard recipes are already extended and support multiple libraries.
  3070. You can check in the <filename>meta/conf/multilib.conf</filename>
  3071. configuration file in the
  3072. <link linkend='source-directory'>Source Directory</link> to see how this is
  3073. done using the
  3074. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink>
  3075. variable.
  3076. Eventually, all recipes will be covered and this list will
  3077. not be needed.
  3078. </para>
  3079. <para>
  3080. For the most part, the Multilib class extension works automatically to
  3081. extend the package name from <filename>${PN}</filename> to
  3082. <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename>
  3083. is the particular multilib (e.g. "lib32-" or "lib64-").
  3084. Standard variables such as
  3085. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  3086. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  3087. <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>,
  3088. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  3089. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and
  3090. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink>
  3091. are automatically extended by the system.
  3092. If you are extending any manual code in the recipe, you can use the
  3093. <filename>${MLPREFIX}</filename> variable to ensure those names are extended
  3094. correctly.
  3095. This automatic extension code resides in <filename>multilib.bbclass</filename>.
  3096. </para>
  3097. </section>
  3098. <section id='using-multilib'>
  3099. <title>Using Multilib</title>
  3100. <para>
  3101. After you have set up the recipes, you need to define the actual
  3102. combination of multiple libraries you want to build.
  3103. You accomplish this through your <filename>local.conf</filename>
  3104. configuration file in the
  3105. <link linkend='build-directory'>Build Directory</link>.
  3106. An example configuration would be as follows:
  3107. <literallayout class='monospaced'>
  3108. MACHINE = "qemux86-64"
  3109. require conf/multilib.conf
  3110. MULTILIBS = "multilib:lib32"
  3111. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  3112. IMAGE_INSTALL = "lib32-connman"
  3113. </literallayout>
  3114. This example enables an
  3115. additional library named <filename>lib32</filename> alongside the
  3116. normal target packages.
  3117. When combining these "lib32" alternatives, the example uses "x86" for tuning.
  3118. For information on this particular tuning, see
  3119. <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>.
  3120. </para>
  3121. <para>
  3122. The example then includes <filename>lib32-connman</filename>
  3123. in all the images, which illustrates one method of including a
  3124. multiple library dependency.
  3125. You can use a normal image build to include this dependency,
  3126. for example:
  3127. <literallayout class='monospaced'>
  3128. $ bitbake core-image-sato
  3129. </literallayout>
  3130. You can also build Multilib packages specifically with a command like this:
  3131. <literallayout class='monospaced'>
  3132. $ bitbake lib32-connman
  3133. </literallayout>
  3134. </para>
  3135. </section>
  3136. <section id='additional-implementation-details'>
  3137. <title>Additional Implementation Details</title>
  3138. <para>
  3139. Different packaging systems have different levels of native Multilib
  3140. support.
  3141. For the RPM Package Management System, the following implementation details
  3142. exist:
  3143. <itemizedlist>
  3144. <listitem><para>A unique architecture is defined for the Multilib packages,
  3145. along with creating a unique deploy folder under
  3146. <filename>tmp/deploy/rpm</filename> in the
  3147. <link linkend='build-directory'>Build Directory</link>.
  3148. For example, consider <filename>lib32</filename> in a
  3149. <filename>qemux86-64</filename> image.
  3150. The possible architectures in the system are "all", "qemux86_64",
  3151. "lib32_qemux86_64", and "lib32_x86".</para></listitem>
  3152. <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from
  3153. <filename>${PN}</filename> during RPM packaging.
  3154. The naming for a normal RPM package and a Multilib RPM package in a
  3155. <filename>qemux86-64</filename> system resolves to something similar to
  3156. <filename>bash-4.1-r2.x86_64.rpm</filename> and
  3157. <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively.
  3158. </para></listitem>
  3159. <listitem><para>When installing a Multilib image, the RPM backend first
  3160. installs the base image and then installs the Multilib libraries.
  3161. </para></listitem>
  3162. <listitem><para>The build system relies on RPM to resolve the identical files in the
  3163. two (or more) Multilib packages.</para></listitem>
  3164. </itemizedlist>
  3165. </para>
  3166. <para>
  3167. For the IPK Package Management System, the following implementation details exist:
  3168. <itemizedlist>
  3169. <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from
  3170. <filename>${PN}</filename> during IPK packaging.
  3171. The naming for a normal RPM package and a Multilib IPK package in a
  3172. <filename>qemux86-64</filename> system resolves to something like
  3173. <filename>bash_4.1-r2.x86_64.ipk</filename> and
  3174. <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively.
  3175. </para></listitem>
  3176. <listitem><para>The IPK deploy folder is not modified with
  3177. <filename>${MLPREFIX}</filename> because packages with and without
  3178. the Multilib feature can exist in the same folder due to the
  3179. <filename>${PN}</filename> differences.</para></listitem>
  3180. <listitem><para>IPK defines a sanity check for Multilib installation
  3181. using certain rules for file comparison, overridden, etc.
  3182. </para></listitem>
  3183. </itemizedlist>
  3184. </para>
  3185. </section>
  3186. </section>
  3187. <section id='installing-multiple-versions-of-the-same-library'>
  3188. <title>Installing Multiple Versions of the Same Library</title>
  3189. <para>
  3190. Situations can exist where you need to install and use
  3191. multiple versions of the same library on the same system
  3192. at the same time.
  3193. These situations almost always exist when a library API
  3194. changes and you have multiple pieces of software that
  3195. depend on the separate versions of the library.
  3196. To accommodate these situations, you can install multiple
  3197. versions of the same library in parallel on the same system.
  3198. </para>
  3199. <para>
  3200. The process is straightforward as long as the libraries use
  3201. proper versioning.
  3202. With properly versioned libraries, all you need to do to
  3203. individually specify the libraries is create separate,
  3204. appropriately named recipes where the
  3205. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the
  3206. name includes a portion that differentiates each library version
  3207. (e.g.the major part of the version number).
  3208. Thus, instead of having a single recipe that loads one version
  3209. of a library (e.g. <filename>clutter</filename>), you provide
  3210. multiple recipes that result in different versions
  3211. of the libraries you want.
  3212. As an example, the following two recipes would allow the
  3213. two separate versions of the <filename>clutter</filename>
  3214. library to co-exist on the same system:
  3215. <literallayout class='monospaced'>
  3216. clutter-1.6_1.6.20.bb
  3217. clutter-1.8_1.8.4.bb
  3218. </literallayout>
  3219. Additionally, if you have other recipes that depend on a given
  3220. library, you need to use the
  3221. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3222. variable to create the dependency.
  3223. Continuing with the same example, if you want to have a recipe
  3224. depend on the 1.8 version of the <filename>clutter</filename>
  3225. library, use the following in your recipe:
  3226. <literallayout class='monospaced'>
  3227. DEPENDS = "clutter-1.8"
  3228. </literallayout>
  3229. </para>
  3230. </section>
  3231. </section>
  3232. <section id='creating-partitioned-images'>
  3233. <title>Creating Partitioned Images</title>
  3234. <para>
  3235. Creating an image for a particular hardware target using the
  3236. OpenEmbedded build system does not necessarily mean you can boot
  3237. that image as is on your device.
  3238. Physical devices accept and boot images in various ways depending
  3239. on the specifics of the device.
  3240. Usually, information about the hardware can tell you what image
  3241. format the device requires.
  3242. Should your device require multiple partitions on an SD card, flash,
  3243. or an HDD, you can use the OpenEmbedded Image Creator,
  3244. <filename>wic</filename>, to create the properly partitioned image.
  3245. </para>
  3246. <para>
  3247. The <filename>wic</filename> command generates partitioned images
  3248. from existing OpenEmbedded build artifacts.
  3249. Image generation is driven by partitioning commands contained
  3250. in an Openembedded kickstart file (<filename>.wks</filename>)
  3251. specified either directly on the command line or as one of a
  3252. selection of canned <filename>.wks</filename> files as shown
  3253. with the <filename>wic list images</filename> command in the
  3254. "<link linkend='using-a-provided-kickstart_file'>Using an Existing Kickstart File</link>"
  3255. section.
  3256. When applied to a given set of build artifacts, the result is an
  3257. image or set of images that can be directly written onto media and
  3258. used on a particular system.
  3259. </para>
  3260. <para>
  3261. The <filename>wic</filename> command and the infrastructure
  3262. it is based on is by definition incomplete.
  3263. Its purpose is to allow the generation of customized images,
  3264. and as such was designed to be completely extensible through a
  3265. plugin interface.
  3266. See the
  3267. "<link linkend='openembedded-kickstart-plugins'>Plugins</link>"
  3268. section for information on these plugins.
  3269. </para>
  3270. <para>
  3271. This section provides some background information on
  3272. <filename>wic</filename>, describes what you need to have in
  3273. place to run the tool, provides instruction on how to use
  3274. <filename>wic</filename>, and provides several examples.
  3275. </para>
  3276. <section id='wic-background'>
  3277. <title>Background</title>
  3278. <para>
  3279. This section provides some background on the
  3280. <filename>wic</filename> utility.
  3281. While none of this information is required to use
  3282. <filename>wic</filename>, you might find it interesting.
  3283. <itemizedlist>
  3284. <listitem><para>
  3285. The name "wic" is derived from OpenEmbedded
  3286. Image Creator (oeic).
  3287. The "oe" diphthong in "oeic" was promoted to the
  3288. letter "w", because "oeic" is both difficult to remember and
  3289. pronounce.</para></listitem>
  3290. <listitem><para>
  3291. <filename>wic</filename> is loosely based on the
  3292. Meego Image Creator (<filename>mic</filename>)
  3293. framework.
  3294. The <filename>wic</filename> implementation has been
  3295. heavily modified to make direct use of OpenEmbedded
  3296. build artifacts instead of package installation and
  3297. configuration, which are already incorporated within
  3298. the OpenEmbedded artifacts.</para></listitem>
  3299. <listitem><para>
  3300. <filename>wic</filename> is a completely independent
  3301. standalone utility that initially provides
  3302. easier-to-use and more flexible replacements for a
  3303. couple bits of existing functionality in OE Core's
  3304. <filename>boot-directdisk.bbclass</filename> and
  3305. <filename>mkefidisk.sh</filename> scripts.
  3306. The difference between
  3307. <filename>wic</filename> and those examples is
  3308. that with <filename>wic</filename> the
  3309. functionality of those scripts is implemented
  3310. by a general-purpose partitioning language, which is
  3311. based on Redhat kickstart syntax.</para></listitem>
  3312. </itemizedlist>
  3313. </para>
  3314. </section>
  3315. <section id='wic-requirements'>
  3316. <title>Requirements</title>
  3317. <para>
  3318. In order to use the <filename>wic</filename> utility
  3319. with the OpenEmbedded Build system, your system needs
  3320. to meet the following requirements:
  3321. <itemizedlist>
  3322. <listitem><para>The Linux distribution on your
  3323. development host must support the Yocto Project.
  3324. See the
  3325. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  3326. section in the Yocto Project Reference Manual for this
  3327. list of distributions.</para></listitem>
  3328. <listitem><para>
  3329. The standard system utilities, such as
  3330. <filename>cp</filename>, must be installed on your
  3331. development host system.
  3332. </para></listitem>
  3333. <listitem><para>
  3334. The
  3335. <ulink url='http://www.gnu.org/software/parted/'>GNU Parted</ulink>
  3336. package must be installed on your development host
  3337. system.
  3338. </para></listitem>
  3339. <listitem><para>
  3340. You need to have the build artifacts already
  3341. available, which typically means that you must
  3342. have already created an image using the
  3343. Openembedded build system (e.g.
  3344. <filename>core-image-minimal</filename>).
  3345. While it might seem redundant to generate an image in
  3346. order to create an image using
  3347. <filename>wic</filename>, the current version of
  3348. <filename>wic</filename> requires the artifacts
  3349. in the form generated by the build system.
  3350. </para></listitem>
  3351. <listitem><para>
  3352. You must have sourced one of the build environment
  3353. setup scripts (i.e.
  3354. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  3355. or
  3356. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  3357. found in the
  3358. <link linkend='build-directory'>Build Directory</link>.
  3359. </para></listitem>
  3360. </itemizedlist>
  3361. </para>
  3362. </section>
  3363. <section id='wic-getting-help'>
  3364. <title>Getting Help</title>
  3365. <para>
  3366. You can get general help for the <filename>wic</filename>
  3367. by entering the <filename>wic</filename> command by itself
  3368. or by entering the command with a help argument as follows:
  3369. <literallayout class='monospaced'>
  3370. $ wic -h
  3371. $ wic &dash;&dash;help
  3372. </literallayout>
  3373. </para>
  3374. <para>
  3375. Currently, <filename>wic</filename> supports two commands:
  3376. <filename>create</filename> and <filename>list</filename>.
  3377. You can get help for these commands as follows:
  3378. <literallayout class='monospaced'>
  3379. $ wic help <replaceable>command</replaceable>
  3380. </literallayout>
  3381. </para>
  3382. <para>
  3383. You can also get detailed help on a number of topics
  3384. from the help system.
  3385. The output of <filename>wic &dash;&dash;help</filename>
  3386. displays a list of available help
  3387. topics under a "Help topics" heading.
  3388. You can have the help system display the help text for
  3389. a given topic by prefacing the topic with
  3390. <filename>wic help</filename>:
  3391. <literallayout class='monospaced'>
  3392. $ wic help <replaceable>help_topic</replaceable>
  3393. </literallayout>
  3394. </para>
  3395. <para>
  3396. You can find out more about the images
  3397. <filename>wic</filename> creates using the existing
  3398. kickstart files with the following form of the command:
  3399. <literallayout class='monospaced'>
  3400. $ wic list <replaceable>image</replaceable> help
  3401. </literallayout>
  3402. where <filename><replaceable>image</replaceable></filename> is either
  3403. <filename>directdisk</filename> or
  3404. <filename>mkefidisk</filename>.
  3405. </para>
  3406. </section>
  3407. <section id='operational-modes'>
  3408. <title>Operational Modes</title>
  3409. <para>
  3410. You can use <filename>wic</filename> in two different
  3411. modes, depending on how much control you need for
  3412. specifying the Openembedded build artifacts that are
  3413. used for creating the image: Raw and Cooked:
  3414. <itemizedlist>
  3415. <listitem><para><emphasis>Raw Mode:</emphasis>
  3416. You explicitly specify build artifacts through
  3417. command-line arguments.</para></listitem>
  3418. <listitem><para><emphasis>Cooked Mode:</emphasis>
  3419. The current
  3420. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  3421. setting and image name are used to automatically locate
  3422. and provide the build artifacts.</para></listitem>
  3423. </itemizedlist>
  3424. </para>
  3425. <para>
  3426. Regardless of the mode you use, you need to have the build
  3427. artifacts ready and available.
  3428. Additionally, the environment must be set up using the
  3429. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  3430. or
  3431. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>
  3432. script found in the
  3433. <link linkend='build-directory'>Build Directory</link>.
  3434. </para>
  3435. <section id='raw-mode'>
  3436. <title>Raw Mode</title>
  3437. <para>
  3438. The general form of the 'wic' command in raw mode is:
  3439. <literallayout class='monospaced'>
  3440. $ wic create <replaceable>image_name</replaceable>.wks [<replaceable>options</replaceable>] [...]
  3441. Where:
  3442. <replaceable>image_name</replaceable>.wks
  3443. An OpenEmbedded kickstart file. You can provide
  3444. your own custom file or use a file from a set of
  3445. existing files as described by further options.
  3446. -o <replaceable>OUTDIR</replaceable>, &dash;&dash;outdir=<replaceable>OUTDIR</replaceable>
  3447. The name of a directory in which to create image.
  3448. -i <replaceable>PROPERTIES_FILE</replaceable>, &dash;&dash;infile=<replaceable>PROPERTIES_FILE</replaceable>
  3449. The name of a file containing the values for image
  3450. properties as a JSON file.
  3451. -e <replaceable>IMAGE_NAME</replaceable>, &dash;&dash;image-name=<replaceable>IMAGE_NAME</replaceable>
  3452. The name of the image from which to use the artifacts
  3453. (e.g. <filename>core-image-sato</filename>).
  3454. -r <replaceable>ROOTFS_DIR</replaceable>, &dash;&dash;rootfs-dir=<replaceable>ROOTFS_DIR</replaceable>
  3455. The path to the <filename>/rootfs</filename> directory to use as the
  3456. <filename>.wks</filename> rootfs source.
  3457. -b <replaceable>BOOTIMG_DIR</replaceable>, &dash;&dash;bootimg-dir=<replaceable>BOOTIMG_DIR</replaceable>
  3458. The path to the directory containing the boot artifacts
  3459. (e.g. <filename>/EFI</filename> or <filename>/syslinux</filename>) to use as the <filename>.wks</filename> bootimg
  3460. source.
  3461. -k <replaceable>KERNEL_DIR</replaceable>, &dash;&dash;kernel-dir=<replaceable>KERNEL_DIR</replaceable>
  3462. The path to the directory containing the kernel to use
  3463. in the <filename>.wks</filename> boot image.
  3464. -n <replaceable>NATIVE_SYSROOT</replaceable>, &dash;&dash;native-sysroot=<replaceable>NATIVE_SYSROOT</replaceable>
  3465. The path to the native sysroot containing the tools to use
  3466. to build the image.
  3467. -s, &dash;&dash;skip-build-check
  3468. Skips the build check.
  3469. -D, &dash;&dash;debug
  3470. Output debug information.
  3471. </literallayout>
  3472. <note>
  3473. You do not need root privileges to run
  3474. <filename>wic</filename>.
  3475. In fact, you should not run as root when using the
  3476. utility.
  3477. </note>
  3478. </para>
  3479. </section>
  3480. <section id='cooked-mode'>
  3481. <title>Cooked Mode</title>
  3482. <para>
  3483. The general form of the <filename>wic</filename> command
  3484. using Cooked Mode is:
  3485. <literallayout class='monospaced'>
  3486. $ wic create <replaceable>kickstart_file</replaceable> -e <replaceable>image_name</replaceable>
  3487. Where:
  3488. <replaceable>kickstart_file</replaceable>
  3489. An OpenEmbedded kickstart file. You can provide your own
  3490. custom file or supplied file.
  3491. <replaceable>image_name</replaceable>
  3492. Specifies the image built using the OpenEmbedded build
  3493. system.
  3494. </literallayout>
  3495. This form is the simplest and most user-friendly, as it
  3496. does not require specifying all individual parameters.
  3497. All you need to provide is your own
  3498. <filename>.wks</filename> file or one provided with the
  3499. release.
  3500. </para>
  3501. </section>
  3502. </section>
  3503. <section id='using-a-provided-kickstart_file'>
  3504. <title>Using an Existing Kickstart File</title>
  3505. <para>
  3506. If you do not want to create your own
  3507. <filename>.wks</filename> file, you can use an existing
  3508. file provided by the <filename>wic</filename> installation.
  3509. Use the following command to list the available files:
  3510. <literallayout class='monospaced'>
  3511. $ wic list images
  3512. directdisk Create a 'pcbios' direct disk image
  3513. mkefidisk Create an EFI disk image
  3514. </literallayout>
  3515. When you use an existing file, you do not have to use the
  3516. <filename>.wks</filename> extension.
  3517. Here is an example in Raw Mode that uses the
  3518. <filename>directdisk</filename> file:
  3519. <literallayout class='monospaced'>
  3520. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  3521. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  3522. </literallayout>
  3523. </para>
  3524. <para>
  3525. Here are the actual partition language commands
  3526. used in the <filename>mkefidisk.wks</filename> file to generate
  3527. an image:
  3528. <literallayout class='monospaced'>
  3529. # short-description: Create an EFI disk image
  3530. # long-description: Creates a partitioned EFI disk image that the user
  3531. # can directly dd to boot media.
  3532. part /boot --source bootimg-efi --ondisk sda --label msdos --active --align 1024
  3533. part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024
  3534. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  3535. bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0"
  3536. </literallayout>
  3537. </para>
  3538. </section>
  3539. <section id='wic-usage-examples'>
  3540. <title>Examples</title>
  3541. <para>
  3542. This section provides several examples that show how to use
  3543. the <filename>wic</filename> utility.
  3544. All the examples assume the list of requirements in the
  3545. "<link linkend='wic-requirements'>Requirements</link>" section
  3546. have been met.
  3547. The examples assume the previously generated image is
  3548. <filename>core-image-minimal</filename>.
  3549. </para>
  3550. <section id='generate-an-image-using-a-provided-kickstart-file'>
  3551. <title>Generate an Image using an Existing Kickstart File</title>
  3552. <para>
  3553. This example runs in Cooked Mode and uses the
  3554. <filename>mkefidisk</filename> kickstart file:
  3555. <literallayout class='monospaced'>
  3556. $ wic create mkefidisk -e core-image-minimal
  3557. Checking basic build environment...
  3558. Done.
  3559. Creating image(s)...
  3560. Info: The new image(s) can be found here:
  3561. /var/tmp/wic/build/mkefidisk-201310230946-sda.direct
  3562. The following build artifacts were used to create the image(s):
  3563. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/rootfs
  3564. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/core-image-minimal-1.0/hddimg
  3565. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/minnow/usr/src/kernel
  3566. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  3567. The image(s) were created using OE kickstart file:
  3568. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/mkefidisk.wks
  3569. </literallayout>
  3570. This example shows the easiest way to create an image
  3571. by running in Cooked Mode and using the
  3572. <filename>-e</filename> option with an existing kickstart
  3573. file.
  3574. All that is necessary is to specify the image used to
  3575. generate the artifacts.
  3576. Your <filename>local.conf</filename> needs to have the
  3577. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  3578. variable set to the machine you are using, which is
  3579. "minnow" in this example.
  3580. </para>
  3581. <para>
  3582. The output specifies the exact created as well as where
  3583. it was created.
  3584. The output also names the artifacts used and the exact
  3585. <filename>.wks</filename> script that was used to generate
  3586. the image.
  3587. <note>
  3588. You should always verify the details provided in the
  3589. output to make sure that the image was indeed created
  3590. exactly as expected.
  3591. </note>
  3592. </para>
  3593. <para>
  3594. Continuing with the example, you can now directly
  3595. <filename>dd</filename> the image to a USB stick, or
  3596. whatever media for which you built your image,
  3597. and boot the resulting media:
  3598. <literallayout class='monospaced'>
  3599. $ sudo dd if=/var/tmp/wic/build/mkefidisk-201310230946-sda.direct of=/dev/sdb
  3600. [sudo] password for trz:
  3601. 182274+0 records in
  3602. 182274+0 records out
  3603. 93324288 bytes (93 MB) copied, 14.4777 s, 6.4 MB/s
  3604. [trz@empanada ~]$ sudo eject /dev/sdb
  3605. </literallayout>
  3606. </para>
  3607. </section>
  3608. <section id='using-a-modified-kickstart-file'>
  3609. <title>Using a Modified Kickstart File</title>
  3610. <para>
  3611. Because <filename>wic</filename> image creation is driven
  3612. by the kickstart file, it is easy to affect image creation
  3613. by changing the parameters in the file.
  3614. This next example demonstrates that through modification
  3615. of the <filename>directdisk</filename> kickstart file.
  3616. </para>
  3617. <para>
  3618. As mentioned earlier, you can use the command
  3619. <filename>wic list images</filename> to show the list
  3620. of existing kickstart files.
  3621. The directory in which these files reside is
  3622. <filename>scripts/lib/image/canned-wks/</filename>
  3623. located in the
  3624. <link linkend='source-directory'>Source Directory</link>.
  3625. Because the available files reside in this directory, you
  3626. can create and add your own custom files to the directory.
  3627. Subsequent use of the <filename>wic list images</filename>
  3628. command would then include your kickstart files.
  3629. </para>
  3630. <para>
  3631. In this example, the existing
  3632. <filename>directdisk</filename> file already does most
  3633. of what is needed.
  3634. However, for the hardware in this example, the image will
  3635. need to boot from <filename>sdb</filename> instead of
  3636. <filename>sda</filename>, which is what the
  3637. <filename>directdisk</filename> kickstart file uses.
  3638. </para>
  3639. <para>
  3640. The example begins by making a copy of the
  3641. <filename>directdisk.wks</filename> file in the
  3642. <filename>scripts/lib/image/canned-wks</filename>
  3643. directory and then changing the lines that specify the
  3644. target disk from which to boot.
  3645. <literallayout class='monospaced'>
  3646. $ cp /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks \
  3647. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks
  3648. </literallayout>
  3649. Next, the example modifies the
  3650. <filename>directdisksdb.wks</filename> file and changes all
  3651. instances of "<filename>&dash;&dash;ondisk sda</filename>"
  3652. to "<filename>&dash;&dash;ondisk sdb</filename>".
  3653. The example changes the following two lines and leaves the
  3654. remaining lines untouched:
  3655. <literallayout class='monospaced'>
  3656. part /boot &dash;&dash;source bootimg-pcbios &dash;&dash;ondisk sdb &dash;&dash;label boot &dash;&dash;active &dash;&dash;align 1024
  3657. part / &dash;&dash;source rootfs &dash;&dash;ondisk sdb &dash;&dash;fstype=ext3 &dash;&dash;label platform &dash;&dash;align 1024
  3658. </literallayout>
  3659. Once the lines are changed, the example generates the
  3660. <filename>directdisksdb</filename> image.
  3661. The command points the process at the
  3662. <filename>core-image-minimal</filename> artifacts for the
  3663. Next Unit of Computing (nuc)
  3664. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  3665. the <filename>local.conf</filename>.
  3666. <literallayout class='monospaced'>
  3667. $ wic create directdisksdb -e core-image-minimal
  3668. Checking basic build environment...
  3669. Done.
  3670. Creating image(s)...
  3671. Info: The new image(s) can be found here:
  3672. /var/tmp/wic/build/directdisksdb-201310231131-sdb.direct
  3673. The following build artifacts were used to create the image(s):
  3674. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/nuc-poky-linux/core-image-minimal/1.0-r0/rootfs
  3675. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/share
  3676. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/src/kernel
  3677. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  3678. The image(s) were created using OE kickstart file:
  3679. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks
  3680. </literallayout>
  3681. Continuing with the example, you can now directly
  3682. <filename>dd</filename> the image to a USB stick, or
  3683. whatever media for which you built your image,
  3684. and boot the resulting media:
  3685. <literallayout class='monospaced'>
  3686. $ sudo dd if=/var/tmp/wic/build/directdisksdb-201310231131-sdb.direct of=/dev/sdb
  3687. 86018+0 records in
  3688. 86018+0 records out
  3689. 44041216 bytes (44 MB) copied, 13.0734 s, 3.4 MB/s
  3690. [trz@empanada tmp]$ sudo eject /dev/sdb
  3691. </literallayout>
  3692. </para>
  3693. </section>
  3694. <section id='creating-an-image-based-on-core-image-minimal-and-crownbay-noemgd'>
  3695. <title>Creating an Image Based on <filename>core-image-minimal</filename> and <filename>crownbay-noemgd</filename></title>
  3696. <para>
  3697. This example creates an image based on
  3698. <filename>core-image-minimal</filename> and a
  3699. <filename>crownbay-noemgd</filename>
  3700. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  3701. that works right out of the box.
  3702. <literallayout class='monospaced'>
  3703. $ wic create directdisk -e core-image-minimal
  3704. Checking basic build environment...
  3705. Done.
  3706. Creating image(s)...
  3707. Info: The new image(s) can be found here:
  3708. /var/tmp/wic/build/directdisk-201309252350-sda.direct
  3709. The following build artifacts were used to create the image(s):
  3710. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs
  3711. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share
  3712. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  3713. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  3714. The image(s) were created using OE kickstart file:
  3715. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks
  3716. </literallayout>
  3717. </para>
  3718. </section>
  3719. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  3720. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  3721. <para>
  3722. This next example manually specifies each build artifact
  3723. (runs in Raw Mode) and uses a modified kickstart file.
  3724. The example also uses the <filename>-o</filename> option
  3725. to cause <filename>wic</filename> to create the output
  3726. somewhere other than the default
  3727. <filename>/var/tmp/wic</filename> directory:
  3728. <literallayout class='monospaced'>
  3729. $ wic create ~/test.wks -o /home/trz/testwic &dash;&dash;rootfs-dir \
  3730. /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs \
  3731. &dash;&dash;bootimg-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share \
  3732. &dash;&dash;kernel-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel \
  3733. &dash;&dash;native-sysroot /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  3734. Creating image(s)...
  3735. Info: The new image(s) can be found here:
  3736. /home/trz/testwic/build/test-201309260032-sda.direct
  3737. The following build artifacts were used to create the image(s):
  3738. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs
  3739. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share
  3740. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  3741. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  3742. The image(s) were created using OE kickstart file:
  3743. /home/trz/test.wks
  3744. </literallayout>
  3745. For this example,
  3746. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  3747. did not have to be specified in the
  3748. <filename>local.conf</filename> file since the artifact is
  3749. manually specified.
  3750. </para>
  3751. </section>
  3752. </section>
  3753. <section id='openembedded-kickstart-plugins'>
  3754. <title>Plugins</title>
  3755. <para>
  3756. Plugins allow <filename>wic</filename> functionality to
  3757. be extended and specialized by users.
  3758. This section documents the plugin interface, which is
  3759. currently restricted to source plugins.
  3760. </para>
  3761. <para>
  3762. Source plugins provide a mechanism to customize
  3763. various aspects of the image generation process in
  3764. <filename>wic</filename>, mainly the contents of
  3765. partitions.
  3766. The plugins provide a mechanism for mapping values
  3767. specified in <filename>.wks</filename> files using the
  3768. <filename>&dash;&dash;source</filename> keyword to a
  3769. particular plugin implementation that populates a
  3770. corresponding partition.
  3771. </para>
  3772. <para>
  3773. A source plugin is created as a subclass of
  3774. <filename>SourcePlugin</filename>.
  3775. The plugin file containing it is added to
  3776. <filename>scripts/lib/mic/plugins/source/</filename> to
  3777. make the plugin implementation available to the
  3778. <filename>wic</filename> implementation.
  3779. For more information, see
  3780. <filename>scripts/lib/mic/pluginbase.py</filename>.
  3781. </para>
  3782. <para>
  3783. Source plugins can also be implemented and added by
  3784. external layers.
  3785. As such, any plugins found in a
  3786. <filename>scripts/lib/mic/plugins/source/</filename>
  3787. directory in an external layer are also made
  3788. available.
  3789. </para>
  3790. <para>
  3791. When the <filename>wic</filename> implementation needs
  3792. to invoke a partition-specific implementation, it looks
  3793. for the plugin that has the same name as the
  3794. <filename>&dash;&dash;source</filename> parameter given to
  3795. that partition.
  3796. For example, if the partition is set up as follows:
  3797. <literallayout class='monospaced'>
  3798. part /boot &dash;&dash;source bootimg-pcbios ...
  3799. </literallayout>
  3800. The methods defined as class members of the plugin
  3801. having the matching <filename>bootimg-pcbios.name</filename>
  3802. class member are used.
  3803. </para>
  3804. <para>
  3805. To be more concrete, here is the plugin definition that
  3806. matches a
  3807. <filename>&dash;&dash;source bootimg-pcbios</filename> usage,
  3808. along with an example
  3809. method called by the <filename>wic</filename> implementation
  3810. when it needs to invoke an implementation-specific
  3811. partition-preparation function:
  3812. <literallayout class='monospaced'>
  3813. class BootimgPcbiosPlugin(SourcePlugin):
  3814. name = 'bootimg-pcbios'
  3815. @classmethod
  3816. def do_prepare_partition(self, part, ...)
  3817. </literallayout>
  3818. If the subclass itself does not implement a function, a
  3819. default version in a superclass is located and
  3820. used, which is why all plugins must be derived from
  3821. <filename>SourcePlugin</filename>.
  3822. </para>
  3823. <para>
  3824. The <filename>SourcePlugin</filename> class defines the
  3825. following methods, which is the current set of methods
  3826. that can be implemented or overridden by
  3827. <filename>&dash;&dash;source</filename> plugins.
  3828. Any methods not implemented by a
  3829. <filename>SourcePlugin</filename> subclass inherit the
  3830. implementations present in the
  3831. <filename>SourcePlugin</filename> class.
  3832. For more information, see the
  3833. <filename>SourcePlugin</filename> source for details:
  3834. </para>
  3835. <para>
  3836. <itemizedlist>
  3837. <listitem><para><emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  3838. Called to do the actual content population for a
  3839. partition.
  3840. In other words, the method prepares the final
  3841. partition image that is incorporated into the
  3842. disk image.
  3843. </para></listitem>
  3844. <listitem><para><emphasis><filename>do_configure_partition()</filename>:</emphasis>
  3845. Called before
  3846. <filename>do_prepare_partition()</filename>.
  3847. This method is typically used to create custom
  3848. configuration files for a partition (e.g. syslinux or
  3849. grub configuration files).
  3850. </para></listitem>
  3851. <listitem><para><emphasis><filename>do_install_disk()</filename>:</emphasis>
  3852. Called after all partitions have been prepared and
  3853. assembled into a disk image.
  3854. This method provides a hook to allow finalization of a
  3855. disk image, (e.g. writing an MBR).
  3856. </para></listitem>
  3857. <listitem><para><emphasis><filename>do_stage_partition()</filename>:</emphasis>
  3858. Special content-staging hook called before
  3859. <filename>do_prepare_partition()</filename>.
  3860. This method is normally empty.</para>
  3861. <para>Typically, a partition just uses the passed-in
  3862. parameters (e.g. the unmodified value of
  3863. <filename>bootimg_dir</filename>).
  3864. However, in some cases things might need to be
  3865. more tailored.
  3866. As an example, certain files might additionally
  3867. need to be taken from
  3868. <filename>bootimg_dir + /boot</filename>.
  3869. This hook allows those files to be staged in a
  3870. customized fashion.
  3871. <note>
  3872. <filename>get_bitbake_var()</filename>
  3873. allows you to access non-standard variables
  3874. that you might want to use for this.
  3875. </note>
  3876. </para></listitem>
  3877. </itemizedlist>
  3878. </para>
  3879. <para>
  3880. This scheme is extensible.
  3881. Adding more hooks is a simple matter of adding more
  3882. plugin methods to <filename>SourcePlugin</filename> and
  3883. derived classes.
  3884. The code that then needs to call the plugin methods uses
  3885. <filename>plugin.get_source_plugin_methods()</filename>
  3886. to find the method or methods needed by the call.
  3887. Retrieval of those methods is accomplished
  3888. by filling up a dict with keys
  3889. containing the method names of interest.
  3890. On success, these will be filled in with the actual
  3891. methods.
  3892. Please see the <filename>wic</filename>
  3893. implementation for examples and details.
  3894. </para>
  3895. </section>
  3896. <section id='openembedded-kickstart-wks-reference'>
  3897. <title>OpenEmbedded Kickstart (.wks) Reference</title>
  3898. <para>
  3899. The current <filename>wic</filename> implementation supports
  3900. only the basic kickstart partitioning commands:
  3901. <filename>partition</filename> (or <filename>part</filename>
  3902. for short) and <filename>bootloader</filename>.
  3903. <note>
  3904. Future updates will implement more commands and options.
  3905. If you use anything that is not specifically
  3906. supported, results can be unpredictable.
  3907. </note>
  3908. </para>
  3909. <para>
  3910. The following is a list of the commands, their syntax,
  3911. and meanings.
  3912. The commands are based on the Fedora
  3913. kickstart versions but with modifications to
  3914. reflect <filename>wic</filename> capabilities.
  3915. You can see the original documentation for those commands
  3916. at the following links:
  3917. <itemizedlist>
  3918. <listitem><para>
  3919. <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition'>http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition</ulink>
  3920. </para></listitem>
  3921. <listitem><para>
  3922. <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader'>http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader</ulink>
  3923. </para></listitem>
  3924. </itemizedlist>
  3925. </para>
  3926. <section id='command-part-or-partition'>
  3927. <title>Command: part or partition</title>
  3928. <para>
  3929. This command creates a partition on the system and uses the
  3930. following syntax:
  3931. <literallayout class='monospaced'>
  3932. part <replaceable>mntpoint</replaceable>
  3933. </literallayout>
  3934. The <filename><replaceable>mntpoint</replaceable></filename>
  3935. is where the
  3936. partition will be mounted and must be of one of the
  3937. following forms:
  3938. <itemizedlist>
  3939. <listitem><para><filename>/<replaceable>path</replaceable></filename>:
  3940. For example, <filename>/</filename>,
  3941. <filename>/usr</filename>, and
  3942. <filename>/home</filename></para></listitem>
  3943. <listitem><para><filename>swap</filename>:
  3944. The partition will be used as swap space.
  3945. </para></listitem>
  3946. </itemizedlist>
  3947. </para>
  3948. <para>
  3949. Following are the supported options:
  3950. <itemizedlist>
  3951. <listitem><para><emphasis><filename>&dash;&dash;size</filename>:</emphasis>
  3952. The minimum partition size in MBytes.
  3953. Specify an integer value such as 500.
  3954. Do not append the number with "MB".
  3955. You do not need this option if you use
  3956. <filename>&dash;&dash;source</filename>.</para></listitem>
  3957. <listitem><para><emphasis><filename>&dash;&dash;source</filename>:</emphasis>
  3958. This option is a
  3959. <filename>wic</filename>-specific option that
  3960. names the source of the data that populates
  3961. the partition.
  3962. The most common value for this option is
  3963. "rootfs", but you can use any value that maps to
  3964. a valid source plugin.
  3965. For information on the source plugins, see the
  3966. "<link linkend='openembedded-kickstart-plugins'>Plugins</link>"
  3967. section.</para>
  3968. <para>If you use
  3969. <filename>&dash;&dash;source rootfs</filename>,
  3970. <filename>wic</filename> creates a partition as
  3971. large as needed and to fill it with the contents of
  3972. the root filesystem pointed to by the
  3973. <filename>-r</filename> command-line option
  3974. or the equivalent rootfs derived from the
  3975. <filename>-e</filename> command-line
  3976. option.
  3977. The filesystem type used to create the
  3978. partition is driven by the value of the
  3979. <filename>&dash;&dash;fstype</filename> option
  3980. specified for the partition.
  3981. See the entry on
  3982. <filename>&dash;&dash;fstype</filename> that
  3983. follows for more information.
  3984. </para>
  3985. <para>If you use
  3986. <filename>&dash;&dash;source <replaceable>plugin-name</replaceable></filename>,
  3987. <filename>wic</filename> creates a partition as
  3988. large as needed and fills it with the contents of
  3989. the partition that is generated by the
  3990. specified plugin name using the data pointed
  3991. to by the <filename>-r</filename> command-line
  3992. option or the equivalent rootfs derived from the
  3993. <filename>-e</filename> command-line
  3994. option.
  3995. Exactly what those contents and
  3996. filesystem type end up being are dependent
  3997. on the given plugin implementation.
  3998. </para></listitem>
  3999. <listitem><para><emphasis><filename>&dash;&dash;ondisk</filename> or <filename>&dash;&dash;ondrive</filename>:</emphasis>
  4000. Forces the partition to be created on a particular
  4001. disk.</para></listitem>
  4002. <listitem><para><emphasis><filename>&dash;&dash;fstype</filename>:</emphasis>
  4003. Sets the file system type for the partition.
  4004. Valid values are:
  4005. <itemizedlist>
  4006. <listitem><para><filename>ext4</filename>
  4007. </para></listitem>
  4008. <listitem><para><filename>ext3</filename>
  4009. </para></listitem>
  4010. <listitem><para><filename>ext2</filename>
  4011. </para></listitem>
  4012. <listitem><para><filename>btrfs</filename>
  4013. </para></listitem>
  4014. <listitem><para><filename>squashfs</filename>
  4015. </para></listitem>
  4016. <listitem><para><filename>swap</filename>
  4017. </para></listitem>
  4018. </itemizedlist></para></listitem>
  4019. <listitem><para><emphasis><filename>&dash;&dash;fsoptions</filename>:</emphasis>
  4020. Specifies a free-form string of options to be
  4021. used when mounting the filesystem.
  4022. This string will be copied into the
  4023. <filename>/etc/fstab</filename> file of the
  4024. installed system and should be enclosed in
  4025. quotes.
  4026. If not specified, the default string
  4027. is "defaults".
  4028. </para></listitem>
  4029. <listitem><para><emphasis><filename>&dash;&dash;label label</filename>:</emphasis>
  4030. Specifies the label to give to the filesystem to
  4031. be made on the partition.
  4032. If the given label is already in use by another
  4033. filesystem, a new label is created for the
  4034. partition.</para></listitem>
  4035. <listitem><para><emphasis><filename>&dash;&dash;active</filename>:</emphasis>
  4036. Marks the partition as active.</para></listitem>
  4037. <listitem><para><emphasis><filename>&dash;&dash;align (in KBytes)</filename>:</emphasis>
  4038. This option is a <filename>wic</filename>-specific
  4039. option that says to start a partition on an
  4040. x KBytes boundary.</para></listitem>
  4041. </itemizedlist>
  4042. </para>
  4043. </section>
  4044. <section id='command-bootloader'>
  4045. <title>Command: bootloader</title>
  4046. <para>
  4047. This command specifies how the boot loader should be
  4048. configured and supports the following options:
  4049. <note>
  4050. Bootloader functionality and boot partitions are
  4051. implemented by the various
  4052. <filename>&dash;&dash;source</filename>
  4053. plugins that implement bootloader functionality.
  4054. The bootloader command essentially provides a means of
  4055. modifying bootloader configuration.
  4056. </note>
  4057. <itemizedlist>
  4058. <listitem><para><emphasis><filename>&dash;&dash;timeout</filename>:</emphasis>
  4059. Specifies the number of seconds before the
  4060. bootloader times out and boots the default option.
  4061. </para></listitem>
  4062. <listitem><para><emphasis><filename>&dash;&dash;append</filename>:</emphasis>
  4063. Specifies kernel parameters.
  4064. These parameters will be added to the syslinux
  4065. <filename>APPEND</filename> or
  4066. <filename>grub</filename> kernel command line.
  4067. </para></listitem>
  4068. </itemizedlist>
  4069. </para>
  4070. </section>
  4071. </section>
  4072. </section>
  4073. <section id='configuring-the-kernel'>
  4074. <title>Configuring the Kernel</title>
  4075. <para>
  4076. Configuring the Yocto Project kernel consists of making sure the <filename>.config</filename>
  4077. file has all the right information in it for the image you are building.
  4078. You can use the <filename>menuconfig</filename> tool and configuration fragments to
  4079. make sure your <filename>.config</filename> file is just how you need it.
  4080. This section describes how to use <filename>menuconfig</filename>, create and use
  4081. configuration fragments, and how to interactively modify your <filename>.config</filename>
  4082. file to create the leanest kernel configuration file possible.
  4083. </para>
  4084. <para>
  4085. For more information on kernel configuration, see the
  4086. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  4087. section in the Yocto Project Linux Kernel Development Manual.
  4088. </para>
  4089. <section id='using-menuconfig'>
  4090. <title>Using&nbsp;&nbsp;<filename>menuconfig</filename></title>
  4091. <para>
  4092. The easiest way to define kernel configurations is to set them through the
  4093. <filename>menuconfig</filename> tool.
  4094. This tool provides an interactive method with which
  4095. to set kernel configurations.
  4096. For general information on <filename>menuconfig</filename>, see
  4097. <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>.
  4098. </para>
  4099. <para>
  4100. To use the <filename>menuconfig</filename> tool in the Yocto Project development
  4101. environment, you must launch it using BitBake.
  4102. Thus, the environment must be set up using the
  4103. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  4104. or
  4105. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>
  4106. script found in the
  4107. <link linkend='build-directory'>Build Directory</link>.
  4108. The following commands run <filename>menuconfig</filename> assuming the
  4109. <link linkend='source-directory'>Source Directory</link>
  4110. top-level folder is <filename>~/poky</filename>:
  4111. <literallayout class='monospaced'>
  4112. $ cd poky
  4113. $ source oe-init-build-env
  4114. $ bitbake linux-yocto -c menuconfig
  4115. </literallayout>
  4116. Once <filename>menuconfig</filename> comes up, its standard interface allows you to
  4117. interactively examine and configure all the kernel configuration parameters.
  4118. After making your changes, simply exit the tool and save your changes to
  4119. create an updated version of the <filename>.config</filename> configuration file.
  4120. </para>
  4121. <para>
  4122. Consider an example that configures the <filename>linux-yocto-3.14</filename>
  4123. kernel.
  4124. The OpenEmbedded build system recognizes this kernel as
  4125. <filename>linux-yocto</filename>.
  4126. Thus, the following commands from the shell in which you previously sourced the
  4127. environment initialization script cleans the shared state cache and the
  4128. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  4129. directory and then runs <filename>menuconfig</filename>:
  4130. <literallayout class='monospaced'>
  4131. $ bitbake linux-yocto -c menuconfig
  4132. </literallayout>
  4133. </para>
  4134. <para>
  4135. Once <filename>menuconfig</filename> launches, use the interface
  4136. to navigate through the selections to find the configuration settings in
  4137. which you are interested.
  4138. For example, consider the <filename>CONFIG_SMP</filename> configuration setting.
  4139. You can find it at <filename>Processor Type and Features</filename> under
  4140. the configuration selection <filename>Symmetric Multi-processing Support</filename>.
  4141. After highlighting the selection, use the arrow keys to select or deselect
  4142. the setting.
  4143. When you are finished with all your selections, exit out and save them.
  4144. </para>
  4145. <para>
  4146. Saving the selections updates the <filename>.config</filename> configuration file.
  4147. This is the file that the OpenEmbedded build system uses to configure the
  4148. kernel during the build.
  4149. You can find and examine this file in the Build Directory in
  4150. <filename>tmp/work/</filename>.
  4151. The actual <filename>.config</filename> is located in the area where the
  4152. specific kernel is built.
  4153. For example, if you were building a Linux Yocto kernel based on the
  4154. Linux 3.14 kernel and you were building a QEMU image targeted for
  4155. <filename>x86</filename> architecture, the
  4156. <filename>.config</filename> file would be located here:
  4157. <literallayout class='monospaced'>
  4158. poky/build/tmp/work/qemux86-poky-linux/linux-yocto-3.14.11+git1+84f...
  4159. ...656ed30-r1/linux-qemux86-standard-build
  4160. </literallayout>
  4161. <note>
  4162. The previous example directory is artificially split and many of the characters
  4163. in the actual filename are omitted in order to make it more readable.
  4164. Also, depending on the kernel you are using, the exact pathname
  4165. for <filename>linux-yocto-3.14...</filename> might differ.
  4166. </note>
  4167. </para>
  4168. <para>
  4169. Within the <filename>.config</filename> file, you can see the kernel settings.
  4170. For example, the following entry shows that symmetric multi-processor support
  4171. is not set:
  4172. <literallayout class='monospaced'>
  4173. # CONFIG_SMP is not set
  4174. </literallayout>
  4175. </para>
  4176. <para>
  4177. A good method to isolate changed configurations is to use a combination of the
  4178. <filename>menuconfig</filename> tool and simple shell commands.
  4179. Before changing configurations with <filename>menuconfig</filename>, copy the
  4180. existing <filename>.config</filename> and rename it to something else,
  4181. use <filename>menuconfig</filename> to make
  4182. as many changes as you want and save them, then compare the renamed configuration
  4183. file against the newly created file.
  4184. You can use the resulting differences as your base to create configuration fragments
  4185. to permanently save in your kernel layer.
  4186. <note>
  4187. Be sure to make a copy of the <filename>.config</filename> and don't just
  4188. rename it.
  4189. The build system needs an existing <filename>.config</filename>
  4190. from which to work.
  4191. </note>
  4192. </para>
  4193. </section>
  4194. <section id='creating-config-fragments'>
  4195. <title>Creating Configuration Fragments</title>
  4196. <para>
  4197. Configuration fragments are simply kernel options that appear in a file
  4198. placed where the OpenEmbedded build system can find and apply them.
  4199. Syntactically, the configuration statement is identical to what would appear
  4200. in the <filename>.config</filename> file, which is in the
  4201. <link linkend='build-directory'>Build Directory</link> in
  4202. <filename>tmp/work/&lt;arch&gt;-poky-linux/linux-yocto-&lt;release-specific-string&gt;/linux-&lt;arch&gt;-&lt;build-type&gt;</filename>.
  4203. </para>
  4204. <para>
  4205. It is simple to create a configuration fragment.
  4206. For example, issuing the following from the shell creates a configuration fragment
  4207. file named <filename>my_smp.cfg</filename> that enables multi-processor support
  4208. within the kernel:
  4209. <literallayout class='monospaced'>
  4210. $ echo "CONFIG_SMP=y" >> my_smp.cfg
  4211. </literallayout>
  4212. <note>
  4213. All configuration files must use the <filename>.cfg</filename> extension in order
  4214. for the OpenEmbedded build system to recognize them as a configuration fragment.
  4215. </note>
  4216. </para>
  4217. <para>
  4218. Where do you put your configuration files?
  4219. You can place these configuration files in the same area pointed to by
  4220. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  4221. The OpenEmbedded build system will pick up the configuration and add it to the
  4222. kernel's configuration.
  4223. For example, suppose you had a set of configuration options in a file called
  4224. <filename>myconfig.cfg</filename>.
  4225. If you put that file inside a directory named <filename>linux-yocto</filename>
  4226. that resides in the same directory as the kernel's append file and then add
  4227. a <filename>SRC_URI</filename> statement such as the following to the kernel's append file,
  4228. those configuration options will be picked up and applied when the kernel is built.
  4229. <literallayout class='monospaced'>
  4230. SRC_URI += "file://myconfig.cfg"
  4231. </literallayout>
  4232. </para>
  4233. <para>
  4234. As mentioned earlier, you can group related configurations into multiple files and
  4235. name them all in the <filename>SRC_URI</filename> statement as well.
  4236. For example, you could group separate configurations specifically for Ethernet and graphics
  4237. into their own files and add those by using a <filename>SRC_URI</filename> statement like the
  4238. following in your append file:
  4239. <literallayout class='monospaced'>
  4240. SRC_URI += "file://myconfig.cfg \
  4241. file://eth.cfg \
  4242. file://gfx.cfg"
  4243. </literallayout>
  4244. </para>
  4245. </section>
  4246. <section id='fine-tuning-the-kernel-configuration-file'>
  4247. <title>Fine-Tuning the Kernel Configuration File</title>
  4248. <para>
  4249. You can make sure the <filename>.config</filename> file is as lean or efficient as
  4250. possible by reading the output of the kernel configuration fragment audit,
  4251. noting any issues, making changes to correct the issues, and then repeating.
  4252. </para>
  4253. <para>
  4254. As part of the kernel build process, the
  4255. <filename>do_kernel_configcheck</filename> task runs.
  4256. This task validates the kernel configuration by checking the final
  4257. <filename>.config</filename> file against the input files.
  4258. During the check, the task produces warning messages for the following
  4259. issues:
  4260. <itemizedlist>
  4261. <listitem><para>Requested options that did not make the final
  4262. <filename>.config</filename> file.</para></listitem>
  4263. <listitem><para>Configuration items that appear twice in the same
  4264. configuration fragment.</para></listitem>
  4265. <listitem><para>Configuration items tagged as "required" that were overridden.
  4266. </para></listitem>
  4267. <listitem><para>A board overrides a non-board specific option.</para></listitem>
  4268. <listitem><para>Listed options not valid for the kernel being processed.
  4269. In other words, the option does not appear anywhere.</para></listitem>
  4270. </itemizedlist>
  4271. <note>
  4272. The <filename>do_kernel_configcheck</filename> task can
  4273. also optionally report if an option is overridden during
  4274. processing.
  4275. </note>
  4276. </para>
  4277. <para>
  4278. For each output warning, a message points to the file
  4279. that contains a list of the options and a pointer to the config
  4280. fragment that defines them.
  4281. Collectively, the files are the key to streamlining the configuration.
  4282. </para>
  4283. <para>
  4284. To streamline the configuration, do the following:
  4285. <orderedlist>
  4286. <listitem><para>Start with a full configuration that you
  4287. know works - it builds and boots successfully.
  4288. This configuration file will be your baseline.
  4289. </para></listitem>
  4290. <listitem><para>Separately run the
  4291. <filename>do_configme</filename> and
  4292. <filename>do_kernel_configcheck</filename> tasks.
  4293. </para></listitem>
  4294. <listitem><para>Take the resulting list of files from the
  4295. <filename>do_kernel_configcheck</filename> task
  4296. warnings and do the following:
  4297. <itemizedlist>
  4298. <listitem><para>
  4299. Drop values that are redefined in the fragment
  4300. but do not change the final
  4301. <filename>.config</filename> file.
  4302. </para></listitem>
  4303. <listitem><para>
  4304. Analyze and potentially drop values from the
  4305. <filename>.config</filename> file that override
  4306. required configurations.
  4307. </para></listitem>
  4308. <listitem><para>
  4309. Analyze and potentially remove non-board
  4310. specific options.
  4311. </para></listitem>
  4312. <listitem><para>
  4313. Remove repeated and invalid options.
  4314. </para></listitem>
  4315. </itemizedlist></para></listitem>
  4316. <listitem><para>
  4317. After you have worked through the output of the kernel
  4318. configuration audit, you can re-run the
  4319. <filename>do_configme</filename> and
  4320. <filename>do_kernel_configcheck</filename> tasks to
  4321. see the results of your changes.
  4322. If you have more issues, you can deal with them as
  4323. described in the previous step.
  4324. </para></listitem>
  4325. </orderedlist>
  4326. </para>
  4327. <para>
  4328. Iteratively working through steps two through four eventually yields
  4329. a minimal, streamlined configuration file.
  4330. Once you have the best <filename>.config</filename>, you can build the Linux
  4331. Yocto kernel.
  4332. </para>
  4333. </section>
  4334. </section>
  4335. <section id="patching-the-kernel">
  4336. <title>Patching the Kernel</title>
  4337. <para>
  4338. Patching the kernel involves changing or adding configurations to an existing kernel,
  4339. changing or adding recipes to the kernel that are needed to support specific hardware features,
  4340. or even altering the source code itself.
  4341. <note>
  4342. You can use the <filename>yocto-kernel</filename> script
  4343. found in the <link linkend='source-directory'>Source Directory</link>
  4344. under <filename>scripts</filename> to manage kernel patches and configuration.
  4345. See the "<ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'>Managing kernel Patches and Config Items with yocto-kernel</ulink>"
  4346. section in the Yocto Project Board Support Packages (BSP) Developer's Guide for
  4347. more information.</note>
  4348. </para>
  4349. <para>
  4350. This example creates a simple patch by adding some QEMU emulator console
  4351. output at boot time through <filename>printk</filename> statements in the kernel's
  4352. <filename>calibrate.c</filename> source code file.
  4353. Applying the patch and booting the modified image causes the added
  4354. messages to appear on the emulator's console.
  4355. </para>
  4356. <para>
  4357. The example assumes a clean build exists for the <filename>qemux86</filename>
  4358. machine in a
  4359. <link linkend='source-directory'>Source Directory</link>
  4360. named <filename>poky</filename>.
  4361. Furthermore, the <link linkend='build-directory'>Build Directory</link> is
  4362. <filename>build</filename> and is located in <filename>poky</filename> and
  4363. the kernel is based on the Linux 3.4 kernel.
  4364. For general information on how to configure the most efficient build, see the
  4365. "<ulink url='&YOCTO_DOCS_QS_URL;#building-image'>Building an Image</ulink>" section
  4366. in the Yocto Project Quick Start.
  4367. </para>
  4368. <para>
  4369. Also, for more information on patching the kernel, see the
  4370. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#applying-patches'>Applying Patches</ulink>"
  4371. section in the Yocto Project Linux Kernel Development Manual.
  4372. </para>
  4373. <section id='create-a-layer-for-your-changes'>
  4374. <title>Create a Layer for your Changes</title>
  4375. <para>
  4376. The first step is to create a layer so you can isolate your
  4377. changes.
  4378. Rather than use the <filename>yocto-layer</filename> script
  4379. to create the layer, this example steps through the process
  4380. by hand.
  4381. If you want information on the script that creates a general
  4382. layer, see the
  4383. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  4384. section.
  4385. </para>
  4386. <para>
  4387. These two commands create a directory you can use for your
  4388. layer:
  4389. <literallayout class='monospaced'>
  4390. $ cd ~/poky
  4391. $ mkdir meta-mylayer
  4392. </literallayout>
  4393. Creating a directory that follows the Yocto Project layer naming
  4394. conventions sets up the layer for your changes.
  4395. The layer is where you place your configuration files, append
  4396. files, and patch files.
  4397. To learn more about creating a layer and filling it with the
  4398. files you need, see the "<link linkend='understanding-and-creating-layers'>Understanding
  4399. and Creating Layers</link>" section.
  4400. </para>
  4401. </section>
  4402. <section id='finding-the-kernel-source-code'>
  4403. <title>Finding the Kernel Source Code</title>
  4404. <para>
  4405. Each time you build a kernel image, the kernel source code is fetched
  4406. and unpacked into the following directory:
  4407. <literallayout class='monospaced'>
  4408. ${S}/linux
  4409. </literallayout>
  4410. See the "<link linkend='finding-the-temporary-source-code'>Finding the Temporary Source Code</link>"
  4411. section and the
  4412. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> variable
  4413. for more information about where source is kept during a build.
  4414. </para>
  4415. <para>
  4416. For this example, we are going to patch the
  4417. <filename>init/calibrate.c</filename> file
  4418. by adding some simple console <filename>printk</filename> statements that we can
  4419. see when we boot the image using QEMU.
  4420. </para>
  4421. </section>
  4422. <section id='creating-the-patch'>
  4423. <title>Creating the Patch</title>
  4424. <para>
  4425. Two methods exist by which you can create the patch:
  4426. <link linkend='using-a-git-workflow'>Git workflow</link> and
  4427. <link linkend='using-a-quilt-workflow'>Quilt workflow</link>.
  4428. For kernel patches, the Git workflow is more appropriate.
  4429. This section assumes the Git workflow and shows the steps specific to
  4430. this example.
  4431. <orderedlist>
  4432. <listitem><para><emphasis>Change the working directory</emphasis>:
  4433. Change to where the kernel source code is before making
  4434. your edits to the <filename>calibrate.c</filename> file:
  4435. <literallayout class='monospaced'>
  4436. $ cd ~/poky/build/tmp/work/qemux86-poky-linux/linux-yocto-${PV}-${PR}/linux
  4437. </literallayout>
  4438. Because you are working in an established Git repository,
  4439. you must be in this directory in order to commit your changes
  4440. and create the patch file.
  4441. <note>The <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> and
  4442. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> variables
  4443. represent the version and revision for the
  4444. <filename>linux-yocto</filename> recipe.
  4445. The <filename>PV</filename> variable includes the Git meta and machine
  4446. hashes, which make the directory name longer than you might
  4447. expect.
  4448. </note></para></listitem>
  4449. <listitem><para><emphasis>Edit the source file</emphasis>:
  4450. Edit the <filename>init/calibrate.c</filename> file to have the
  4451. following changes:
  4452. <literallayout class='monospaced'>
  4453. void calibrate_delay(void)
  4454. {
  4455. unsigned long lpj;
  4456. static bool printed;
  4457. int this_cpu = smp_processor_id();
  4458. printk("*************************************\n");
  4459. printk("* *\n");
  4460. printk("* HELLO YOCTO KERNEL *\n");
  4461. printk("* *\n");
  4462. printk("*************************************\n");
  4463. if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
  4464. .
  4465. .
  4466. .
  4467. </literallayout></para></listitem>
  4468. <listitem><para><emphasis>Stage and commit your changes</emphasis>:
  4469. These Git commands display the modified file, stage it, and then
  4470. commit the file:
  4471. <literallayout class='monospaced'>
  4472. $ git status
  4473. $ git add init/calibrate.c
  4474. $ git commit -m "calibrate: Add printk example"
  4475. </literallayout></para></listitem>
  4476. <listitem><para><emphasis>Generate the patch file</emphasis>:
  4477. This Git command creates the a patch file named
  4478. <filename>0001-calibrate-Add-printk-example.patch</filename>
  4479. in the current directory.
  4480. <literallayout class='monospaced'>
  4481. $ git format-patch -1
  4482. </literallayout>
  4483. </para></listitem>
  4484. </orderedlist>
  4485. </para>
  4486. </section>
  4487. <section id='set-up-your-layer-for-the-build'>
  4488. <title>Set Up Your Layer for the Build</title>
  4489. <para>These steps get your layer set up for the build:
  4490. <orderedlist>
  4491. <listitem><para><emphasis>Create additional structure</emphasis>:
  4492. Create the additional layer structure:
  4493. <literallayout class='monospaced'>
  4494. $ cd ~/poky/meta-mylayer
  4495. $ mkdir conf
  4496. $ mkdir recipes-kernel
  4497. $ mkdir recipes-kernel/linux
  4498. $ mkdir recipes-kernel/linux/linux-yocto
  4499. </literallayout>
  4500. The <filename>conf</filename> directory holds your configuration files, while the
  4501. <filename>recipes-kernel</filename> directory holds your append file and
  4502. your patch file.</para></listitem>
  4503. <listitem><para><emphasis>Create the layer configuration file</emphasis>:
  4504. Move to the <filename>meta-mylayer/conf</filename> directory and create
  4505. the <filename>layer.conf</filename> file as follows:
  4506. <literallayout class='monospaced'>
  4507. # We have a conf and classes directory, add to BBPATH
  4508. BBPATH .= ":${LAYERDIR}"
  4509. # We have recipes-* directories, add to BBFILES
  4510. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  4511. ${LAYERDIR}/recipes-*/*/*.bbappend"
  4512. BBFILE_COLLECTIONS += "mylayer"
  4513. BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"
  4514. BBFILE_PRIORITY_mylayer = "5"
  4515. </literallayout>
  4516. Notice <filename>mylayer</filename> as part of the last three
  4517. statements.</para></listitem>
  4518. <listitem><para><emphasis>Create the kernel recipe append file</emphasis>:
  4519. Move to the <filename>meta-mylayer/recipes-kernel/linux</filename> directory and create
  4520. the <filename>linux-yocto_3.4.bbappend</filename> file as follows:
  4521. <literallayout class='monospaced'>
  4522. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  4523. SRC_URI += "file://0001-calibrate-Add-printk-example.patch"
  4524. </literallayout>
  4525. The <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  4526. and <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  4527. statements enable the OpenEmbedded build system to find the patch file.
  4528. For more information on using append files, see the
  4529. "<link linkend='using-bbappend-files'>Using .bbappend Files</link>"
  4530. section.
  4531. </para></listitem>
  4532. <listitem><para><emphasis>Put the patch file in your layer</emphasis>:
  4533. Move the <filename>0001-calibrate-Add-printk-example.patch</filename> file to
  4534. the <filename>meta-mylayer/recipes-kernel/linux/linux-yocto</filename>
  4535. directory.</para></listitem>
  4536. </orderedlist>
  4537. </para>
  4538. </section>
  4539. <section id='set-up-for-the-build'>
  4540. <title>Set Up for the Build</title>
  4541. <para>
  4542. Do the following to make sure the build parameters are set up for the example.
  4543. Once you set up these build parameters, they do not have to change unless you
  4544. change the target architecture of the machine you are building:
  4545. <itemizedlist>
  4546. <listitem><para><emphasis>Build for the correct target architecture:</emphasis> Your
  4547. selected <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4548. definition within the <filename>local.conf</filename> file in the
  4549. <link linkend='build-directory'>Build Directory</link>
  4550. specifies the target architecture used when building the Linux kernel.
  4551. By default, <filename>MACHINE</filename> is set to
  4552. <filename>qemux86</filename>, which specifies a 32-bit
  4553. <trademark class='registered'>Intel</trademark> Architecture
  4554. target machine suitable for the QEMU emulator.</para></listitem>
  4555. <listitem><para><emphasis>Identify your <filename>meta-mylayer</filename>
  4556. layer:</emphasis> The
  4557. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  4558. variable in the
  4559. <filename>bblayers.conf</filename> file found in the
  4560. <filename>poky/build/conf</filename> directory needs to have the path to your local
  4561. <filename>meta-mylayer</filename> layer.
  4562. By default, the <filename>BBLAYERS</filename> variable contains paths to
  4563. <filename>meta</filename>, <filename>meta-yocto</filename>, and
  4564. <filename>meta-yocto-bsp</filename> in the
  4565. <filename>poky</filename> Git repository.
  4566. Add the path to your <filename>meta-mylayer</filename> location:
  4567. <literallayout class='monospaced'>
  4568. BBLAYERS ?= " \
  4569. $HOME/poky/meta \
  4570. $HOME/poky/meta-yocto \
  4571. $HOME/poky/meta-yocto-bsp \
  4572. $HOME/poky/meta-mylayer \
  4573. "
  4574. BBLAYERS_NON_REMOVABLE ?= " \
  4575. $HOME/poky/meta \
  4576. $HOME/poky/meta-yocto \
  4577. "
  4578. </literallayout></para></listitem>
  4579. </itemizedlist>
  4580. </para>
  4581. </section>
  4582. <section id='build-the-modified-qemu-kernel-image'>
  4583. <title>Build the Modified QEMU Kernel Image</title>
  4584. <para>
  4585. The following steps build your modified kernel image:
  4586. <orderedlist>
  4587. <listitem><para><emphasis>Be sure your build environment is initialized</emphasis>:
  4588. Your environment should be set up since you previously sourced
  4589. the
  4590. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  4591. script.
  4592. If it is not, source the script again from <filename>poky</filename>.
  4593. <literallayout class='monospaced'>
  4594. $ cd ~/poky
  4595. $ source &OE_INIT_FILE;
  4596. </literallayout>
  4597. </para></listitem>
  4598. <listitem><para><emphasis>Clean up</emphasis>:
  4599. Be sure to clean the shared state out by using BitBake
  4600. to run from within the Build Directory the
  4601. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>
  4602. task as follows:
  4603. <literallayout class='monospaced'>
  4604. $ bitbake -c cleansstate linux-yocto
  4605. </literallayout></para>
  4606. <para>
  4607. <note>
  4608. Never remove any files by hand from the
  4609. <filename>tmp/deploy</filename>
  4610. directory inside the
  4611. <link linkend='build-directory'>Build Directory</link>.
  4612. Always use the various BitBake clean tasks to
  4613. clear out previous build artifacts.
  4614. For information on the clean tasks, see the
  4615. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>",
  4616. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>",
  4617. and
  4618. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>"
  4619. sections all in the Yocto Project Reference
  4620. Manual.
  4621. </note>
  4622. </para></listitem>
  4623. <listitem><para><emphasis>Build the image</emphasis>:
  4624. Next, build the kernel image using this command:
  4625. <literallayout class='monospaced'>
  4626. $ bitbake -k linux-yocto
  4627. </literallayout></para></listitem>
  4628. </orderedlist>
  4629. </para>
  4630. </section>
  4631. <section id='boot-the-image-and-verify-your-changes'>
  4632. <title>Boot the Image and Verify Your Changes</title>
  4633. <para>
  4634. These steps boot the image and allow you to see the changes
  4635. <orderedlist>
  4636. <listitem><para><emphasis>Boot the image</emphasis>:
  4637. Boot the modified image in the QEMU emulator
  4638. using this command:
  4639. <literallayout class='monospaced'>
  4640. $ runqemu qemux86
  4641. </literallayout></para></listitem>
  4642. <listitem><para><emphasis>Verify the changes</emphasis>:
  4643. Log into the machine using <filename>root</filename> with no password and then
  4644. use the following shell command to scroll through the console's boot output.
  4645. <literallayout class='monospaced'>
  4646. # dmesg | less
  4647. </literallayout>
  4648. You should see the results of your <filename>printk</filename> statements
  4649. as part of the output.</para></listitem>
  4650. </orderedlist>
  4651. </para>
  4652. </section>
  4653. </section>
  4654. <section id='making-images-more-secure'>
  4655. <title>Making Images More Secure</title>
  4656. <para>
  4657. Security is of increasing concern for embedded devices.
  4658. Consider the issues and problems discussed in just this
  4659. sampling of work found across the Internet:
  4660. <itemizedlist>
  4661. <listitem><para><emphasis>
  4662. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  4663. by Bruce Schneier
  4664. </para></listitem>
  4665. <listitem><para><emphasis>
  4666. "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis>
  4667. by Carna Botnet</para></listitem>
  4668. <listitem><para><emphasis>
  4669. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  4670. by Jake Edge
  4671. </para></listitem>
  4672. <listitem><para><emphasis>
  4673. "<ulink url='https://www.nccgroup.com/media/18475/exploiting_security_gateways_via_their_web_interfaces.pdf'>They ought to know better: Exploiting Security
  4674. Gateways via their Web Interfaces</ulink>"</emphasis>
  4675. by Ben Williams
  4676. </para></listitem>
  4677. </itemizedlist>
  4678. </para>
  4679. <para>
  4680. When securing your image is of concern, there are steps, tools,
  4681. and variables that you can consider to help you reach the
  4682. security goals you need for your particular device.
  4683. Not all situations are identical when it comes to making an
  4684. image secure.
  4685. Consequently, this section provides some guidance and suggestions
  4686. for consideration when you want to make your image more secure.
  4687. <note>
  4688. Because the security requirements and risks are
  4689. different for every type of device, this section cannot
  4690. provide a complete reference on securing your custom OS.
  4691. It is strongly recommended that you also consult other sources
  4692. of information on embedded Linux system hardening and on
  4693. security.
  4694. </note>
  4695. </para>
  4696. <section id='general-considerations'>
  4697. <title>General Considerations</title>
  4698. <para>
  4699. General considerations exist that help you create more
  4700. secure images.
  4701. You should consider the following suggestions to help
  4702. make your device more secure:
  4703. <itemizedlist>
  4704. <listitem><para>
  4705. Scan additional code you are adding to the system
  4706. (e.g. application code) by using static analysis
  4707. tools.
  4708. Look for buffer overflows and other potential
  4709. security problems.
  4710. </para></listitem>
  4711. <listitem><para>
  4712. Pay particular attention to the security for
  4713. any web-based administration interface.
  4714. </para>
  4715. <para>Web interfaces typically need to perform
  4716. administrative functions and tend to need to run with
  4717. elevated privileges.
  4718. Thus, the consequences resulting from the interface's
  4719. security becoming compromised can be serious.
  4720. Look for common web vulnerabilities such as
  4721. cross-site-scripting (XSS), unvalidated inputs,
  4722. and so forth.</para>
  4723. <para>As with system passwords, the default credentials
  4724. for accessing a web-based interface should not be the
  4725. same across all devices.
  4726. This is particularly true if the interface is enabled
  4727. by default as it can be assumed that many end-users
  4728. will not change the credentials.
  4729. </para></listitem>
  4730. <listitem><para>
  4731. Ensure you can update the software on the device to
  4732. mitigate vulnerabilities discovered in the future.
  4733. This consideration especially applies when your
  4734. device is network-enabled.
  4735. </para></listitem>
  4736. <listitem><para>
  4737. Ensure you remove or disable debugging functionality
  4738. before producing the final image.
  4739. For information on how to do this, see the
  4740. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  4741. section.
  4742. </para></listitem>
  4743. <listitem><para>
  4744. Ensure you have no network services listening that
  4745. are not needed.
  4746. </para></listitem>
  4747. <listitem><para>
  4748. Remove any software from the image that is not needed.
  4749. </para></listitem>
  4750. <listitem><para>
  4751. Enable hardware support for secure boot functionality
  4752. when your device supports this functionality.
  4753. </para></listitem>
  4754. </itemizedlist>
  4755. </para>
  4756. </section>
  4757. <section id='security-flags'>
  4758. <title>Security Flags</title>
  4759. <para>
  4760. The Yocto Project has security flags that you can enable that
  4761. help make your build output more secure.
  4762. The security flags are in the
  4763. <filename>meta/conf/distro/include/security_flags.inc</filename>
  4764. file in your
  4765. <link linkend='source-directory'>Source Directory</link>
  4766. (e.g. <filename>poky</filename>).
  4767. <note>
  4768. Depending on the recipe, certain security flags are enabled
  4769. and disabled by default.
  4770. </note>
  4771. </para>
  4772. <para>
  4773. <!--
  4774. The GCC/LD flags in <filename>security_flags.inc</filename>
  4775. enable more secure code generation.
  4776. By including the <filename>security_flags.inc</filename>
  4777. file, you enable flags to the compiler and linker that cause
  4778. them to generate more secure code.
  4779. <note>
  4780. The GCC/LD flags are enabled by default in the
  4781. <filename>poky-lsb</filename> distribution.
  4782. </note>
  4783. -->
  4784. Use the following line in your
  4785. <filename>local.conf</filename> file or in your custom
  4786. distribution configuration file to enable the security
  4787. compiler and linker flags for your build:
  4788. <literallayout class='monospaced'>
  4789. require conf/distro/include/security_flags.inc
  4790. </literallayout>
  4791. </para>
  4792. </section>
  4793. <section id='considerations-specific-to-the-openembedded-build-system'>
  4794. <title>Considerations Specific to the OpenEmbedded Build System</title>
  4795. <para>
  4796. You can take some steps that are specific to the
  4797. OpenEmbedded build system to make your images more secure:
  4798. <itemizedlist>
  4799. <listitem><para>
  4800. Ensure "debug-tweaks" is not one of your selected
  4801. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  4802. When creating a new project, the default is to provide you
  4803. with an initial <filename>local.conf</filename> file that
  4804. enables this feature using the
  4805. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  4806. <literallayout class='monospaced'>
  4807. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  4808. </literallayout>
  4809. To disable that feature, simply comment out that line in your
  4810. <filename>local.conf</filename> file, or
  4811. make sure <filename>IMAGE_FEATURES</filename> does not contain
  4812. "debug-tweaks" before producing your final image.
  4813. Among other things, leaving this in place sets the
  4814. root password as blank, which makes logging in for
  4815. debugging or inspection easy during
  4816. development but also means anyone can easily log in
  4817. during production.
  4818. </para></listitem>
  4819. <listitem><para>
  4820. It is possible to set a root password for the image
  4821. and also to set passwords for any extra users you might
  4822. add (e.g. administrative or service type users).
  4823. When you set up passwords for multiple images or
  4824. users, you should not duplicate passwords.
  4825. </para>
  4826. <para>
  4827. To set up passwords, use the
  4828. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  4829. class, which is the preferred method.
  4830. For an example on how to set up both root and user
  4831. passwords, see the
  4832. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  4833. section.
  4834. <note>
  4835. When adding extra user accounts or setting a
  4836. root password, be cautious about setting the
  4837. same password on every device.
  4838. If you do this, and the password you have set
  4839. is exposed, then every device is now potentially
  4840. compromised.
  4841. If you need this access but want to ensure
  4842. security, consider setting a different,
  4843. random password for each device.
  4844. Typically, you do this as a separate step after
  4845. you deploy the image onto the device.
  4846. </note>
  4847. </para></listitem>
  4848. <listitem><para>
  4849. Consider enabling a Mandatory Access Control (MAC)
  4850. framework such as SMACK or SELinux and tuning it
  4851. appropriately for your device's usage.
  4852. </para></listitem>
  4853. </itemizedlist>
  4854. </para>
  4855. <para>
  4856. </para>
  4857. </section>
  4858. <section id='tools-for-hardening-your-image'>
  4859. <title>Tools for Hardening Your Image</title>
  4860. <para>
  4861. The Yocto Project provides tools for making your image
  4862. more secure.
  4863. You can find these tools in the
  4864. <filename>meta-security</filename> layer of the
  4865. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
  4866. </para>
  4867. </section>
  4868. </section>
  4869. <section id='creating-your-own-distribution'>
  4870. <title>Creating Your Own Distribution</title>
  4871. <para>
  4872. When you build an image using the Yocto Project and
  4873. do not alter any distribution
  4874. <link linkend='metadata'>Metadata</link>, you are creating a
  4875. Poky distribution.
  4876. If you wish to gain more control over package alternative
  4877. selections, compile-time options, and other low-level
  4878. configurations, you can create your own distribution.
  4879. </para>
  4880. <para>
  4881. To create your own distribution, the basic steps consist of
  4882. creating your own distribution layer, creating your own
  4883. distribution configuration file, and then adding any needed
  4884. code and Metadata to the layer.
  4885. The following steps provide some more detail:
  4886. <itemizedlist>
  4887. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  4888. Create your distribution layer so that you can keep your
  4889. Metadata and code for the distribution separate.
  4890. It is strongly recommended that you create and use your own
  4891. layer for configuration and code.
  4892. Using your own layer as compared to just placing
  4893. configurations in a <filename>local.conf</filename>
  4894. configuration file makes it easier to reproduce the same
  4895. build configuration when using multiple build machines.
  4896. See the
  4897. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  4898. section for information on how to quickly set up a layer.
  4899. </para></listitem>
  4900. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  4901. The distribution configuration file needs to be created in
  4902. the <filename>conf/distro</filename> directory of your
  4903. layer.
  4904. You need to name it using your distribution name
  4905. (e.g. <filename>mydistro.conf</filename>).
  4906. <note>
  4907. The
  4908. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  4909. variable in your
  4910. <filename>local.conf</filename> file determines the
  4911. name of your distribution.
  4912. </note></para>
  4913. <para>You can split out parts of your configuration file
  4914. into include files and then "require" them from within
  4915. your distribution configuration file.
  4916. Be sure to place the include files in the
  4917. <filename>conf/distro/include</filename> directory of
  4918. your layer.
  4919. A common example usage of include files would be to
  4920. separate out the selection of desired version and revisions
  4921. for individual recipes.
  4922. </para>
  4923. <para>Your configuration file needs to set the following
  4924. required variables:
  4925. <literallayout class='monospaced'>
  4926. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  4927. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  4928. </literallayout>
  4929. These following variables are optional and you typically
  4930. set them from the distribution configuration file:
  4931. <literallayout class='monospaced'>
  4932. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  4933. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  4934. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  4935. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  4936. </literallayout>
  4937. <tip>
  4938. If you want to base your distribution configuration file
  4939. on the very basic configuration from OE-Core, you
  4940. can use
  4941. <filename>conf/distro/defaultsetup.conf</filename> as
  4942. a reference and just include variables that differ
  4943. as compared to <filename>defaultsetup.conf</filename>.
  4944. Alternatively, you can create a distribution
  4945. configuration file from scratch using the
  4946. <filename>defaultsetup.conf</filename> file
  4947. or configuration files from other distributions
  4948. such as Poky or Angstrom as references.
  4949. </tip></para></listitem>
  4950. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  4951. Be sure to define any other variables for which you want to
  4952. create a default or enforce as part of the distribution
  4953. configuration.
  4954. You can include nearly any variable from the
  4955. <filename>local.conf</filename> file.
  4956. The variables you use are not limited to the list in the
  4957. previous bulleted item.</para></listitem>
  4958. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  4959. In your <filename>local.conf</filename> file in the
  4960. <link linkend='build-directory'>Build Directory</link>,
  4961. set your
  4962. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  4963. variable to point to your distribution's configuration file.
  4964. For example, if your distribution's configuration file is
  4965. named <filename>mydistro.conf</filename>, then you point
  4966. to it as follows:
  4967. <literallayout class='monospaced'>
  4968. DISTRO = "mydistro"
  4969. </literallayout></para></listitem>
  4970. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  4971. Use your layer to hold other information needed for the
  4972. distribution:
  4973. <itemizedlist>
  4974. <listitem><para>Add recipes for installing
  4975. distro-specific configuration files that are not
  4976. already installed by another recipe.
  4977. If you have distro-specific configuration files
  4978. that are included by an existing recipe, you should
  4979. add an append file (<filename>.bbappend</filename>)
  4980. for those.
  4981. For general information and recommendations
  4982. on how to add recipes to your layer, see the
  4983. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  4984. and
  4985. "<link linkend='best-practices-to-follow-when-creating-layers'>Best Practices to Follow When Creating Layers</link>"
  4986. sections.</para></listitem>
  4987. <listitem><para>Add any image recipes that are specific
  4988. to your distribution.</para></listitem>
  4989. <listitem><para>Add a <filename>psplash</filename>
  4990. append file for a branded splash screen.
  4991. For information on append files, see the
  4992. "<link linkend='using-bbappend-files'>Using .bbappend Files</link>"
  4993. section.</para></listitem>
  4994. <listitem><para>Add any other append files to make
  4995. custom changes that are specific to individual
  4996. recipes.</para></listitem>
  4997. </itemizedlist></para></listitem>
  4998. </itemizedlist>
  4999. </para>
  5000. </section>
  5001. <section id='creating-a-custom-template-configuration-directory'>
  5002. <title>Creating a Custom Template Configuration Directory</title>
  5003. <para>
  5004. If you are producing your own customized version
  5005. of the build system for use by other users, you might
  5006. want to customize the message shown by the setup script or
  5007. you might want to change the template configuration files (i.e.
  5008. <filename>local.conf</filename> and
  5009. <filename>bblayers.conf</filename>) that are created in
  5010. a new build directory.
  5011. </para>
  5012. <para>
  5013. The OpenEmbedded build system uses the environment variable
  5014. <filename>TEMPLATECONF</filename> to locate the directory
  5015. from which it gathers configuration information that ultimately
  5016. ends up in the
  5017. <link linkend='build-directory'>Build Directory's</link>
  5018. <filename>conf</filename> directory.
  5019. By default, <filename>TEMPLATECONF</filename> is set as
  5020. follows in the <filename>poky</filename> repository:
  5021. <literallayout class='monospaced'>
  5022. TEMPLATECONF=${TEMPLATECONF:-meta-yocto/conf}
  5023. </literallayout>
  5024. This is the directory used by the build system to find templates
  5025. from which to build some key configuration files.
  5026. If you look at this directory, you will see the
  5027. <filename>bblayers.conf.sample</filename>,
  5028. <filename>local.conf.sample</filename>, and
  5029. <filename>conf-notes.txt</filename> files.
  5030. The build system uses these files to form the respective
  5031. <filename>bblayers.conf</filename> file,
  5032. <filename>local.conf</filename> file, and display the list of
  5033. BitBake targets when running the setup script.
  5034. </para>
  5035. <para>
  5036. To override these default configuration files with
  5037. configurations you want used within every new
  5038. Build Directory, simply set the
  5039. <filename>TEMPLATECONF</filename> variable to your directory.
  5040. The <filename>TEMPLATECONF</filename> variable is set in the
  5041. <filename>.templateconf</filename> file, which is in the
  5042. top-level
  5043. <link linkend='source-directory'>Source Directory</link>
  5044. folder (e.g. <filename>poky</filename>).
  5045. Edit the <filename>.templateconf</filename> so that it can locate
  5046. your directory.
  5047. </para>
  5048. <para>
  5049. Best practices dictate that you should keep your
  5050. template configuration directory in your custom distribution layer.
  5051. For example, suppose you have a layer named
  5052. <filename>meta-mylayer</filename> located in your home directory
  5053. and you want your template configuration directory named
  5054. <filename>myconf</filename>.
  5055. Changing the <filename>.templateconf</filename> as follows
  5056. causes the OpenEmbedded build system to look in your directory
  5057. and base its configuration files on the
  5058. <filename>*.sample</filename> configuration files it finds.
  5059. The final configuration files (i.e.
  5060. <filename>local.conf</filename> and
  5061. <filename>bblayers.conf</filename> ultimately still end up in
  5062. your Build Directory, but they are based on your
  5063. <filename>*.sample</filename> files.
  5064. <literallayout class='monospaced'>
  5065. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  5066. </literallayout>
  5067. </para>
  5068. <para>
  5069. Aside from the <filename>*.sample</filename> configuration files,
  5070. the <filename>conf-notes.txt</filename> also resides in the
  5071. default <filename>meta-yocto/conf</filename> directory.
  5072. The scripts that set up the build environment
  5073. (i.e.
  5074. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>
  5075. and
  5076. <ulink url="&YOCTO_DOCS_REF_URL;#structure-memres-core-script"><filename>oe-init-build-env-memres</filename></ulink>)
  5077. use this file to display BitBake targets as part of the script
  5078. output.
  5079. Customizing this <filename>conf-notes.txt</filename> file is a
  5080. good way to make sure your list of custom targets appears
  5081. as part of the script's output.
  5082. </para>
  5083. <para>
  5084. Here is the default list of targets displayed as a result of
  5085. running either of the setup scripts:
  5086. <literallayout class='monospaced'>
  5087. You can now run 'bitbake &lt;target&gt;'
  5088. Common targets are:
  5089. core-image-minimal
  5090. core-image-sato
  5091. meta-toolchain
  5092. adt-installer
  5093. meta-ide-support
  5094. </literallayout>
  5095. </para>
  5096. <para>
  5097. Changing the listed common targets is as easy as editing your
  5098. version of <filename>conf-notes.txt</filename> in your
  5099. custom template configuration directory and making sure you
  5100. have <filename>TEMPLATECONF</filename> set to your directory.
  5101. </para>
  5102. </section>
  5103. <section id='building-a-tiny-system'>
  5104. <title>Building a Tiny System</title>
  5105. <para>
  5106. Very small distributions have some significant advantages such
  5107. as requiring less on-die or in-package memory (cheaper), better
  5108. performance through efficient cache usage, lower power requirements
  5109. due to less memory, faster boot times, and reduced development
  5110. overhead.
  5111. Some real-world examples where a very small distribution gives
  5112. you distinct advantages are digital cameras, medical devices,
  5113. and small headless systems.
  5114. </para>
  5115. <para>
  5116. This section presents information that shows you how you can
  5117. trim your distribution to even smaller sizes than the
  5118. <filename>poky-tiny</filename> distribution, which is around
  5119. 5 Mbytes, that can be built out-of-the-box using the Yocto Project.
  5120. </para>
  5121. <section id='tiny-system-overview'>
  5122. <title>Overview</title>
  5123. <para>
  5124. The following list presents the overall steps you need to
  5125. consider and perform to create distributions with smaller
  5126. root filesystems, achieve faster boot times, maintain your critical
  5127. functionality, and avoid initial RAM disks:
  5128. <itemizedlist>
  5129. <listitem><para>
  5130. <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link>
  5131. </para></listitem>
  5132. <listitem><para>
  5133. <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link>
  5134. </para></listitem>
  5135. <listitem><para>
  5136. <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link>
  5137. </para></listitem>
  5138. <listitem><para>
  5139. <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link>
  5140. </para></listitem>
  5141. <listitem><para>
  5142. <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link>
  5143. </para></listitem>
  5144. <listitem><para>
  5145. <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link>
  5146. </para></listitem>
  5147. <listitem><para>
  5148. <link linkend='iterate-on-the-process'>Iterate on the process.</link>
  5149. </para></listitem>
  5150. </itemizedlist>
  5151. </para>
  5152. </section>
  5153. <section id='goals-and-guiding-principles'>
  5154. <title>Goals and Guiding Principles</title>
  5155. <para>
  5156. Before you can reach your destination, you need to know
  5157. where you are going.
  5158. Here is an example list that you can use as a guide when
  5159. creating very small distributions:
  5160. <itemizedlist>
  5161. <listitem><para>Determine how much space you need
  5162. (e.g. a kernel that is 1 Mbyte or less and
  5163. a root filesystem that is 3 Mbytes or less).
  5164. </para></listitem>
  5165. <listitem><para>Find the areas that are currently
  5166. taking 90% of the space and concentrate on reducing
  5167. those areas.
  5168. </para></listitem>
  5169. <listitem><para>Do not create any difficult "hacks"
  5170. to achieve your goals.</para></listitem>
  5171. <listitem><para>Leverage the device-specific
  5172. options.</para></listitem>
  5173. <listitem><para>Work in a separate layer so that you
  5174. keep changes isolated.
  5175. For information on how to create layers, see
  5176. the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section.
  5177. </para></listitem>
  5178. </itemizedlist>
  5179. </para>
  5180. </section>
  5181. <section id='understand-what-gives-your-image-size'>
  5182. <title>Understand What Contributes to Your Image Size</title>
  5183. <para>
  5184. It is easiest to have something to start with when creating
  5185. your own distribution.
  5186. You can use the Yocto Project out-of-the-box to create the
  5187. <filename>poky-tiny</filename> distribution.
  5188. Ultimately, you will want to make changes in your own
  5189. distribution that are likely modeled after
  5190. <filename>poky-tiny</filename>.
  5191. <note>
  5192. To use <filename>poky-tiny</filename> in your build,
  5193. set the
  5194. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5195. variable in your
  5196. <filename>local.conf</filename> file to "poky-tiny"
  5197. as described in the
  5198. "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  5199. section.
  5200. </note>
  5201. </para>
  5202. <para>
  5203. Understanding some memory concepts will help you reduce the
  5204. system size.
  5205. Memory consists of static, dynamic, and temporary memory.
  5206. Static memory is the TEXT (code), DATA (initialized data
  5207. in the code), and BSS (uninitialized data) sections.
  5208. Dynamic memory represents memory that is allocated at runtime:
  5209. stacks, hash tables, and so forth.
  5210. Temporary memory is recovered after the boot process.
  5211. This memory consists of memory used for decompressing
  5212. the kernel and for the <filename>__init__</filename>
  5213. functions.
  5214. </para>
  5215. <para>
  5216. To help you see where you currently are with kernel and root
  5217. filesystem sizes, you can use two tools found in the
  5218. <link linkend='source-directory'>Source Directory</link> in
  5219. the <filename>scripts/tiny/</filename> directory:
  5220. <itemizedlist>
  5221. <listitem><para><filename>ksize.py</filename>: Reports
  5222. component sizes for the kernel build objects.
  5223. </para></listitem>
  5224. <listitem><para><filename>dirsize.py</filename>: Reports
  5225. component sizes for the root filesystem.</para></listitem>
  5226. </itemizedlist>
  5227. This next tool and command help you organize configuration
  5228. fragments and view file dependencies in a human-readable form:
  5229. <itemizedlist>
  5230. <listitem><para><filename>merge_config.sh</filename>:
  5231. Helps you manage configuration files and fragments
  5232. within the kernel.
  5233. With this tool, you can merge individual configuration
  5234. fragments together.
  5235. The tool allows you to make overrides and warns you
  5236. of any missing configuration options.
  5237. The tool is ideal for allowing you to iterate on
  5238. configurations, create minimal configurations, and
  5239. create configuration files for different machines
  5240. without having to duplicate your process.</para>
  5241. <para>The <filename>merge_config.sh</filename> script is
  5242. part of the Linux Yocto kernel Git repositories
  5243. (i.e. <filename>linux-yocto-3.14</filename>,
  5244. <filename>linux-yocto-3.10</filename>,
  5245. <filename>linux-yocto-3.8</filename>, and so forth)
  5246. in the
  5247. <filename>scripts/kconfig</filename> directory.</para>
  5248. <para>For more information on configuration fragments,
  5249. see the
  5250. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>"
  5251. section of the Yocto Project Linux Kernel Development
  5252. Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>"
  5253. section, which is in this manual.</para></listitem>
  5254. <listitem><para><filename>bitbake -u depexp -g <replaceable>bitbake_target</replaceable></filename>:
  5255. Using the BitBake command with these options brings up
  5256. a Dependency Explorer from which you can view file
  5257. dependencies.
  5258. Understanding these dependencies allows you to make
  5259. informed decisions when cutting out various pieces of the
  5260. kernel and root filesystem.</para></listitem>
  5261. </itemizedlist>
  5262. </para>
  5263. </section>
  5264. <section id='trim-the-root-filesystem'>
  5265. <title>Trim the Root Filesystem</title>
  5266. <para>
  5267. The root filesystem is made up of packages for booting,
  5268. libraries, and applications.
  5269. To change things, you can configure how the packaging happens,
  5270. which changes the way you build them.
  5271. You can also modify the filesystem itself or select a different
  5272. filesystem.
  5273. </para>
  5274. <para>
  5275. First, find out what is hogging your root filesystem by running the
  5276. <filename>dirsize.py</filename> script from your root directory:
  5277. <literallayout class='monospaced'>
  5278. $ cd <replaceable>root-directory-of-image</replaceable>
  5279. $ dirsize.py 100000 > dirsize-100k.log
  5280. $ cat dirsize-100k.log
  5281. </literallayout>
  5282. You can apply a filter to the script to ignore files under
  5283. a certain size.
  5284. The previous example filters out any files below 100 Kbytes.
  5285. The sizes reported by the tool are uncompressed, and thus
  5286. will be smaller by a relatively constant factor in a
  5287. compressed root filesystem.
  5288. When you examine your log file, you can focus on areas of the
  5289. root filesystem that take up large amounts of memory.
  5290. </para>
  5291. <para>
  5292. You need to be sure that what you eliminate does not cripple
  5293. the functionality you need.
  5294. One way to see how packages relate to each other is by using
  5295. the Dependency Explorer UI with the BitBake command:
  5296. <literallayout class='monospaced'>
  5297. $ cd <replaceable>image-directory</replaceable>
  5298. $ bitbake -u depexp -g <replaceable>image</replaceable>
  5299. </literallayout>
  5300. Use the interface to select potential packages you wish to
  5301. eliminate and see their dependency relationships.
  5302. </para>
  5303. <para>
  5304. When deciding how to reduce the size, get rid of packages that
  5305. result in minimal impact on the feature set.
  5306. For example, you might not need a VGA display.
  5307. Or, you might be able to get by with <filename>devtmpfs</filename>
  5308. and <filename>mdev</filename> instead of
  5309. <filename>udev</filename>.
  5310. </para>
  5311. <para>
  5312. Use your <filename>local.conf</filename> file to make changes.
  5313. For example, to eliminate <filename>udev</filename> and
  5314. <filename>glib</filename>, set the following in the
  5315. local configuration file:
  5316. <literallayout class='monospaced'>
  5317. VIRTUAL-RUNTIME_dev_manager = ""
  5318. </literallayout>
  5319. </para>
  5320. <para>
  5321. Finally, you should consider exactly the type of root
  5322. filesystem you need to meet your needs while also reducing
  5323. its size.
  5324. For example, consider <filename>cramfs</filename>,
  5325. <filename>squashfs</filename>, <filename>ubifs</filename>,
  5326. <filename>ext2</filename>, or an <filename>initramfs</filename>
  5327. using <filename>initramfs</filename>.
  5328. Be aware that <filename>ext3</filename> requires a 1 Mbyte
  5329. journal.
  5330. If you are okay with running read-only, you do not need this
  5331. journal.
  5332. </para>
  5333. <note>
  5334. After each round of elimination, you need to rebuild your
  5335. system and then use the tools to see the effects of your
  5336. reductions.
  5337. </note>
  5338. </section>
  5339. <section id='trim-the-kernel'>
  5340. <title>Trim the Kernel</title>
  5341. <para>
  5342. The kernel is built by including policies for hardware-independent
  5343. aspects.
  5344. What subsystems do you enable?
  5345. For what architecture are you building?
  5346. Which drivers do you build by default?
  5347. <note>You can modify the kernel source if you want to help
  5348. with boot time.
  5349. </note>
  5350. </para>
  5351. <para>
  5352. Run the <filename>ksize.py</filename> script from the top-level
  5353. Linux build directory to get an idea of what is making up
  5354. the kernel:
  5355. <literallayout class='monospaced'>
  5356. $ cd <replaceable>top-level-linux-build-directory</replaceable>
  5357. $ ksize.py > ksize.log
  5358. $ cat ksize.log
  5359. </literallayout>
  5360. When you examine the log, you will see how much space is
  5361. taken up with the built-in <filename>.o</filename> files for
  5362. drivers, networking, core kernel files, filesystem, sound,
  5363. and so forth.
  5364. The sizes reported by the tool are uncompressed, and thus
  5365. will be smaller by a relatively constant factor in a compressed
  5366. kernel image.
  5367. Look to reduce the areas that are large and taking up around
  5368. the "90% rule."
  5369. </para>
  5370. <para>
  5371. To examine, or drill down, into any particular area, use the
  5372. <filename>-d</filename> option with the script:
  5373. <literallayout class='monospaced'>
  5374. $ ksize.py -d > ksize.log
  5375. </literallayout>
  5376. Using this option breaks out the individual file information
  5377. for each area of the kernel (e.g. drivers, networking, and
  5378. so forth).
  5379. </para>
  5380. <para>
  5381. Use your log file to see what you can eliminate from the kernel
  5382. based on features you can let go.
  5383. For example, if you are not going to need sound, you do not
  5384. need any drivers that support sound.
  5385. </para>
  5386. <para>
  5387. After figuring out what to eliminate, you need to reconfigure
  5388. the kernel to reflect those changes during the next build.
  5389. You could run <filename>menuconfig</filename> and make all your
  5390. changes at once.
  5391. However, that makes it difficult to see the effects of your
  5392. individual eliminations and also makes it difficult to replicate
  5393. the changes for perhaps another target device.
  5394. A better method is to start with no configurations using
  5395. <filename>allnoconfig</filename>, create configuration
  5396. fragments for individual changes, and then manage the
  5397. fragments into a single configuration file using
  5398. <filename>merge_config.sh</filename>.
  5399. The tool makes it easy for you to iterate using the
  5400. configuration change and build cycle.
  5401. </para>
  5402. <para>
  5403. Each time you make configuration changes, you need to rebuild
  5404. the kernel and check to see what impact your changes had on
  5405. the overall size.
  5406. </para>
  5407. </section>
  5408. <section id='remove-package-management-requirements'>
  5409. <title>Remove Package Management Requirements</title>
  5410. <para>
  5411. Packaging requirements add size to the image.
  5412. One way to reduce the size of the image is to remove all the
  5413. packaging requirements from the image.
  5414. This reduction includes both removing the package manager
  5415. and its unique dependencies as well as removing the package
  5416. management data itself.
  5417. </para>
  5418. <para>
  5419. To eliminate all the packaging requirements for an image,
  5420. be sure that "package-management" is not part of your
  5421. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  5422. statement for the image.
  5423. When you remove this feature, you are removing the package
  5424. manager as well as its dependencies from the root filesystem.
  5425. </para>
  5426. </section>
  5427. <section id='look-for-other-ways-to-minimize-size'>
  5428. <title>Look for Other Ways to Minimize Size</title>
  5429. <para>
  5430. Depending on your particular circumstances, other areas that you
  5431. can trim likely exist.
  5432. The key to finding these areas is through tools and methods
  5433. described here combined with experimentation and iteration.
  5434. Here are a couple of areas to experiment with:
  5435. <itemizedlist>
  5436. <listitem><para><filename>eglibc</filename>:
  5437. In general, follow this process:
  5438. <orderedlist>
  5439. <listitem><para>Remove <filename>eglibc</filename>
  5440. features from
  5441. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  5442. that you think you do not need.</para></listitem>
  5443. <listitem><para>Build your distribution.
  5444. </para></listitem>
  5445. <listitem><para>If the build fails due to missing
  5446. symbols in a package, determine if you can
  5447. reconfigure the package to not need those
  5448. features.
  5449. For example, change the configuration to not
  5450. support wide character support as is done for
  5451. <filename>ncurses</filename>.
  5452. Or, if support for those characters is needed,
  5453. determine what <filename>eglibc</filename>
  5454. features provide the support and restore the
  5455. configuration.
  5456. </para></listitem>
  5457. <listitem><para>Rebuild and repeat the process.
  5458. </para></listitem>
  5459. </orderedlist></para></listitem>
  5460. <listitem><para><filename>busybox</filename>:
  5461. For BusyBox, use a process similar as described for
  5462. <filename>eglibc</filename>.
  5463. A difference is you will need to boot the resulting
  5464. system to see if you are able to do everything you
  5465. expect from the running system.
  5466. You need to be sure to integrate configuration fragments
  5467. into Busybox because BusyBox handles its own core
  5468. features and then allows you to add configuration
  5469. fragments on top.
  5470. </para></listitem>
  5471. </itemizedlist>
  5472. </para>
  5473. </section>
  5474. <section id='iterate-on-the-process'>
  5475. <title>Iterate on the Process</title>
  5476. <para>
  5477. If you have not reached your goals on system size, you need
  5478. to iterate on the process.
  5479. The process is the same.
  5480. Use the tools and see just what is taking up 90% of the root
  5481. filesystem and the kernel.
  5482. Decide what you can eliminate without limiting your device
  5483. beyond what you need.
  5484. </para>
  5485. <para>
  5486. Depending on your system, a good place to look might be
  5487. Busybox, which provides a stripped down
  5488. version of Unix tools in a single, executable file.
  5489. You might be able to drop virtual terminal services or perhaps
  5490. ipv6.
  5491. </para>
  5492. </section>
  5493. </section>
  5494. <section id='working-with-packages'>
  5495. <title>Working with Packages</title>
  5496. <para>
  5497. This section describes a few tasks that involve packages:
  5498. <itemizedlist>
  5499. <listitem><para>
  5500. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  5501. </para></listitem>
  5502. <listitem><para>
  5503. <link linkend='incrementing-a-package-revision-number'>Incrementing a package revision number</link>
  5504. </para></listitem>
  5505. <listitem><para>
  5506. <link linkend='usingpoky-configuring-DISTRO_PN_ALIAS'>Handling a package name alias</link>
  5507. </para></listitem>
  5508. <listitem><para>
  5509. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  5510. </para></listitem>
  5511. <listitem><para>
  5512. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  5513. </para></listitem>
  5514. <listitem><para>
  5515. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  5516. </para></listitem>
  5517. </itemizedlist>
  5518. </para>
  5519. <section id='excluding-packages-from-an-image'>
  5520. <title>Excluding Packages from an Image</title>
  5521. <para>
  5522. You might find it necessary to prevent specific packages
  5523. from being installed into an image.
  5524. If so, you can use several variables to direct the build
  5525. system to essentially ignore installing recommended packages
  5526. or to not install a package at all.
  5527. </para>
  5528. <para>
  5529. The following list introduces variables you can use to
  5530. prevent packages from being installed into your image.
  5531. Each of these variables only works with IPK and RPM
  5532. package types.
  5533. Support for Debian packages does not exist.
  5534. Also, you can use these variables from your
  5535. <filename>local.conf</filename> file or attach them to a
  5536. specific image recipe by using a recipe name override.
  5537. For more detail on the variables, see the descriptions in the
  5538. Yocto Project Reference Manual's glossary chapter.
  5539. <itemizedlist>
  5540. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  5541. Use this variable to specify "recommended-only"
  5542. packages that you do not want installed.
  5543. </para></listitem>
  5544. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  5545. Use this variable to prevent all "recommended-only"
  5546. packages from being installed.
  5547. </para></listitem>
  5548. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  5549. Use this variable to prevent specific packages from
  5550. being installed regardless of whether they are
  5551. "recommended-only" or not.
  5552. You need to realize that the build process could
  5553. fail with an error when you
  5554. prevent the installation of a package whose presence
  5555. is required by an installed package.
  5556. </para></listitem>
  5557. </itemizedlist>
  5558. </para>
  5559. </section>
  5560. <section id='incrementing-a-package-revision-number'>
  5561. <title>Incrementing a Package Revision Number</title>
  5562. <para>
  5563. If a committed change results in changing the package output,
  5564. then the value of the
  5565. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  5566. variable needs to be increased (or "bumped").
  5567. Increasing <filename>PR</filename> occurs one of two ways:
  5568. <itemizedlist>
  5569. <listitem><para>Automatically using a Package Revision
  5570. Service (PR Service).</para></listitem>
  5571. <listitem><para>Manually incrementing the
  5572. <filename>PR</filename> variable.</para></listitem>
  5573. </itemizedlist>
  5574. </para>
  5575. <para>
  5576. Given that one of the challenges any build system and its
  5577. users face is how to maintain a package feed that is compatible
  5578. with existing package manager applications such as
  5579. RPM, APT, and OPKG, using an automated system is much
  5580. preferred over a manual system.
  5581. In either system, the main requirement is that version
  5582. numbering increases in a linear fashion and that a number of
  5583. version components exist that support that linear progression.
  5584. </para>
  5585. <para>
  5586. The following two sections provide information on the PR Service
  5587. and on manual <filename>PR</filename> bumping.
  5588. </para>
  5589. <section id='working-with-a-pr-service'>
  5590. <title>Working With a PR Service</title>
  5591. <para>
  5592. As mentioned, attempting to maintain revision numbers in the
  5593. <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink>
  5594. is error prone, inaccurate, and causes problems for people
  5595. submitting recipes.
  5596. Conversely, the PR Service automatically generates
  5597. increasing numbers, particularly the revision field,
  5598. which removes the human element.
  5599. <note>
  5600. For additional information on using a PR Service, you
  5601. can see the
  5602. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  5603. wiki page.
  5604. </note>
  5605. </para>
  5606. <para>
  5607. The Yocto Project uses variables in order of
  5608. decreasing priority to facilitate revision numbering (i.e.
  5609. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  5610. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  5611. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  5612. for epoch, version, and revision, respectively).
  5613. The values are highly dependent on the policies and
  5614. procedures of a given distribution and package feed.
  5615. </para>
  5616. <para>
  5617. Because the OpenEmbedded build system uses
  5618. "<ulink url='&YOCTO_DOCS_REF_URL;#checksums'>signatures</ulink>",
  5619. which are unique to a given build, the build system
  5620. knows when to rebuild packages.
  5621. All the inputs into a given task are represented by a
  5622. signature, which can trigger a rebuild when different.
  5623. Thus, the build system itself does not rely on the
  5624. <filename>PR</filename> numbers to trigger a rebuild.
  5625. The signatures, however, can be used to generate
  5626. <filename>PR</filename> values.
  5627. </para>
  5628. <para>
  5629. The PR Service works with both
  5630. <filename>OEBasic</filename> and
  5631. <filename>OEBasicHash</filename> generators.
  5632. The value of <filename>PR</filename> bumps when the
  5633. checksum changes and the different generator mechanisms
  5634. change signatures under different circumstances.
  5635. </para>
  5636. <para>
  5637. As implemented, the build system includes values from
  5638. the PR Service into the <filename>PR</filename> field as
  5639. an addition using the form "<filename>.x</filename>" so
  5640. <filename>r0</filename> becomes <filename>r0.1</filename>,
  5641. <filename>r0.2</filename> and so forth.
  5642. This scheme allows existing <filename>PR</filename> values
  5643. to be used for whatever reasons, which include manual
  5644. <filename>PR</filename> bumps, should it be necessary.
  5645. </para>
  5646. <para>
  5647. By default, the PR Service is not enabled or running.
  5648. Thus, the packages generated are just "self consistent".
  5649. The build system adds and removes packages and
  5650. there are no guarantees about upgrade paths but images
  5651. will be consistent and correct with the latest changes.
  5652. </para>
  5653. <para>
  5654. The simplest form for a PR Service is for it to exist
  5655. for a single host development system that builds the
  5656. package feed (building system).
  5657. For this scenario, you can enable a local PR Service by
  5658. setting
  5659. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  5660. in your <filename>local.conf</filename> file in the
  5661. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>:
  5662. <literallayout class='monospaced'>
  5663. PRSERV_HOST = "localhost:0"
  5664. </literallayout>
  5665. Once the service is started, packages will automatically
  5666. get increasing <filename>PR</filename> values and
  5667. BitBake will take care of starting and stopping the server.
  5668. </para>
  5669. <para>
  5670. If you have a more complex setup where multiple host
  5671. development systems work against a common, shared package
  5672. feed, you have a single PR Service running and it is
  5673. connected to each building system.
  5674. For this scenario, you need to start the PR Service using
  5675. the <filename>bitbake-prserv</filename> command:
  5676. <literallayout class='monospaced'>
  5677. bitbake-prserv &dash;&dash;host <replaceable>ip</replaceable> &dash;&dash;port <replaceable>port</replaceable> &dash;&dash;start
  5678. </literallayout>
  5679. In addition to hand-starting the service, you need to
  5680. update the <filename>local.conf</filename> file of each
  5681. building system as described earlier so each system
  5682. points to the server and port.
  5683. </para>
  5684. <para>
  5685. It is also recommended you use build history, which adds
  5686. some sanity checks to package versions, in conjunction with
  5687. the server that is running the PR Service.
  5688. To enable build history, add the following to each building
  5689. system's <filename>local.conf</filename> file:
  5690. <literallayout class='monospaced'>
  5691. # It is recommended to activate "buildhistory" for testing the PR service
  5692. INHERIT += "buildhistory"
  5693. BUILDHISTORY_COMMIT = "1"
  5694. </literallayout>
  5695. For information on build history, see the
  5696. "<ulink url='&YOCTO_DOCS_REF_URL;#maintaining-build-output-quality'>Maintaining Build Output Quality</ulink>"
  5697. section in the Yocto Project Reference Manual.
  5698. </para>
  5699. <note>
  5700. <para>The OpenEmbedded build system does not maintain
  5701. <filename>PR</filename> information as part of the
  5702. shared state (sstate) packages.
  5703. If you maintain an sstate feed, its expected that either
  5704. all your building systems that contribute to the sstate
  5705. feed use a shared PR Service, or you do not run a PR
  5706. Service on any of your building systems.
  5707. Having some systems use a PR Service while others do
  5708. not leads to obvious problems.</para>
  5709. <para>For more information on shared state, see the
  5710. "<ulink url='&YOCTO_DOCS_REF_URL;#shared-state-cache'>Shared State Cache</ulink>"
  5711. section in the Yocto Project Reference Manual.</para>
  5712. </note>
  5713. </section>
  5714. <section id='manually-bumping-pr'>
  5715. <title>Manually Bumping PR</title>
  5716. <para>
  5717. The alternative to setting up a PR Service is to manually
  5718. bump the
  5719. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  5720. variable.
  5721. </para>
  5722. <para>
  5723. If a committed change results in changing the package output,
  5724. then the value of the PR variable needs to be increased
  5725. (or "bumped") as part of that commit.
  5726. For new recipes you should add the <filename>PR</filename>
  5727. variable and set its initial value equal to "r0", which is the default.
  5728. Even though the default value is "r0", the practice of adding it to a new recipe makes
  5729. it harder to forget to bump the variable when you make changes
  5730. to the recipe in future.
  5731. </para>
  5732. <para>
  5733. If you are sharing a common <filename>.inc</filename> file with multiple recipes,
  5734. you can also use the
  5735. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  5736. variable to ensure that
  5737. the recipes sharing the <filename>.inc</filename> file are rebuilt when the
  5738. <filename>.inc</filename> file itself is changed.
  5739. The <filename>.inc</filename> file must set <filename>INC_PR</filename>
  5740. (initially to "r0"), and all recipes referring to it should set <filename>PR</filename>
  5741. to "$(INC_PR).0" initially, incrementing the last number when the recipe is changed.
  5742. If the <filename>.inc</filename> file is changed then its
  5743. <filename>INC_PR</filename> should be incremented.
  5744. </para>
  5745. <para>
  5746. When upgrading the version of a package, assuming the
  5747. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  5748. changes, the <filename>PR</filename> variable should be
  5749. reset to "r0" (or "$(INC_PR).0" if you are using
  5750. <filename>INC_PR</filename>).
  5751. </para>
  5752. <para>
  5753. Usually, version increases occur only to packages.
  5754. However, if for some reason <filename>PV</filename> changes but does not
  5755. increase, you can increase the
  5756. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  5757. variable (Package Epoch).
  5758. The <filename>PE</filename> variable defaults to "0".
  5759. </para>
  5760. <para>
  5761. Version numbering strives to follow the
  5762. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  5763. Debian Version Field Policy Guidelines</ulink>.
  5764. These guidelines define how versions are compared and what "increasing" a version means.
  5765. </para>
  5766. </section>
  5767. </section>
  5768. <section id="usingpoky-configuring-DISTRO_PN_ALIAS">
  5769. <title>Handling a Package Name Alias</title>
  5770. <para>
  5771. Sometimes a package name you are using might exist under
  5772. an alias or as a similarly named package in a different
  5773. distribution.
  5774. The OpenEmbedded build system implements a
  5775. <filename>do_distro_check</filename>
  5776. task that automatically connects to major distributions
  5777. and checks for these situations.
  5778. If the package exists under a different name in a different
  5779. distribution, you get a <filename>distro_check</filename>
  5780. mismatch.
  5781. You can resolve this problem by defining a per-distro recipe
  5782. name alias using the
  5783. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_PN_ALIAS'>DISTRO_PN_ALIAS</ulink></filename>
  5784. variable.
  5785. </para>
  5786. <para>
  5787. Following is an example that shows how you specify the <filename>DISTRO_PN_ALIAS</filename>
  5788. variable:
  5789. <literallayout class='monospaced'>
  5790. DISTRO_PN_ALIAS_pn-PACKAGENAME = "distro1=package_name_alias1 \
  5791. distro2=package_name_alias2 \
  5792. distro3=package_name_alias3 \
  5793. ..."
  5794. </literallayout>
  5795. </para>
  5796. <para>
  5797. If you have more than one distribution alias, separate them with a space.
  5798. Note that the build system currently automatically checks the
  5799. Fedora, OpenSUSE, Debian, Ubuntu,
  5800. and Mandriva distributions for source package recipes without having to specify them
  5801. using the <filename>DISTRO_PN_ALIAS</filename> variable.
  5802. For example, the following command generates a report that lists the Linux distributions
  5803. that include the sources for each of the recipes.
  5804. <literallayout class='monospaced'>
  5805. $ bitbake world -f -c distro_check
  5806. </literallayout>
  5807. The results are stored in the <filename>build/tmp/log/distro_check-${DATETIME}.results</filename>
  5808. file found in the
  5809. <link linkend='source-directory'>Source Directory</link>.
  5810. </para>
  5811. </section>
  5812. <section id='handling-optional-module-packaging'>
  5813. <title>Handling Optional Module Packaging</title>
  5814. <para>
  5815. Many pieces of software split functionality into optional
  5816. modules (or plug-ins) and the plug-ins that are built
  5817. might depend on configuration options.
  5818. To avoid having to duplicate the logic that determines what
  5819. modules are available in your recipe or to avoid having
  5820. to package each module by hand, the OpenEmbedded build system
  5821. provides functionality to handle module packaging dynamically.
  5822. </para>
  5823. <para>
  5824. To handle optional module packaging, you need to do two things:
  5825. <itemizedlist>
  5826. <listitem><para>Ensure the module packaging is actually
  5827. done.</para></listitem>
  5828. <listitem><para>Ensure that any dependencies on optional
  5829. modules from other recipes are satisfied by your recipe.
  5830. </para></listitem>
  5831. </itemizedlist>
  5832. </para>
  5833. <section id='making-sure-the-packaging-is-done'>
  5834. <title>Making Sure the Packaging is Done</title>
  5835. <para>
  5836. To ensure the module packaging actually gets done, you use
  5837. the <filename>do_split_packages</filename> function within
  5838. the <filename>populate_packages</filename> Python function
  5839. in your recipe.
  5840. The <filename>do_split_packages</filename> function
  5841. searches for a pattern of files or directories under a
  5842. specified path and creates a package for each one it finds
  5843. by appending to the
  5844. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  5845. variable and setting the appropriate values for
  5846. <filename>FILES_packagename</filename>,
  5847. <filename>RDEPENDS_packagename</filename>,
  5848. <filename>DESCRIPTION_packagename</filename>, and so forth.
  5849. Here is an example from the <filename>lighttpd</filename>
  5850. recipe:
  5851. <literallayout class='monospaced'>
  5852. python populate_packages_prepend () {
  5853. lighttpd_libdir = d.expand('${libdir}')
  5854. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  5855. 'lighttpd-module-%s', 'Lighttpd module for %s',
  5856. extra_depends='')
  5857. }
  5858. </literallayout>
  5859. The previous example specifies a number of things in the
  5860. call to <filename>do_split_packages</filename>.
  5861. <itemizedlist>
  5862. <listitem><para>A directory within the files installed
  5863. by your recipe through <filename>do_install</filename>
  5864. in which to search.</para></listitem>
  5865. <listitem><para>A regular expression used to match module
  5866. files in that directory.
  5867. In the example, note the parentheses () that mark
  5868. the part of the expression from which the module
  5869. name should be derived.</para></listitem>
  5870. <listitem><para>A pattern to use for the package names.
  5871. </para></listitem>
  5872. <listitem><para>A description for each package.
  5873. </para></listitem>
  5874. <listitem><para>An empty string for
  5875. <filename>extra_depends</filename>, which disables
  5876. the default dependency on the main
  5877. <filename>lighttpd</filename> package.
  5878. Thus, if a file in <filename>${libdir}</filename>
  5879. called <filename>mod_alias.so</filename> is found,
  5880. a package called <filename>lighttpd-module-alias</filename>
  5881. is created for it and the
  5882. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  5883. is set to "Lighttpd module for alias".</para></listitem>
  5884. </itemizedlist>
  5885. </para>
  5886. <para>
  5887. Often, packaging modules is as simple as the previous
  5888. example.
  5889. However, more advanced options exist that you can use
  5890. within <filename>do_split_packages</filename> to modify its
  5891. behavior.
  5892. And, if you need to, you can add more logic by specifying
  5893. a hook function that is called for each package.
  5894. It is also perfectly acceptable to call
  5895. <filename>do_split_packages</filename> multiple times if
  5896. you have more than one set of modules to package.
  5897. </para>
  5898. <para>
  5899. For more examples that show how to use
  5900. <filename>do_split_packages</filename>, see the
  5901. <filename>connman.inc</filename> file in the
  5902. <filename>meta/recipes-connectivity/connman/</filename>
  5903. directory of the <filename>poky</filename>
  5904. <link linkend='yocto-project-repositories'>source repository</link>.
  5905. You can also find examples in
  5906. <filename>meta/classes/kernel.bbclass</filename>.
  5907. </para>
  5908. <para>
  5909. Following is a reference that shows
  5910. <filename>do_split_packages</filename> mandatory and
  5911. optional arguments:
  5912. <literallayout class='monospaced'>
  5913. Mandatory arguments
  5914. root
  5915. The path in which to search
  5916. file_regex
  5917. Regular expression to match searched files.
  5918. Use parentheses () to mark the part of this
  5919. expression that should be used to derive the
  5920. module name (to be substituted where %s is
  5921. used in other function arguments as noted below)
  5922. output_pattern
  5923. Pattern to use for the package names. Must
  5924. include %s.
  5925. description
  5926. Description to set for each package. Must
  5927. include %s.
  5928. Optional arguments
  5929. postinst
  5930. Postinstall script to use for all packages
  5931. (as a string)
  5932. recursive
  5933. True to perform a recursive search - default
  5934. False
  5935. hook
  5936. A hook function to be called for every match.
  5937. The function will be called with the following
  5938. arguments (in the order listed):
  5939. f
  5940. Full path to the file/directory match
  5941. pkg
  5942. The package name
  5943. file_regex
  5944. As above
  5945. output_pattern
  5946. As above
  5947. modulename
  5948. The module name derived using file_regex
  5949. extra_depends
  5950. Extra runtime dependencies (RDEPENDS) to be
  5951. set for all packages. The default value of None
  5952. causes a dependency on the main package
  5953. (${PN}) - if you do not want this, pass empty
  5954. string '' for this parameter.
  5955. aux_files_pattern
  5956. Extra item(s) to be added to FILES for each
  5957. package. Can be a single string item or a list
  5958. of strings for multiple items. Must include %s.
  5959. postrm
  5960. postrm script to use for all packages (as a
  5961. string)
  5962. allow_dirs
  5963. True to allow directories to be matched -
  5964. default False
  5965. prepend
  5966. If True, prepend created packages to PACKAGES
  5967. instead of the default False which appends them
  5968. match_path
  5969. match file_regex on the whole relative path to
  5970. the root rather than just the file name
  5971. aux_files_pattern_verbatim
  5972. Extra item(s) to be added to FILES for each
  5973. package, using the actual derived module name
  5974. rather than converting it to something legal
  5975. for a package name. Can be a single string item
  5976. or a list of strings for multiple items. Must
  5977. include %s.
  5978. allow_links
  5979. True to allow symlinks to be matched - default
  5980. False
  5981. summary
  5982. Summary to set for each package. Must include %s;
  5983. defaults to description if not set.
  5984. </literallayout>
  5985. </para>
  5986. </section>
  5987. <section id='satisfying-dependencies'>
  5988. <title>Satisfying Dependencies</title>
  5989. <para>
  5990. The second part for handling optional module packaging
  5991. is to ensure that any dependencies on optional modules
  5992. from other recipes are satisfied by your recipe.
  5993. You can be sure these dependencies are satisfied by
  5994. using the
  5995. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  5996. Here is an example that continues with the
  5997. <filename>lighttpd</filename> recipe shown earlier:
  5998. <literallayout class='monospaced'>
  5999. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  6000. </literallayout>
  6001. The name specified in the regular expression can of
  6002. course be anything.
  6003. In this example, it is <filename>lighttpd-module-</filename>
  6004. and is specified as the prefix to ensure that any
  6005. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  6006. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  6007. on a package name starting with the prefix are satisfied
  6008. during build time.
  6009. If you are using <filename>do_split_packages</filename>
  6010. as described in the previous section, the value you put in
  6011. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  6012. the name pattern specified in the call to
  6013. <filename>do_split_packages</filename>.
  6014. </para>
  6015. </section>
  6016. </section>
  6017. <section id='using-runtime-package-management'>
  6018. <title>Using Runtime Package Management</title>
  6019. <para>
  6020. During a build, BitBake always transforms a recipe into one or
  6021. more packages.
  6022. For example, BitBake takes the <filename>bash</filename> recipe
  6023. and currently produces the <filename>bash-dbg</filename>,
  6024. <filename>bash-staticdev</filename>,
  6025. <filename>bash-dev</filename>, <filename>bash-doc</filename>,
  6026. <filename>bash-locale</filename>, and
  6027. <filename>bash</filename> packages.
  6028. Not all generated packages are included in an image.
  6029. </para>
  6030. <para>
  6031. In several situations, you might need to update, add, remove,
  6032. or query the packages on a target device at runtime
  6033. (i.e. without having to generate a new image).
  6034. Examples of such situations include:
  6035. <itemizedlist>
  6036. <listitem><para>
  6037. You want to provide in-the-field updates to deployed
  6038. devices (e.g. security updates).
  6039. </para></listitem>
  6040. <listitem><para>
  6041. You want to have a fast turn-around development cycle
  6042. for one or more applications that run on your device.
  6043. </para></listitem>
  6044. <listitem><para>
  6045. You want to temporarily install the "debug" packages
  6046. of various applications on your device so that
  6047. debugging can be greatly improved by allowing
  6048. access to symbols and source debugging.
  6049. </para></listitem>
  6050. <listitem><para>
  6051. You want to deploy a more minimal package selection of
  6052. your device but allow in-the-field updates to add a
  6053. larger selection for customization.
  6054. </para></listitem>
  6055. </itemizedlist>
  6056. </para>
  6057. <para>
  6058. In all these situations, you have something similar to a more
  6059. traditional Linux distribution in that in-field devices
  6060. are able to receive pre-compiled packages from a server for
  6061. installation or update.
  6062. Being able to install these packages on a running,
  6063. in-field device is what is termed "runtime package
  6064. management".
  6065. </para>
  6066. <para>
  6067. In order to use runtime package management, you
  6068. need a host/server machine that serves up the pre-compiled
  6069. packages plus the required metadata.
  6070. You also need package manipulation tools on the target.
  6071. The build machine is a likely candidate to act as the server.
  6072. However, that machine does not necessarily have to be the
  6073. package server.
  6074. The build machine could push its artifacts to another machine
  6075. that acts as the server (e.g. Internet-facing).
  6076. </para>
  6077. <para>
  6078. A simple build that targets just one device produces
  6079. more than one package database.
  6080. In other words, the packages produced by a build are separated
  6081. out into a couple of different package groupings based on
  6082. criteria such as the target's CPU architecture, the target
  6083. board, or the C library used on the target.
  6084. For example, a build targeting the <filename>qemuarm</filename>
  6085. device produces the following three package databases:
  6086. <filename>all</filename>, <filename>armv5te</filename>, and
  6087. <filename>qemuarm</filename>.
  6088. If you wanted your <filename>qemuarm</filename> device to be
  6089. aware of all the packages that were available to it,
  6090. you would need to point it to each of these databases
  6091. individually.
  6092. In a similar way, a traditional Linux distribution usually is
  6093. configured to be aware of a number of software repositories
  6094. from which it retrieves packages.
  6095. </para>
  6096. <para>
  6097. Using runtime package management is completely optional and
  6098. not required for a successful build or deployment in any
  6099. way.
  6100. But if you want to make use of runtime package management,
  6101. you need to do a couple things above and beyond the basics.
  6102. The remainder of this section describes what you need to do.
  6103. </para>
  6104. <section id='runtime-package-management-build'>
  6105. <title>Build Considerations</title>
  6106. <para>
  6107. This section describes build considerations that you need
  6108. to be aware of in order to provide support for runtime
  6109. package management.
  6110. </para>
  6111. <para>
  6112. When BitBake generates packages it needs to know
  6113. what format or formats to use.
  6114. In your configuration, you use the
  6115. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  6116. variable to specify the format.
  6117. <note>
  6118. You can choose to have more than one format but you must
  6119. provide at least one.
  6120. </note>
  6121. </para>
  6122. <para>
  6123. If you would like your image to start off with a basic
  6124. package database of the packages in your current build
  6125. as well as have the relevant tools available on the
  6126. target for runtime package management, you can include
  6127. "package-management" in the
  6128. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  6129. variable.
  6130. Including "package-management" in this
  6131. configuration variable ensures that when the image
  6132. is assembled for your target, the image includes
  6133. the currently-known package databases as well as
  6134. the target-specific tools required for runtime
  6135. package management to be performed on the target.
  6136. However, this is not strictly necessary.
  6137. You could start your image off without any databases
  6138. but only include the required on-target package
  6139. tool(s).
  6140. As an example, you could include "opkg" in your
  6141. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  6142. variable if you are using the IPK package format.
  6143. You can then initialize your target's package database(s)
  6144. later once your image is up and running.
  6145. </para>
  6146. <para>
  6147. Whenever you perform any sort of build step that can
  6148. potentially generate a package or modify an existing
  6149. package, it is always a good idea to re-generate the
  6150. package index with:
  6151. <literallayout class='monospaced'>
  6152. $ bitbake package-index
  6153. </literallayout>
  6154. Realize that it is not sufficient to simply do the
  6155. following:
  6156. <literallayout class='monospaced'>
  6157. $ bitbake <replaceable>some-package</replaceable> package-index
  6158. </literallayout>
  6159. This is because BitBake does not properly schedule the
  6160. <filename>package-index</filename> target fully after any
  6161. other target has completed.
  6162. Thus, be sure to run the package update step separately.
  6163. </para>
  6164. <para>
  6165. As described below in the
  6166. "<link linkend='runtime-package-management-target-ipk'>Using IPK</link>"
  6167. section, if you are using IPK as your package format, you
  6168. can make use of the
  6169. <filename>distro-feed-configs</filename> recipe provided
  6170. by <filename>meta-oe</filename> in order to configure your
  6171. target to use your IPK databases.
  6172. </para>
  6173. <para>
  6174. When your build is complete, your packages reside in the
  6175. <filename>${TMPDIR}/deploy/<replaceable>package-format</replaceable></filename>
  6176. directory.
  6177. For example, if <filename>${TMPDIR}</filename>
  6178. is <filename>tmp</filename> and your selected package type
  6179. is IPK, then your IPK packages are available in
  6180. <filename>tmp/deploy/ipk</filename>.
  6181. </para>
  6182. </section>
  6183. <section id='runtime-package-management-server'>
  6184. <title>Host or Server Machine Setup</title>
  6185. <para>
  6186. Typically, packages are served from a server using
  6187. HTTP.
  6188. However, other protocols are possible.
  6189. If you want to use HTTP, then setup and configure a
  6190. web server, such as Apache 2 or lighttpd, on the machine
  6191. serving the packages.
  6192. </para>
  6193. <para>
  6194. As previously mentioned, the build machine can act as the
  6195. package server.
  6196. In the following sections that describe server machine
  6197. setups, the build machine is assumed to also be the server.
  6198. </para>
  6199. <section id='package-server-apache'>
  6200. <title>Serving Packages via Apache 2</title>
  6201. <para>
  6202. This example assumes you are using the Apache 2
  6203. server:
  6204. <orderedlist>
  6205. <listitem><para>
  6206. Add the directory to your Apache
  6207. configuration, which you can find at
  6208. <filename>/etc/httpd/conf/httpd.conf</filename>.
  6209. Use commands similar to these on the
  6210. development system.
  6211. These example commands assume a top-level
  6212. <link linkend='source-directory'>Source Directory</link>
  6213. named <filename>poky</filename> in your home
  6214. directory.
  6215. The example also assumes an RPM package type.
  6216. If you are using a different package type, such
  6217. as IPK, use "ipk" in the pathnames:
  6218. <literallayout class='monospaced'>
  6219. &lt;VirtualHost *:80&gt;
  6220. ....
  6221. Alias /rpm ~/poky/build/tmp/deploy/rpm
  6222. &lt;Directory "~/poky/build/tmp/deploy/rpm"&gt;
  6223. Options +Indexes
  6224. &lt;/Directory&gt;
  6225. &lt;/VirtualHost&gt;
  6226. </literallayout></para></listitem>
  6227. <listitem><para>
  6228. Reload the Apache configuration as described
  6229. in this step.
  6230. For all commands, be sure you have root
  6231. privileges.
  6232. </para>
  6233. <para>
  6234. If your development system is using Fedora or
  6235. CentOS, use the following:
  6236. <literallayout class='monospaced'>
  6237. # service httpd reload
  6238. </literallayout>
  6239. For Ubuntu and Debian, use the following:
  6240. <literallayout class='monospaced'>
  6241. # /etc/init.d/apache2 reload
  6242. </literallayout>
  6243. For OpenSUSE, use the following:
  6244. <literallayout class='monospaced'>
  6245. # /etc/init.d/apache2 reload
  6246. </literallayout></para></listitem>
  6247. <listitem><para>
  6248. If you are using Security-Enhanced Linux
  6249. (SELinux), you need to label the files as
  6250. being accessible through Apache.
  6251. Use the following command from the development
  6252. host.
  6253. This example assumes RPM package types:
  6254. <literallayout class='monospaced'>
  6255. # chcon -R -h -t httpd_sys_content_t tmp/deploy/rpm
  6256. </literallayout></para></listitem>
  6257. </orderedlist>
  6258. </para>
  6259. </section>
  6260. <section id='package-server-lighttpd'>
  6261. <title>Serving Packages via lighttpd</title>
  6262. <para>
  6263. If you are using lighttpd, all you need
  6264. to do is to provide a link from your
  6265. <filename>${TMPDIR}/deploy/<replaceable>package-format</replaceable></filename>
  6266. directory to lighttpd's document-root.
  6267. You can determine the specifics of your lighttpd
  6268. installation by looking through its configuration file,
  6269. which is usually found at:
  6270. <filename>/etc/lighttpd/lighttpd.conf</filename>.
  6271. </para>
  6272. <para>
  6273. For example, if you are using IPK, lighttpd's
  6274. document-root is set to
  6275. <filename>/var/www/lighttpd</filename>, and you had
  6276. packages for a target named "BOARD",
  6277. then you might create a link from your build location
  6278. to lighttpd's document-root as follows:
  6279. <literallayout class='monospaced'>
  6280. # ln -s $(PWD)/tmp/deploy/ipk /var/www/lighttpd/BOARD-dir
  6281. </literallayout>
  6282. </para>
  6283. <para>
  6284. At this point, you need to start the lighttpd server.
  6285. The method used to start the server varies by
  6286. distribution.
  6287. However, one basic method that starts it by hand is:
  6288. <literallayout class='monospaced'>
  6289. # lighttpd -f /etc/lighttpd/lighttpd.conf
  6290. </literallayout>
  6291. </para>
  6292. </section>
  6293. </section>
  6294. <section id='runtime-package-management-target'>
  6295. <title>Target Setup</title>
  6296. <para>
  6297. Setting up the target differs depending on the
  6298. package management system.
  6299. This section provides information for RPM and IPK.
  6300. </para>
  6301. <section id='runtime-package-management-target-rpm'>
  6302. <title>Using RPM</title>
  6303. <para>
  6304. The application for performing runtime package
  6305. management of RPM packages on the target is called
  6306. <filename>smart</filename>.
  6307. </para>
  6308. <para>
  6309. On the target machine, you need to inform
  6310. <filename>smart</filename> of every package database
  6311. you want to use.
  6312. As an example, suppose your target device can use the
  6313. following three package databases from a server named
  6314. <filename>server.name</filename>:
  6315. <filename>all</filename>, <filename>i586</filename>,
  6316. and <filename>qemux86</filename>.
  6317. Given this example, issue the following commands on the
  6318. target:
  6319. <literallayout class='monospaced'>
  6320. # smart channel &dash;&dash;add all type=rpm-md baseurl=http://server.name/rpm/all
  6321. # smart channel &dash;&dash;add i585 type=rpm-md baseurl=http://server.name/rpm/i586
  6322. # smart channel &dash;&dash;add qemux86 type=rpm-md baseurl=http://server.name/rpm/qemux86
  6323. </literallayout>
  6324. Also from the target machine, fetch the repository
  6325. information using this command:
  6326. <literallayout class='monospaced'>
  6327. # smart update
  6328. </literallayout>
  6329. You can now use the <filename>smart query</filename>
  6330. and <filename>smart install</filename> commands to
  6331. find and install packages from the repositories.
  6332. </para>
  6333. </section>
  6334. <section id='runtime-package-management-target-ipk'>
  6335. <title>Using IPK</title>
  6336. <para>
  6337. The application for performing runtime package
  6338. management of IPK packages on the target is called
  6339. <filename>opkg</filename>.
  6340. </para>
  6341. <para>
  6342. In order to inform <filename>opkg</filename> of the
  6343. package databases you want to use, simply create one
  6344. or more <filename>*.conf</filename> files in the
  6345. <filename>/etc/opkg</filename> directory on the target.
  6346. The <filename>opkg</filename> application uses them
  6347. to find its available package databases.
  6348. As an example, suppose you configured your HTTP server
  6349. on your machine named
  6350. <filename>www.mysite.com</filename> to serve files
  6351. from a <filename>BOARD-dir</filename> directory under
  6352. its document-root.
  6353. In this case, you might create a configuration
  6354. file on the target called
  6355. <filename>/etc/opkg/base-feeds.conf</filename> that
  6356. contains:
  6357. <literallayout class='monospaced'>
  6358. src/gz all http://www.mysite.com/BOARD-dir/all
  6359. src/gz armv7a http://www.mysite.com/BOARD-dir/armv7a
  6360. src/gz beaglebone http://www.mysite.com/BOARD-dir/beaglebone
  6361. </literallayout>
  6362. </para>
  6363. <para>
  6364. As a way of making it easier to generate and make
  6365. these IPK configuration files available on your
  6366. target, simply define
  6367. <ulink url='&YOCTO_DOCS_REF_URL;#var-FEED_DEPLOYDIR_BASE_URI'><filename>FEED_DEPLOYDIR_BASE_URI</filename></ulink>
  6368. to point to your server and the location within the
  6369. document-root which contains the databases.
  6370. For example: if you are serving your packages over
  6371. HTTP, your server's IP address is 192.168.7.1, and
  6372. your databases are located in a directory called
  6373. <filename>BOARD-dir</filename> underneath your HTTP
  6374. server's document-root, you need to set
  6375. <filename>FEED_DEPLOYDIR_BASE_URI</filename> to
  6376. <filename>http://192.168.7.1/BOARD-dir</filename> and
  6377. a set of configuration files will be generated for you
  6378. in your target to work with this feed.
  6379. </para>
  6380. <para>
  6381. On the target machine, fetch (or refresh) the
  6382. repository information using this command:
  6383. <literallayout class='monospaced'>
  6384. # opkg update
  6385. </literallayout>
  6386. You can now use the <filename>opkg list</filename> and
  6387. <filename>opkg install</filename> commands to find and
  6388. install packages from the repositories.
  6389. </para>
  6390. </section>
  6391. </section>
  6392. </section>
  6393. <section id='testing-packages-with-ptest'>
  6394. <title>Testing Packages With ptest</title>
  6395. <para>
  6396. A Package Test (ptest) runs tests against packages built
  6397. by the OpenEmbedded build system on the target machine.
  6398. A ptest contains at least two items: the actual test, and
  6399. a shell script (<filename>run-ptest</filename>) that starts
  6400. the test.
  6401. The shell script that starts the test must not contain
  6402. the actual test - the script only starts the test.
  6403. On the other hand, the test can be anything from a simple
  6404. shell script that runs a binary and checks the output to
  6405. an elaborate system of test binaries and data files.
  6406. </para>
  6407. <para>
  6408. The test generates output in the format used by
  6409. Automake:
  6410. <literallayout class='monospaced'>
  6411. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  6412. </literallayout>
  6413. where the result can be <filename>PASS</filename>,
  6414. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  6415. and the testname can be any identifying string.
  6416. </para>
  6417. <note>
  6418. A recipe is "ptest-enabled" if it inherits the
  6419. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  6420. class.
  6421. </note>
  6422. <section id='adding-ptest-to-your-build'>
  6423. <title>Adding ptest to Your Build</title>
  6424. <para>
  6425. To add package testing to your build, add the
  6426. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6427. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  6428. variables to your <filename>local.conf</filename> file,
  6429. which is found in the
  6430. <link linkend='build-directory'>Build Directory</link>:
  6431. <literallayout class='monospaced'>
  6432. DISTRO_FEATURES_append = " ptest"
  6433. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  6434. </literallayout>
  6435. Once your build is complete, the ptest files are installed
  6436. into the
  6437. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  6438. directory within the image, where
  6439. <filename><replaceable>package</replaceable></filename>
  6440. is the name of the package.
  6441. </para>
  6442. </section>
  6443. <section id='running-ptest'>
  6444. <title>Running ptest</title>
  6445. <para>
  6446. The <filename>ptest-runner</filename> package installs a
  6447. shell script that loops through all installed ptest test
  6448. suites and runs them in sequence.
  6449. Consequently, you might want to add this package to
  6450. your image.
  6451. </para>
  6452. </section>
  6453. <section id='getting-your-package-ready'>
  6454. <title>Getting Your Package Ready</title>
  6455. <para>
  6456. In order to enable a recipe to run installed ptests
  6457. on target hardware,
  6458. you need to prepare the recipes that build the packages
  6459. you want to test.
  6460. Here is what you have to do for each recipe:
  6461. <itemizedlist>
  6462. <listitem><para><emphasis>Be sure the recipe
  6463. inherits the
  6464. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  6465. class:</emphasis>
  6466. Include the following line in each recipe:
  6467. <literallayout class='monospaced'>
  6468. inherit ptest
  6469. </literallayout>
  6470. </para></listitem>
  6471. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  6472. This script starts your test.
  6473. Locate the script where you will refer to it
  6474. using
  6475. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  6476. Here is an example that starts a test for
  6477. <filename>dbus</filename>:
  6478. <literallayout class='monospaced'>
  6479. #!/bin/sh
  6480. cd test
  6481. make -k runtest-TESTS
  6482. </literallayout>
  6483. </para></listitem>
  6484. <listitem><para><emphasis>Ensure dependencies are
  6485. met:</emphasis>
  6486. If the test adds build or runtime dependencies
  6487. that normally do not exist for the package
  6488. (such as requiring "make" to run the test suite),
  6489. use the
  6490. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  6491. and
  6492. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  6493. variables in your recipe in order for the package
  6494. to meet the dependencies.
  6495. Here is an example where the package has a runtime
  6496. dependency on "make":
  6497. <literallayout class='monospaced'>
  6498. RDEPENDS_${PN}-ptest += "make"
  6499. </literallayout>
  6500. </para></listitem>
  6501. <listitem><para><emphasis>Add a function to build the
  6502. test suite:</emphasis>
  6503. Not many packages support cross-compilation of
  6504. their test suites.
  6505. Consequently, you usually need to add a
  6506. cross-compilation function to the package.
  6507. </para>
  6508. <para>Many packages based on Automake compile and
  6509. run the test suite by using a single command
  6510. such as <filename>make check</filename>.
  6511. However, the native <filename>make check</filename>
  6512. builds and runs on the same computer, while
  6513. cross-compiling requires that the package is built
  6514. on the host but executed on the target.
  6515. The built version of Automake that ships with the
  6516. Yocto Project includes a patch that separates
  6517. building and execution.
  6518. Consequently, packages that use the unaltered,
  6519. patched version of <filename>make check</filename>
  6520. automatically cross-compiles.</para>
  6521. <para>Regardless, you still must add a
  6522. <filename>do_compile_ptest</filename> function to
  6523. build the test suite.
  6524. Add a function similar to the following to your
  6525. recipe:
  6526. <literallayout class='monospaced'>
  6527. do_compile_ptest() {
  6528. oe_runmake buildtest-TESTS
  6529. }
  6530. </literallayout>
  6531. </para></listitem>
  6532. <listitem><para><emphasis>Ensure special configurations
  6533. are set:</emphasis>
  6534. If the package requires special configurations
  6535. prior to compiling the test code, you must
  6536. insert a <filename>do_configure_ptest</filename>
  6537. function into the recipe.
  6538. </para></listitem>
  6539. <listitem><para><emphasis>Install the test
  6540. suite:</emphasis>
  6541. The <filename>ptest</filename> class
  6542. automatically copies the file
  6543. <filename>run-ptest</filename> to the target and
  6544. then runs make <filename>install-ptest</filename>
  6545. to run the tests.
  6546. If this is not enough, you need to create a
  6547. <filename>do_install_ptest</filename> function and
  6548. make sure it gets called after the
  6549. "make install-ptest" completes.
  6550. </para></listitem>
  6551. </itemizedlist>
  6552. </para>
  6553. </section>
  6554. </section>
  6555. </section>
  6556. <section id='working-with-source-files'>
  6557. <title>Working with Source Files</title>
  6558. <para>
  6559. The OpenEmbedded build system works with source files located
  6560. through the
  6561. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  6562. variable.
  6563. When you build something using BitBake, a big part of the operation
  6564. is locating and downloading all the source tarballs.
  6565. For images, downloading all the source for various packages can
  6566. take a significant amount of time.
  6567. </para>
  6568. <para>
  6569. This section presents information for working with source
  6570. files that can lead to more efficient use of resources and
  6571. time.
  6572. </para>
  6573. <section id='setting-up-effective-mirrors'>
  6574. <title>Setting up Effective Mirrors</title>
  6575. <para>
  6576. As mentioned, a good deal that goes into a Yocto Project
  6577. build is simply downloading all of the source tarballs.
  6578. Maybe you have been working with another build system
  6579. (OpenEmbedded or Angstrom) for which you have built up a
  6580. sizable directory of source tarballs.
  6581. Or, perhaps someone else has such a directory for which you
  6582. have read access.
  6583. If so, you can save time by adding statements to your
  6584. configuration file so that the build process checks local
  6585. directories first for existing tarballs before checking the
  6586. Internet.
  6587. </para>
  6588. <para>
  6589. Here is an efficient way to set it up in your
  6590. <filename>local.conf</filename> file:
  6591. <literallayout class='monospaced'>
  6592. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  6593. INHERIT += "own-mirrors"
  6594. BB_GENERATE_MIRROR_TARBALLS = "1"
  6595. # BB_NO_NETWORK = "1"
  6596. </literallayout>
  6597. </para>
  6598. <para>
  6599. In the previous example, the
  6600. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  6601. variable causes the OpenEmbedded build system to generate
  6602. tarballs of the Git repositories and store them in the
  6603. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  6604. directory.
  6605. Due to performance reasons, generating and storing these
  6606. tarballs is not the build system's default behavior.
  6607. </para>
  6608. <para>
  6609. You can also use the
  6610. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  6611. variable.
  6612. For an example, see the variable's glossary entry in the
  6613. Yocto Project Reference Manual.
  6614. </para>
  6615. </section>
  6616. <section id='getting-source-files-and-suppressing-the-build'>
  6617. <title>Getting Source Files and Suppressing the Build</title>
  6618. <para>
  6619. Another technique you can use to ready yourself for a
  6620. successive string of build operations, is to pre-fetch
  6621. all the source files without actually starting a build.
  6622. This technique lets you work through any download issues
  6623. and ultimately gathers all the source files into your
  6624. download directory
  6625. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  6626. which is located with
  6627. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  6628. </para>
  6629. <para>
  6630. Use the following BitBake command form to fetch all the
  6631. necessary sources without starting the build:
  6632. <literallayout class='monospaced'>
  6633. $ bitbake -c fetchall <replaceable>target</replaceable>
  6634. </literallayout>
  6635. This variation of the BitBake command guarantees that you
  6636. have all the sources for that BitBake target should you
  6637. disconnect from the Internet and want to do the build
  6638. later offline.
  6639. </para>
  6640. </section>
  6641. </section>
  6642. <section id="building-software-from-an-external-source">
  6643. <title>Building Software from an External Source</title>
  6644. <para>
  6645. By default, the OpenEmbedded build system uses the
  6646. <link linkend='build-directory'>Build Directory</link> when
  6647. building source code.
  6648. The build process involves fetching the source files, unpacking
  6649. them, and then patching them if necessary before the build takes
  6650. place.
  6651. </para>
  6652. <para>
  6653. Situations exist where you might want to build software from source
  6654. files that are external to and thus outside of the
  6655. OpenEmbedded build system.
  6656. For example, suppose you have a project that includes a new BSP with
  6657. a heavily customized kernel.
  6658. And, you want to minimize exposing the build system to the
  6659. development team so that they can focus on their project and
  6660. maintain everyone's workflow as much as possible.
  6661. In this case, you want a kernel source directory on the development
  6662. machine where the development occurs.
  6663. You want the recipe's
  6664. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  6665. variable to point to the external directory and use it as is, not
  6666. copy it.
  6667. </para>
  6668. <para>
  6669. To build from software that comes from an external source, all you
  6670. need to do is inherit the
  6671. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  6672. class and then set the
  6673. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>
  6674. variable to point to your external source code.
  6675. Here are the statements to put in your
  6676. <filename>local.conf</filename> file:
  6677. <literallayout class='monospaced'>
  6678. INHERIT += "externalsrc"
  6679. EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  6680. </literallayout>
  6681. </para>
  6682. <para>
  6683. This next example shows how to accomplish the same thing by setting
  6684. <filename>EXTERNALSRC</filename> in the recipe itself or in the
  6685. recipe's append file:
  6686. <literallayout class='monospaced'>
  6687. EXTERNALSRC = "<replaceable>path</replaceable>"
  6688. EXTERNALSRC_BUILD = "<replaceable>path</replaceable>"
  6689. </literallayout>
  6690. <note>
  6691. In order for these settings to take effect, you must globally
  6692. or locally inherit the
  6693. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  6694. class.
  6695. </note>
  6696. </para>
  6697. <para>
  6698. By default, <filename>externalsrc.bbclass</filename> builds
  6699. the source code in a directory separate from the external source
  6700. directory as specified by
  6701. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>.
  6702. If you need to have the source built in the same directory in
  6703. which it resides, or some other nominated directory, you can set
  6704. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink>
  6705. to point to that directory:
  6706. <literallayout class='monospaced'>
  6707. EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  6708. </literallayout>
  6709. </para>
  6710. </section>
  6711. <section id="selecting-an-initialization-manager">
  6712. <title>Selecting an Initialization Manager</title>
  6713. <para>
  6714. By default, the Yocto Project uses SysVinit as the initialization
  6715. manager.
  6716. However, support also exists for systemd,
  6717. which is a full replacement for init with
  6718. parallel starting of services, reduced shell overhead and other
  6719. features that are used by many distributions.
  6720. </para>
  6721. <para>
  6722. If you want to use SysVinit, you do
  6723. not have to do anything.
  6724. But, if you want to use systemd, you must
  6725. take some steps as described in the following sections.
  6726. </para>
  6727. <section id='using-systemd-exclusively'>
  6728. <title>Using systemd Exclusively</title>
  6729. <para>
  6730. Set the these variables in your distribution configuration
  6731. file as follows:
  6732. <literallayout class='monospaced'>
  6733. DISTRO_FEATURES_append = " systemd"
  6734. VIRTUAL-RUNTIME_init_manager = "systemd"
  6735. </literallayout>
  6736. You can also prevent the SysVinit
  6737. distribution feature from
  6738. being automatically enabled as follows:
  6739. <literallayout class='monospaced'>
  6740. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  6741. </literallayout>
  6742. Doing so removes any redundant SysVinit scripts.
  6743. </para>
  6744. <para>
  6745. To remove initscripts from your image altogether,
  6746. set this variable also:
  6747. <literallayout class='monospaced'>
  6748. VIRTUAL-RUNTIME_initscripts = ""
  6749. </literallayout>
  6750. </para>
  6751. <para>
  6752. For information on the backfill variable, see
  6753. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  6754. </para>
  6755. </section>
  6756. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  6757. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  6758. <para>
  6759. Set these variables in your distribution configuration
  6760. file as follows:
  6761. <literallayout class='monospaced'>
  6762. DISTRO_FEATURES_append = " systemd"
  6763. VIRTUAL-RUNTIME_init_manager = "systemd"
  6764. </literallayout>
  6765. Doing so causes your main image to use the
  6766. <filename>packagegroup-core-boot.bb</filename> recipe and
  6767. systemd.
  6768. The rescue/minimal image cannot use this package group.
  6769. However, it can install SysVinit
  6770. and the appropriate packages will have support for both
  6771. systemd and SysVinit.
  6772. </para>
  6773. </section>
  6774. </section>
  6775. <section id="platdev-appdev-srcrev">
  6776. <title>Using an External SCM</title>
  6777. <para>
  6778. If you're working on a recipe that pulls from an external Source
  6779. Code Manager (SCM), it is possible to have the OpenEmbedded build
  6780. system notice new recipe changes added to the SCM and then build
  6781. the resulting packages that depend on the new recipes by using
  6782. the latest versions.
  6783. This only works for SCMs from which it is possible to get a
  6784. sensible revision number for changes.
  6785. Currently, you can do this with Apache Subversion (SVN), Git, and
  6786. Bazaar (BZR) repositories.
  6787. </para>
  6788. <para>
  6789. To enable this behavior, the
  6790. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  6791. of the recipe needs to reference
  6792. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  6793. Here is an example:
  6794. <literallayout class='monospaced'>
  6795. PV = "1.2.3+git${SRCPV}
  6796. </literallayout>
  6797. Then, you can add the following to your
  6798. <filename>local.conf</filename>:
  6799. <literallayout class='monospaced'>
  6800. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  6801. </literallayout>
  6802. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  6803. is the name of the recipe for which you want to enable automatic source
  6804. revision updating.
  6805. </para>
  6806. <para>
  6807. If you do not want to update your local configuration file, you can
  6808. add the following directly to the recipe to finish enabling
  6809. the feature:
  6810. <literallayout class='monospaced'>
  6811. SRCREV = "${AUTOREV}"
  6812. </literallayout>
  6813. </para>
  6814. <para>
  6815. The Yocto Project provides a distribution named
  6816. <filename>poky-bleeding</filename>, whose configuration
  6817. file contains the line:
  6818. <literallayout class='monospaced'>
  6819. require conf/distro/include/poky-floating-revisions.inc
  6820. </literallayout>
  6821. This line pulls in the listed include file that contains
  6822. numerous lines of exactly that form:
  6823. <literallayout class='monospaced'>
  6824. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  6825. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  6826. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  6827. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  6828. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  6829. SRCREV_pn-matchbox-panel ?= "${AUTOREV}"
  6830. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  6831. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  6832. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  6833. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  6834. SRCREV_pn-matchbox-wm-2 ?= "${AUTOREV}"
  6835. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  6836. SRCREV_pn-screenshot ?= "${AUTOREV}"
  6837. SRCREV_pn-libfakekey ?= "${AUTOREV}"
  6838. SRCREV_pn-oprofileui ?= "${AUTOREV}"
  6839. .
  6840. .
  6841. .
  6842. </literallayout>
  6843. These lines allow you to experiment with building a
  6844. distribution that tracks the latest development source
  6845. for numerous packages.
  6846. <note><title>Caution</title>
  6847. The <filename>poky-bleeding</filename> distribution
  6848. is not tested on a regular basis.
  6849. Keep this in mind if you use it.
  6850. </note>
  6851. </para>
  6852. </section>
  6853. <section id='creating-a-read-only-root-filesystem'>
  6854. <title>Creating a Read-Only Root Filesystem</title>
  6855. <para>
  6856. Suppose, for security reasons, you need to disable
  6857. your target device's root filesystem's write permissions
  6858. (i.e. you need a read-only root filesystem).
  6859. Or, perhaps you are running the device's operating system
  6860. from a read-only storage device.
  6861. For either case, you can customize your image for
  6862. that behavior.
  6863. </para>
  6864. <note>
  6865. Supporting a read-only root filesystem requires that the system and
  6866. applications do not try to write to the root filesystem.
  6867. You must configure all parts of the target system to write
  6868. elsewhere, or to gracefully fail in the event of attempting to
  6869. write to the root filesystem.
  6870. </note>
  6871. <section id='creating-the-root-filesystem'>
  6872. <title>Creating the Root Filesystem</title>
  6873. <para>
  6874. To create the read-only root filesystem, simply add the
  6875. "read-only-rootfs" feature to your image.
  6876. Using either of the following statements in your
  6877. image recipe or from within the
  6878. <filename>local.conf</filename> file found in the
  6879. <link linkend='build-directory'>Build Directory</link>
  6880. causes the build system to create a read-only root filesystem:
  6881. <literallayout class='monospaced'>
  6882. IMAGE_FEATURES = "read-only-rootfs"
  6883. </literallayout>
  6884. or
  6885. <literallayout class='monospaced'>
  6886. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  6887. </literallayout>
  6888. </para>
  6889. <para>
  6890. For more information on how to use these variables, see the
  6891. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  6892. section.
  6893. For information on the variables, see
  6894. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  6895. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  6896. </para>
  6897. </section>
  6898. <section id='post-installation-scripts'>
  6899. <title>Post-Installation Scripts</title>
  6900. <para>
  6901. It is very important that you make sure all
  6902. post-Installation (<filename>pkg_postinst</filename>) scripts
  6903. for packages that are installed into the image can be run
  6904. at the time when the root filesystem is created during the
  6905. build on the host system.
  6906. These scripts cannot attempt to run during first-boot on the
  6907. target device.
  6908. With the "read-only-rootfs" feature enabled,
  6909. the build system checks during root filesystem creation to make
  6910. sure all post-installation scripts succeed.
  6911. If any of these scripts still need to be run after the root
  6912. filesystem is created, the build immediately fails.
  6913. These build-time checks ensure that the build fails
  6914. rather than the target device fails later during its
  6915. initial boot operation.
  6916. </para>
  6917. <para>
  6918. Most of the common post-installation scripts generated by the
  6919. build system for the out-of-the-box Yocto Project are engineered
  6920. so that they can run during root filesystem creation
  6921. (e.g. post-installation scripts for caching fonts).
  6922. However, if you create and add custom scripts, you need
  6923. to be sure they can be run during this file system creation.
  6924. </para>
  6925. <para>
  6926. Here are some common problems that prevent
  6927. post-installation scripts from running during root filesystem
  6928. creation:
  6929. <itemizedlist>
  6930. <listitem><para>
  6931. <emphasis>Not using $D in front of absolute
  6932. paths:</emphasis>
  6933. The build system defines
  6934. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  6935. when the root filesystem is created.
  6936. Furthermore, <filename>$D</filename> is blank when the
  6937. script is run on the target device.
  6938. This implies two purposes for <filename>$D</filename>:
  6939. ensuring paths are valid in both the host and target
  6940. environments, and checking to determine which
  6941. environment is being used as a method for taking
  6942. appropriate actions.
  6943. </para></listitem>
  6944. <listitem><para>
  6945. <emphasis>Attempting to run processes that are
  6946. specific to or dependent on the target
  6947. architecture:</emphasis>
  6948. You can work around these attempts by using native
  6949. tools to accomplish the same tasks, or
  6950. by alternatively running the processes under QEMU,
  6951. which has the <filename>qemu_run_binary</filename>
  6952. function.
  6953. For more information, see the
  6954. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  6955. class.</para></listitem>
  6956. </itemizedlist>
  6957. </para>
  6958. </section>
  6959. <section id='areas-with-write-access'>
  6960. <title>Areas With Write Access</title>
  6961. <para>
  6962. With the "read-only-rootfs" feature enabled,
  6963. any attempt by the target to write to the root filesystem at
  6964. runtime fails.
  6965. Consequently, you must make sure that you configure processes
  6966. and applications that attempt these types of writes do so
  6967. to directories with write access (e.g.
  6968. <filename>/tmp</filename> or <filename>/var/run</filename>).
  6969. </para>
  6970. </section>
  6971. </section>
  6972. <section id="performing-automated-runtime-testing">
  6973. <title>Performing Automated Runtime Testing</title>
  6974. <para>
  6975. The OpenEmbedded build system makes available a series of automated
  6976. tests for images to verify runtime functionality.
  6977. You can run these tests on either QEMU or actual target hardware.
  6978. Tests are written in Python making use of the
  6979. <filename>unittest</filename> module, and the majority of them
  6980. run commands on the target system over SSH.
  6981. This section describes how you set up the environment to use these
  6982. tests, run available tests, and write and add your own tests.
  6983. </para>
  6984. <section id='enabling-tests'>
  6985. <title>Enabling Tests</title>
  6986. <para>
  6987. Depending on whether you are planning to run tests using
  6988. QEMU or on the hardware, you have to take
  6989. different steps to enable the tests.
  6990. See the following subsections for information on how to
  6991. enable both types of tests.
  6992. </para>
  6993. <section id='qemu-image-enabling-tests'>
  6994. <title>Enabling Runtime Tests on QEMU</title>
  6995. <para>
  6996. In order to run tests, you need to do the following:
  6997. <itemizedlist>
  6998. <listitem><para><emphasis>Set up to avoid interaction
  6999. with <filename>sudo</filename> for networking:</emphasis>
  7000. To accomplish this, you must do one of the
  7001. following:
  7002. <itemizedlist>
  7003. <listitem><para>Add
  7004. <filename>NOPASSWD</filename> for your user
  7005. in <filename>/etc/sudoers</filename> either for
  7006. all commands or just for
  7007. <filename>runqemu-ifup</filename>.
  7008. You must provide the full path as that can
  7009. change if you are using multiple clones of the
  7010. source repository.
  7011. <note>
  7012. On some distributions, you also need to
  7013. comment out "Defaults requiretty" in
  7014. <filename>/etc/sudoers</filename>.
  7015. </note></para></listitem>
  7016. <listitem><para>Manually configure a tap interface
  7017. for your system.</para></listitem>
  7018. <listitem><para>Run as root the script in
  7019. <filename>scripts/runqemu-gen-tapdevs</filename>,
  7020. which should generate a list of tap devices.
  7021. This is the option typically chosen for
  7022. Autobuilder-type environments.
  7023. </para></listitem>
  7024. </itemizedlist></para></listitem>
  7025. <listitem><para><emphasis>Set the
  7026. <filename>DISPLAY</filename> variable:</emphasis>
  7027. You need to set this variable so that you have an X
  7028. server available (e.g. start
  7029. <filename>vncserver</filename> for a headless machine).
  7030. </para></listitem>
  7031. <listitem><para><emphasis>Be sure your host's firewall
  7032. accepts incoming connections from
  7033. 192.168.7.0/24:</emphasis>
  7034. Some of the tests (in particular smart tests) start an
  7035. HTTP server on a random high number port, which is
  7036. used to serve files to the target.
  7037. The smart module serves
  7038. <filename>${DEPLOY_DIR}/rpm</filename> so it can run
  7039. smart channel commands. That means your host's firewall
  7040. must accept incoming connections from 192.168.7.0/24,
  7041. which is the default IP range used for tap devices
  7042. by <filename>runqemu</filename>.</para></listitem>
  7043. </itemizedlist>
  7044. </para>
  7045. <para>
  7046. Once you start running the tests, the following happens:
  7047. <orderedlist>
  7048. <listitem><para>A copy of the root filesystem is written
  7049. to <filename>${WORKDIR}/testimage</filename>.
  7050. </para></listitem>
  7051. <listitem><para>The image is booted under QEMU using the
  7052. standard <filename>runqemu</filename> script.
  7053. </para></listitem>
  7054. <listitem><para>A default timeout of 500 seconds occurs
  7055. to allow for the boot process to reach the login prompt.
  7056. You can change the timeout period by setting
  7057. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  7058. in the <filename>local.conf</filename> file.
  7059. </para></listitem>
  7060. <listitem><para>Once the boot process is reached and the
  7061. login prompt appears, the tests run.
  7062. The full boot log is written to
  7063. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  7064. </para></listitem>
  7065. <listitem><para>Each test module loads in the order found
  7066. in <filename>TEST_SUITES</filename>.
  7067. You can find the full output of the commands run over
  7068. SSH in
  7069. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  7070. </para></listitem>
  7071. <listitem><para>If no failures occur, the task running the
  7072. tests ends successfully.
  7073. You can find the output from the
  7074. <filename>unittest</filename> in the task log at
  7075. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  7076. </para></listitem>
  7077. </orderedlist>
  7078. </para>
  7079. </section>
  7080. <section id='hardware-image-enabling-tests'>
  7081. <title>Enabling Runtime Tests on Hardware</title>
  7082. <para>
  7083. The OpenEmbedded build system can run tests on real
  7084. hardware, and for certain devices it can also deploy
  7085. the image to be tested onto the device beforehand.
  7086. </para>
  7087. <para>
  7088. For automated deployment, a "master image" is installed
  7089. onto the hardware once as part of setup.
  7090. Then, each time tests are to be run, the following
  7091. occurs:
  7092. <orderedlist>
  7093. <listitem><para>The master image is booted into and
  7094. used to write the image to be tested to
  7095. a second partition.
  7096. </para></listitem>
  7097. <listitem><para>The device is then rebooted using an
  7098. external script that you need to provide.
  7099. </para></listitem>
  7100. <listitem><para>The device boots into the image to be
  7101. tested.
  7102. </para></listitem>
  7103. </orderedlist>
  7104. </para>
  7105. <para>
  7106. When running tests (independent of whether the image
  7107. has been deployed automatically or not), the device is
  7108. expected to be connected to a network on a
  7109. pre-determined IP address.
  7110. You can either use static IP addresses written into
  7111. the image, or set the image to use DHCP and have your
  7112. DHCP server on the test network assign a known IP address
  7113. based on the MAC address of the device.
  7114. </para>
  7115. <para>
  7116. In order to run tests on hardware, you need to set
  7117. <filename>TEST_TARGET</filename> to an appropriate value.
  7118. For QEMU, you do not have to change anything, the default
  7119. value is "QemuTarget".
  7120. For running tests on hardware, two options exist:
  7121. "SimpleRemoteTarget" and "GummibootTarget".
  7122. <itemizedlist>
  7123. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  7124. Choose "SimpleRemoteTarget" if you are going to
  7125. run tests on a target system that is already
  7126. running the image to be tested and is available
  7127. on the network.
  7128. You can use "SimpleRemoteTarget" in conjunction
  7129. with either real hardware or an image running
  7130. within a separately started QEMU or any
  7131. other virtual machine manager.
  7132. </para></listitem>
  7133. <listitem><para><emphasis>"GummibootTarget":</emphasis>
  7134. Choose "GummibootTarget" if your hardware is
  7135. an EFI-based machine with
  7136. <filename>gummiboot</filename> as bootloader and
  7137. <filename>core-image-testmaster</filename>
  7138. (or something similar) is installed.
  7139. Also, your hardware under test must be in a
  7140. DHCP-enabled network that gives it the same IP
  7141. address for each reboot.</para>
  7142. <para>If you choose "GummibootTarget", there are
  7143. additional requirements and considerations.
  7144. See the
  7145. "<link linkend='selecting-gummiboottarget'>Selecting GummibootTarget</link>"
  7146. section, which follows, for more information.
  7147. </para></listitem>
  7148. </itemizedlist>
  7149. </para>
  7150. </section>
  7151. <section id='selecting-gummiboottarget'>
  7152. <title>Selecting GummibootTarget</title>
  7153. <para>
  7154. If you did not set <filename>TEST_TARGET</filename> to
  7155. "GummibootTarget", then you do not need any information
  7156. in this section.
  7157. You can skip down to the
  7158. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  7159. section.
  7160. </para>
  7161. <para>
  7162. If you did set <filename>TEST_TARGET</filename> to
  7163. "GummibootTarget", you also need to perform a one-time
  7164. setup of your master image by doing the following:
  7165. <orderedlist>
  7166. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  7167. Be sure that <filename>EFI_PROVIDER</filename>
  7168. is as follows:
  7169. <literallayout class='monospaced'>
  7170. EFI_PROVIDER = "gummiboot"
  7171. </literallayout>
  7172. </para></listitem>
  7173. <listitem><para><emphasis>Build the master image:</emphasis>
  7174. Build the <filename>core-image-testmaster</filename>
  7175. image.
  7176. The <filename>core-image-testmaster</filename>
  7177. recipe is provided as an example for a
  7178. "master" image and you can customize the image
  7179. recipe as you would any other recipe.
  7180. </para>
  7181. <para>Here are the image recipe requirements:
  7182. <itemizedlist>
  7183. <listitem><para>Inherits
  7184. <filename>core-image</filename>
  7185. so that kernel modules are installed.
  7186. </para></listitem>
  7187. <listitem><para>Installs normal linux utilities
  7188. not busybox ones (e.g.
  7189. <filename>bash</filename>,
  7190. <filename>coreutils</filename>,
  7191. <filename>tar</filename>,
  7192. <filename>gzip</filename>, and
  7193. <filename>kmod</filename>).
  7194. </para></listitem>
  7195. <listitem><para>Uses a custom
  7196. Initial RAM Disk (initramfs) image with a
  7197. custom installer.
  7198. A normal image that you can install usually
  7199. creates a single rootfs partition.
  7200. This image uses another installer that
  7201. creates a specific partition layout.
  7202. Not all Board Support Packages (BSPs)
  7203. can use an installer.
  7204. For such cases, you need to manually create
  7205. the following partition layout on the
  7206. target:
  7207. <itemizedlist>
  7208. <listitem><para>First partition mounted
  7209. under <filename>/boot</filename>,
  7210. labeled "boot".
  7211. </para></listitem>
  7212. <listitem><para>The main rootfs
  7213. partition where this image gets
  7214. installed, which is mounted under
  7215. <filename>/</filename>.
  7216. </para></listitem>
  7217. <listitem><para>Another partition
  7218. labeled "testrootfs" where test
  7219. images get deployed.
  7220. </para></listitem>
  7221. </itemizedlist>
  7222. </para></listitem>
  7223. </itemizedlist>
  7224. </para></listitem>
  7225. <listitem><para><emphasis>Install image:</emphasis>
  7226. Install the image that you just built on the target
  7227. system.
  7228. </para></listitem>
  7229. </orderedlist>
  7230. </para>
  7231. <para>
  7232. The final thing you need to do when setting
  7233. <filename>TEST_TARGET</filename> to "GummibootTarget" is
  7234. to set up the test image:
  7235. <orderedlist>
  7236. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  7237. Make sure you have the following statements in
  7238. your <filename>local.conf</filename> file:
  7239. <literallayout class='monospaced'>
  7240. IMAGE_FSTYPES += "tar.gz"
  7241. INHERIT += "testimage"
  7242. TEST_TARGET = "GummibootTarget"
  7243. TEST_TARGET_IP = "192.168.2.3"
  7244. </literallayout>
  7245. </para></listitem>
  7246. <listitem><para><emphasis>Build your test image:</emphasis>
  7247. Use BitBake to build the image:
  7248. <literallayout class='monospaced'>
  7249. $ bitbake core-image-sato
  7250. </literallayout>
  7251. </para></listitem>
  7252. </orderedlist>
  7253. </para>
  7254. <para>
  7255. Here is some additional information regarding running
  7256. "GummibootTarget" as your test target:
  7257. <itemizedlist>
  7258. <listitem><para>
  7259. You can use
  7260. <filename>TEST_POWERCONTROL_CMD</filename>
  7261. together with
  7262. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  7263. as a command that runs on the host and does power
  7264. cycling.
  7265. The test code passes one argument to that command:
  7266. off, on or cycle (off then on).
  7267. Here is an example that could appear in your
  7268. <filename>local.conf</filename> file:
  7269. <literallayout class='monospaced'>
  7270. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  7271. </literallayout>
  7272. In this example, the expect script does the
  7273. following:
  7274. <literallayout class='monospaced'>
  7275. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  7276. </literallayout>
  7277. It then runs a Python script that controls power
  7278. for a label called <filename>nuc1</filename>.
  7279. <note>
  7280. You need to customize
  7281. <filename>TEST_POWERCONTROL_CMD</filename>
  7282. and
  7283. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  7284. for your own setup.
  7285. The one requirement is that it accepts
  7286. "on", "off", and "cycle" as the last argument.
  7287. </note>
  7288. </para></listitem>
  7289. <listitem><para>
  7290. When no command is defined, it connects to the
  7291. device over SSH and uses the classic reboot command
  7292. to reboot the device.
  7293. Classic reboot is fine as long as the machine
  7294. actually reboots (i.e. the SSH test has not
  7295. failed).
  7296. It is useful for scenarios where you have a simple
  7297. setup, typically with a single board, and where
  7298. some manual interaction is okay from time to time.
  7299. </para></listitem>
  7300. </itemizedlist>
  7301. </para>
  7302. </section>
  7303. </section>
  7304. <section id="qemu-image-running-tests">
  7305. <title>Running Tests</title>
  7306. <para>
  7307. You can start the tests automatically or manually:
  7308. <itemizedlist>
  7309. <listitem><para><emphasis>Automatically running tests:</emphasis>
  7310. To run the tests automatically after the
  7311. OpenEmbedded build system successfully creates an image,
  7312. first set the
  7313. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink>
  7314. variable to "1" in your <filename>local.conf</filename>
  7315. file in the
  7316. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>:
  7317. <literallayout class='monospaced'>
  7318. TEST_IMAGE = "1"
  7319. </literallayout>
  7320. Next, build your image.
  7321. If the image successfully builds, the tests will be
  7322. run:
  7323. <literallayout class='monospaced'>
  7324. bitbake core-image-sato
  7325. </literallayout></para></listitem>
  7326. <listitem><para><emphasis>Manually running tests:</emphasis>
  7327. To manually run the tests, first globally inherit the
  7328. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage'><filename>testimage</filename></ulink>
  7329. class by editing your <filename>local.conf</filename>
  7330. file:
  7331. <literallayout class='monospaced'>
  7332. INHERIT += "testimage"
  7333. </literallayout>
  7334. Next, use BitBake to run the tests:
  7335. <literallayout class='monospaced'>
  7336. bitbake -c testimage <replaceable>image</replaceable>
  7337. </literallayout></para></listitem>
  7338. </itemizedlist>
  7339. </para>
  7340. <para>
  7341. All test files reside in
  7342. <filename>meta/lib/oeqa/runtime</filename> in the
  7343. <link linkend='source-directory'>Source Directory</link>.
  7344. A test name maps directly to a Python module.
  7345. Each test module may contain a number of individual tests.
  7346. Tests are usually grouped together by the area
  7347. tested (e.g tests for systemd reside in
  7348. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  7349. </para>
  7350. <para>
  7351. You can add tests to any layer provided you place them in the
  7352. proper area and you extend
  7353. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  7354. in the <filename>local.conf</filename> file as normal.
  7355. Be sure that tests reside in
  7356. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  7357. <note>
  7358. Be sure that module names do not collide with module names
  7359. used in the default set of test modules in
  7360. <filename>meta/lib/oeqa/runtime</filename>.
  7361. </note>
  7362. </para>
  7363. <para>
  7364. You can change the set of tests run by appending or overriding
  7365. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  7366. variable in <filename>local.conf</filename>.
  7367. Each name in <filename>TEST_SUITES</filename> represents a
  7368. required test for the image.
  7369. Test modules named within <filename>TEST_SUITES</filename>
  7370. cannot be skipped even if a test is not suitable for an image
  7371. (e.g. running the RPM tests on an image without
  7372. <filename>rpm</filename>).
  7373. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  7374. build system to try to run all tests that are suitable for the
  7375. image (i.e. each test module may elect to skip itself).
  7376. </para>
  7377. <para>
  7378. The order you list tests in <filename>TEST_SUITES</filename>
  7379. is important and influences test dependencies.
  7380. Consequently, tests that depend on other tests should be added
  7381. after the test on which they depend.
  7382. For example, since the <filename>ssh</filename> test
  7383. depends on the
  7384. <filename>ping</filename> test, "ssh" needs to come after
  7385. "ping" in the list.
  7386. The test class provides no re-ordering or dependency handling.
  7387. <note>
  7388. Each module can have multiple classes with multiple test
  7389. methods.
  7390. And, Python <filename>unittest</filename> rules apply.
  7391. </note>
  7392. </para>
  7393. <para>
  7394. Here are some things to keep in mind when running tests:
  7395. <itemizedlist>
  7396. <listitem><para>The default tests for the image are defined
  7397. as:
  7398. <literallayout class='monospaced'>
  7399. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg"
  7400. </literallayout></para></listitem>
  7401. <listitem><para>Add your own test to the list of the
  7402. by using the following:
  7403. <literallayout class='monospaced'>
  7404. TEST_SUITES_append = " mytest"
  7405. </literallayout></para></listitem>
  7406. <listitem><para>Run a specific list of tests as follows:
  7407. <literallayout class='monospaced'>
  7408. TEST_SUITES = "test1 test2 test3"
  7409. </literallayout>
  7410. Remember, order is important.
  7411. Be sure to place a test that is dependent on another test
  7412. later in the order.</para></listitem>
  7413. </itemizedlist>
  7414. </para>
  7415. </section>
  7416. <section id="exporting-tests">
  7417. <title>Exporting Tests</title>
  7418. <para>
  7419. You can export tests so that they can run independently of
  7420. the build system.
  7421. Exporting tests is required if you want to be able to hand
  7422. the test execution off to a scheduler.
  7423. You can only export tests that are defined in
  7424. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  7425. </para>
  7426. <para>
  7427. If your image is already built, make sure the following are set
  7428. in your <filename>local.conf</filename> file.
  7429. Be sure to provide the IP address you need:
  7430. <literallayout class='monospaced'>
  7431. TEST_EXPORT_ONLY = "1"
  7432. TEST_TARGET = "simpleremote"
  7433. TEST_TARGET_IP = "192.168.7.2"
  7434. TEST_SERVER_IP = "192.168.7.1"
  7435. </literallayout>
  7436. You can then export the tests with the following:
  7437. <literallayout class='monospaced'>
  7438. $ bitbake core-image-sato -c testimage
  7439. </literallayout>
  7440. Exporting the tests places them in the
  7441. <link linkend='build-directory'>Build Directory</link> in
  7442. <filename>tmp/testimage/core-image-sato</filename>, which
  7443. is controlled by the
  7444. <filename>TEST_EXPORT_DIR</filename> variable.
  7445. </para>
  7446. <para>
  7447. You can now run the tests outside of the build environment:
  7448. <literallayout class='monospaced'>
  7449. $ cd tmp/testimage/core-image-sato
  7450. $ ./runexported.py testdata.json
  7451. </literallayout>
  7452. <note>
  7453. This "export" feature does not deploy or boot the target
  7454. image.
  7455. Your target (be it a Qemu or hardware one)
  7456. has to already be up and running when you call
  7457. <filename>runexported.py</filename>
  7458. </note>
  7459. </para>
  7460. <para>
  7461. The exported data (i.e. <filename>testdata.json</filename>)
  7462. contains paths to the Build Directory.
  7463. Thus, the contents of the directory can be moved
  7464. to another machine as long as you update some paths in the
  7465. JSON.
  7466. Usually, you only care about the
  7467. <filename>${DEPLOY_DIR}/rpm</filename> directory
  7468. (assuming the RPM and Smart tests are enabled).
  7469. Consequently, running the tests on other machine
  7470. means that you have to move the contents and call
  7471. <filename>runexported.py</filename> with
  7472. "&dash;&dash;deploy-dir <replaceable>path</replaceable>" as
  7473. follows:
  7474. <literallayout class='monospaced'>
  7475. ./runexported.py &dash;&dash;deploy-dir /new/path/on/this/machine testdata.json
  7476. </literallayout>
  7477. <filename>runexported.py</filename> accepts other arguments
  7478. as well as described using <filename>&dash;&dash;help</filename>.
  7479. </para>
  7480. </section>
  7481. <section id="qemu-image-writing-new-tests">
  7482. <title>Writing New Tests</title>
  7483. <para>
  7484. As mentioned previously, all new test files need to be in the
  7485. proper place for the build system to find them.
  7486. New tests for additional functionality outside of the core
  7487. should be added to the layer that adds the functionality, in
  7488. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  7489. (as long as
  7490. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  7491. is extended in the layer's
  7492. <filename>layer.conf</filename> file as normal).
  7493. Just remember that filenames need to map directly to test
  7494. (module) names and that you do not use module names that
  7495. collide with existing core tests.
  7496. </para>
  7497. <para>
  7498. To create a new test, start by copying an existing module
  7499. (e.g. <filename>syslog.py</filename> or
  7500. <filename>gcc.py</filename> are good ones to use).
  7501. Test modules can use code from
  7502. <filename>meta/lib/oeqa/utils</filename>, which are helper
  7503. classes.
  7504. </para>
  7505. <note>
  7506. Structure shell commands such that you rely on them and they
  7507. return a single code for success.
  7508. Be aware that sometimes you will need to parse the output.
  7509. See the <filename>df.py</filename> and
  7510. <filename>date.py</filename> modules for examples.
  7511. </note>
  7512. <para>
  7513. You will notice that all test classes inherit
  7514. <filename>oeRuntimeTest</filename>, which is found in
  7515. <filename>meta/lib/oetest.py</filename>.
  7516. This base class offers some helper attributes, which are
  7517. described in the following sections:
  7518. </para>
  7519. <section id='qemu-image-writing-tests-class-methods'>
  7520. <title>Class Methods</title>
  7521. <para>
  7522. Class methods are as follows:
  7523. <itemizedlist>
  7524. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  7525. Returns "True" if <filename>pkg</filename> is in the
  7526. installed package list of the image, which is based
  7527. on the manifest file that is generated during the
  7528. <filename>do_rootfs</filename> task.
  7529. </para></listitem>
  7530. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  7531. Returns "True" if the feature is in
  7532. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  7533. or
  7534. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  7535. </para></listitem>
  7536. </itemizedlist>
  7537. </para>
  7538. </section>
  7539. <section id='qemu-image-writing-tests-class-attributes'>
  7540. <title>Class Attributes</title>
  7541. <para>
  7542. Class attributes are as follows:
  7543. <itemizedlist>
  7544. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  7545. Equals "ps -ef" if <filename>procps</filename> is
  7546. installed in the image.
  7547. Otherwise, <filename>pscmd</filename> equals
  7548. "ps" (busybox).
  7549. </para></listitem>
  7550. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  7551. The called text context, which gives access to the
  7552. following attributes:
  7553. <itemizedlist>
  7554. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  7555. The BitBake datastore, which allows you to
  7556. use stuff such as
  7557. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  7558. </para></listitem>
  7559. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  7560. Used internally.
  7561. The tests do not need these.
  7562. </para></listitem>
  7563. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  7564. The absolute path to
  7565. <filename>meta/lib/oeqa/runtime/files</filename>,
  7566. which contains helper files for tests meant
  7567. for copying on the target such as small
  7568. files written in C for compilation.
  7569. </para></listitem>
  7570. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  7571. The target controller object used to deploy
  7572. and start an image on a particular target
  7573. (e.g. QemuTarget, SimpleRemote, and
  7574. GummibootTarget).
  7575. Tests usually use the following:
  7576. <itemizedlist>
  7577. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  7578. The target's IP address.
  7579. </para></listitem>
  7580. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  7581. The host's IP address, which is
  7582. usually used by the "smart" test
  7583. suite.
  7584. </para></listitem>
  7585. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  7586. The single, most used method.
  7587. This command is a wrapper for:
  7588. <filename>ssh root@host "cmd"</filename>.
  7589. The command returns a tuple:
  7590. (status, output), which are what
  7591. their names imply - the return code
  7592. of "cmd" and whatever output
  7593. it produces.
  7594. The optional timeout argument
  7595. represents the number of seconds the
  7596. test should wait for "cmd" to
  7597. return.
  7598. If the argument is "None", the
  7599. test uses the default instance's
  7600. timeout period, which is 300
  7601. seconds.
  7602. If the argument is "0", the test
  7603. runs until the command returns.
  7604. </para></listitem>
  7605. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  7606. <filename>scp localpath root@ip:remotepath</filename>.
  7607. </para></listitem>
  7608. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  7609. <filename>scp root@host:remotepath localpath</filename>.
  7610. </para></listitem>
  7611. </itemizedlist></para></listitem>
  7612. </itemizedlist></para></listitem>
  7613. </itemizedlist>
  7614. </para>
  7615. </section>
  7616. <section id='qemu-image-writing-tests-instance-attributes'>
  7617. <title>Instance Attributes</title>
  7618. <para>
  7619. A single instance attribute exists, which is
  7620. <filename>target</filename>.
  7621. The <filename>target</filename> instance attribute is
  7622. identical to the class attribute of the same name, which
  7623. is described in the previous section.
  7624. This attribute exists as both an instance and class
  7625. attribute so tests can use
  7626. <filename>self.target.run(cmd)</filename> in instance
  7627. methods instead of
  7628. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  7629. </para>
  7630. </section>
  7631. </section>
  7632. </section>
  7633. <section id="platdev-gdb-remotedebug">
  7634. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  7635. <para>
  7636. GDB allows you to examine running programs, which in turn helps you to understand and fix problems.
  7637. It also allows you to perform post-mortem style analysis of program crashes.
  7638. GDB is available as a package within the Yocto Project and is
  7639. installed in SDK images by default.
  7640. See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter
  7641. in the Yocto Project Reference Manual for a description of these images.
  7642. You can find information on GDB at <ulink url="http://sourceware.org/gdb/"/>.
  7643. </para>
  7644. <tip>
  7645. For best results, install debug (<filename>-dbg</filename>) packages
  7646. for the applications you are going to debug.
  7647. Doing so makes extra debug symbols available that give you more
  7648. meaningful output.
  7649. </tip>
  7650. <para>
  7651. Sometimes, due to memory or disk space constraints, it is not possible
  7652. to use GDB directly on the remote target to debug applications.
  7653. These constraints arise because GDB needs to load the debugging information and the
  7654. binaries of the process being debugged.
  7655. Additionally, GDB needs to perform many computations to locate information such as function
  7656. names, variable names and values, stack traces and so forth - even before starting the
  7657. debugging process.
  7658. These extra computations place more load on the target system and can alter the
  7659. characteristics of the program being debugged.
  7660. </para>
  7661. <para>
  7662. To help get past the previously mentioned constraints, you can use Gdbserver.
  7663. Gdbserver runs on the remote target and does not load any debugging information
  7664. from the debugged process.
  7665. Instead, a GDB instance processes the debugging information that is run on a
  7666. remote computer - the host GDB.
  7667. The host GDB then sends control commands to Gdbserver to make it stop or start the debugged
  7668. program, as well as read or write memory regions of that debugged program.
  7669. All the debugging information loaded and processed as well
  7670. as all the heavy debugging is done by the host GDB.
  7671. Offloading these processes gives the Gdbserver running on the target a chance to remain
  7672. small and fast.
  7673. <note>
  7674. By default, source files are part of the
  7675. <filename>*-dbg</filename> packages in order to enable GDB
  7676. to show source lines in its output.
  7677. You can save further space on the target by setting the
  7678. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_DEBUG_SPLIT_STYLE'><filename>PACKAGE_DEBUG_SPLIT_STYLE</filename></ulink>
  7679. variable to "debug-without-src" so that these packages do not
  7680. include the source files.
  7681. </note>
  7682. </para>
  7683. <para>
  7684. Because the host GDB is responsible for loading the debugging information and
  7685. for doing the necessary processing to make actual debugging happen,
  7686. you have to make sure the host can access the unstripped binaries complete
  7687. with their debugging information and also be sure the target is compiled with no optimizations.
  7688. The host GDB must also have local access to all the libraries used by the
  7689. debugged program.
  7690. Because Gdbserver does not need any local debugging information, the binaries on
  7691. the remote target can remain stripped.
  7692. However, the binaries must also be compiled without optimization
  7693. so they match the host's binaries.
  7694. </para>
  7695. <para>
  7696. To remain consistent with GDB documentation and terminology, the binary being debugged
  7697. on the remote target machine is referred to as the "inferior" binary.
  7698. For documentation on GDB see the
  7699. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  7700. </para>
  7701. <para>
  7702. The remainder of this section describes the steps you need to take
  7703. to debug using the GNU project debugger.
  7704. </para>
  7705. <section id='platdev-gdb-remotedebug-setup'>
  7706. <title>Set Up the Cross-Development Debugging Environment</title>
  7707. <para>
  7708. Before you can initiate a remote debugging session, you need
  7709. to be sure you have set up the cross-development environment,
  7710. toolchain, and sysroot.
  7711. The "<ulink url='&YOCTO_DOCS_ADT_URL;#adt-prepare'>Preparing for Application Development</ulink>"
  7712. chapter of the Yocto Project Application Developer's Guide
  7713. describes this process.
  7714. Be sure you have read that chapter and have set up
  7715. your environment.
  7716. </para>
  7717. </section>
  7718. <section id="platdev-gdb-remotedebug-launch-gdbserver">
  7719. <title>Launch Gdbserver on the Target</title>
  7720. <para>
  7721. Make sure Gdbserver is installed on the target.
  7722. If it is not, install the package
  7723. <filename>gdbserver</filename>, which needs the
  7724. <filename>libthread-db1</filename> package.
  7725. </para>
  7726. <para>
  7727. Here is an example, that when entered from the host,
  7728. connects to the target and launches Gdbserver in order to
  7729. "debug" a binary named <filename>helloworld</filename>:
  7730. <literallayout class='monospaced'>
  7731. $ gdbserver localhost:2345 /usr/bin/helloworld
  7732. </literallayout>
  7733. Gdbserver should now be listening on port 2345 for debugging
  7734. commands coming from a remote GDB process that is running on
  7735. the host computer.
  7736. Communication between Gdbserver and the host GDB are done
  7737. using TCP.
  7738. To use other communication protocols, please refer to the
  7739. <ulink url='http://www.gnu.org/software/gdb/'>Gdbserver documentation</ulink>.
  7740. </para>
  7741. </section>
  7742. <section id="platdev-gdb-remotedebug-launch-gdb">
  7743. <title>Launch GDB on the Host Computer</title>
  7744. <para>
  7745. Running GDB on the host computer takes a number of stages, which
  7746. this section describes.
  7747. </para>
  7748. <section id="platdev-gdb-remotedebug-launch-gdb-buildcross">
  7749. <title>Build the Cross-GDB Package</title>
  7750. <para>
  7751. A suitable GDB cross-binary is required that runs on your
  7752. host computer but also knows about the the ABI of the
  7753. remote target.
  7754. You can get this binary from the
  7755. <link linkend='cross-development-toolchain'>Cross-Development Toolchain</link>.
  7756. Here is an example where the toolchain has been installed
  7757. in the default directory
  7758. <filename>/opt/poky/&DISTRO;</filename>:
  7759. <literallayout class='monospaced'>
  7760. /opt/poky/&DISTRO;/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb
  7761. </literallayout>
  7762. where <filename>arm</filename> is the target architecture
  7763. and <filename>linux-gnueabi</filename> is the target ABI.
  7764. </para>
  7765. <para>
  7766. Alternatively, you can use BitBake to build the
  7767. <filename>gdb-cross</filename> binary.
  7768. Here is an example:
  7769. <literallayout class='monospaced'>
  7770. $ bitbake gdb-cross
  7771. </literallayout>
  7772. Once the binary is built, you can find it here:
  7773. <literallayout class='monospaced'>
  7774. tmp/sysroots/<replaceable>host-arch</replaceable>/usr/bin/<replaceable>target-platform</replaceable>/<replaceable>target-abi</replaceable>-gdb
  7775. </literallayout>
  7776. </para>
  7777. </section>
  7778. <section id='create-the-gdb-initialization-file'>
  7779. <title>Create the GDB Initialization File and Point to Your Root Filesystem</title>
  7780. <para>
  7781. Aside from the GDB cross-binary, you also need a GDB
  7782. initialization file in the same top directory in which
  7783. your binary resides.
  7784. When you start GDB on your host development system, GDB
  7785. finds this initialization file and executes all the
  7786. commands within.
  7787. For information on the <filename>.gdbinit</filename>, see
  7788. "<ulink url='http://sourceware.org/gdb/onlinedocs/gdb/'>Debugging with GDB</ulink>",
  7789. which is maintained by
  7790. <ulink url='http://www.sourceware.org'>sourceware.org</ulink>.
  7791. </para>
  7792. <para>
  7793. You need to add a statement in the
  7794. <filename>~/.gdbinit</filename> file that points to your
  7795. root filesystem.
  7796. Here is an example that points to the root filesystem for
  7797. an ARM-based target device:
  7798. <literallayout class='monospaced'>
  7799. set sysroot ~/sysroot_arm
  7800. </literallayout>
  7801. </para>
  7802. </section>
  7803. <section id="platdev-gdb-remotedebug-launch-gdb-launchhost">
  7804. <title>Launch the Host GDB</title>
  7805. <para>
  7806. Before launching the host GDB, you need to be sure
  7807. you have sourced the cross-debugging environment script,
  7808. which if you installed the root filesystem in the default
  7809. location is at <filename>/opt/poky/&DISTRO;</filename>
  7810. and begins with the string "environment-setup".
  7811. For more information, see the
  7812. "<ulink url='&YOCTO_DOCS_ADT_URL;#setting-up-the-cross-development-environment'>Setting Up the Cross-Development Environment</ulink>"
  7813. section in the Yocto Project Application Developer's
  7814. Guide.
  7815. </para>
  7816. <para>
  7817. Finally, switch to the directory where the binary resides
  7818. and run the <filename>cross-gdb</filename> binary.
  7819. Provide the binary file you are going to debug.
  7820. For example, the following command continues with the
  7821. example used in the previous section by loading
  7822. the <filename>helloworld</filename> binary as well as the
  7823. debugging information:
  7824. <literallayout class='monospaced'>
  7825. $ arm-poky-linux-gnuabi-gdb helloworld
  7826. </literallayout>
  7827. The commands in your <filename>.gdbinit</filename> execute
  7828. and the GDB prompt appears.
  7829. </para>
  7830. </section>
  7831. </section>
  7832. <section id='platdev-gdb-connect-to-the-remote-gdb-server'>
  7833. <title>Connect to the Remote GDB Server</title>
  7834. <para>
  7835. From the target, you need to connect to the remote GDB
  7836. server that is running on the host.
  7837. You need to specify the remote host and port.
  7838. Here is the command continuing with the example:
  7839. <literallayout class='monospaced'>
  7840. target remote 192.168.7.2:2345
  7841. </literallayout>
  7842. </para>
  7843. </section>
  7844. <section id="platdev-gdb-remotedebug-launch-gdb-using">
  7845. <title>Use the Debugger</title>
  7846. <para>
  7847. You can now proceed with debugging as normal - as if you were debugging
  7848. on the local machine.
  7849. For example, to instruct GDB to break in the "main" function and then
  7850. continue with execution of the inferior binary use the following commands
  7851. from within GDB:
  7852. <literallayout class='monospaced'>
  7853. (gdb) break main
  7854. (gdb) continue
  7855. </literallayout>
  7856. </para>
  7857. <para>
  7858. For more information about using GDB, see the project's online documentation at
  7859. <ulink url="http://sourceware.org/gdb/download/onlinedocs/"/>.
  7860. </para>
  7861. </section>
  7862. </section>
  7863. <section id='debugging-parallel-make-races'>
  7864. <title>Debugging Parallel Make Races</title>
  7865. <para>
  7866. A parallel <filename>make</filename> race occurs when the build
  7867. consists of several parts that are run simultaneously and
  7868. a situation occurs when the output or result of one
  7869. part is not ready for use with a different part of the build that
  7870. depends on that output.
  7871. Parallel make races are annoying and can sometimes be difficult
  7872. to reproduce and fix.
  7873. However, some simple tips and tricks exist that can help
  7874. you debug and fix them.
  7875. This section presents a real-world example of an error encountered
  7876. on the Yocto Project autobuilder and the process used to fix it.
  7877. </para>
  7878. <section id='the-failure'>
  7879. <title>The Failure</title>
  7880. <para>
  7881. For this example, assume that you are building an image that
  7882. depends on the "neard" package.
  7883. And, during the build, BitBake runs into problems and
  7884. creates the following output.
  7885. <note>
  7886. This example log file has longer lines artificially
  7887. broken to make the listing easier to read.
  7888. </note>
  7889. If you examine the output or the log file, you see the
  7890. failure during <filename>make</filename>:
  7891. <literallayout class='monospaced'>
  7892. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  7893. | DEBUG: Executing shell function do_compile
  7894. | NOTE: make -j 16
  7895. | make &dash;&dash;no-print-directory all-am
  7896. | /bin/mkdir -p include/near
  7897. | /bin/mkdir -p include/near
  7898. | /bin/mkdir -p include/near
  7899. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7900. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  7901. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7902. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  7903. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7904. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  7905. | /bin/mkdir -p include/near
  7906. | /bin/mkdir -p include/near
  7907. | /bin/mkdir -p include/near
  7908. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7909. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  7910. | /bin/mkdir -p include/near
  7911. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7912. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  7913. | /bin/mkdir -p include/near
  7914. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7915. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  7916. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7917. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  7918. | /bin/mkdir -p include/near
  7919. | /bin/mkdir -p include/near
  7920. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7921. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  7922. | /bin/mkdir -p include/near
  7923. | /bin/mkdir -p include/near
  7924. | /bin/mkdir -p include/near
  7925. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7926. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  7927. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7928. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  7929. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7930. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  7931. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7932. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  7933. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7934. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  7935. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  7936. | i586-poky-linux-gcc -m32 -march=i586 &dash;&dash;sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  7937. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  7938. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  7939. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  7940. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  7941. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  7942. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  7943. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  7944. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  7945. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  7946. -o tools/snep-send.o tools/snep-send.c
  7947. | In file included from tools/snep-send.c:16:0:
  7948. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  7949. | #include &lt;near/dbus.h&gt;
  7950. | ^
  7951. | compilation terminated.
  7952. | make[1]: *** [tools/snep-send.o] Error 1
  7953. | make[1]: *** Waiting for unfinished jobs....
  7954. | make: *** [all] Error 2
  7955. | ERROR: oe_runmake failed
  7956. </literallayout>
  7957. </para>
  7958. </section>
  7959. <section id='reproducing-the-error'>
  7960. <title>Reproducing the Error</title>
  7961. <para>
  7962. Because race conditions are intermittent, they do not
  7963. manifest themselves every time you do the build.
  7964. In fact, most times the build will complete without problems
  7965. even though the potential race condition exists.
  7966. Thus, once the error surfaces, you need a way to reproduce it.
  7967. </para>
  7968. <para>
  7969. In this example, compiling the "neard" package is causing the
  7970. problem.
  7971. So the first thing to do is build "neard" locally.
  7972. Before you start the build, set the
  7973. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  7974. variable in your <filename>local.conf</filename> file to
  7975. a high number (e.g. "-j 20").
  7976. Using a high value for <filename>PARALLEL_MAKE</filename>
  7977. increases the chances of the race condition showing up:
  7978. <literallayout class='monospaced'>
  7979. $ bitbake neard
  7980. </literallayout>
  7981. </para>
  7982. <para>
  7983. Once the local build for "neard" completes, start a
  7984. <filename>devshell</filename> build:
  7985. <literallayout class='monospaced'>
  7986. $ bitbake neard -c devshell
  7987. </literallayout>
  7988. For information on how to use a
  7989. <filename>devshell</filename>, see the
  7990. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  7991. section.
  7992. </para>
  7993. <para>
  7994. In the <filename>devshell</filename>, do the following:
  7995. <literallayout class='monospaced'>
  7996. $ make clean
  7997. $ make tools/snep-send.o
  7998. </literallayout>
  7999. The <filename>devshell</filename> commands cause the failure
  8000. to clearly be visible.
  8001. In this case, a missing dependency exists for the "neard"
  8002. Makefile target.
  8003. Here is some abbreviated, sample output with the
  8004. missing dependency clearly visible at the end:
  8005. <literallayout class='monospaced'>
  8006. i586-poky-linux-gcc -m32 -march=i586 &dash;&dash;sysroot=/home/scott-lenovo/......
  8007. .
  8008. .
  8009. .
  8010. tools/snep-send.c
  8011. In file included from tools/snep-send.c:16:0:
  8012. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  8013. #include &lt;near/dbus.h&gt;
  8014. ^
  8015. compilation terminated.
  8016. make: *** [tools/snep-send.o] Error 1
  8017. $
  8018. </literallayout>
  8019. </para>
  8020. </section>
  8021. <section id='creating-a-patch-for-the-fix'>
  8022. <title>Creating a Patch for the Fix</title>
  8023. <para>
  8024. Because there is a missing dependency for the Makefile
  8025. target, you need to patch the
  8026. <filename>Makefile.am</filename> file, which is generated
  8027. from <filename>Makefile.in</filename>.
  8028. You can use Quilt to create the patch:
  8029. <literallayout class='monospaced'>
  8030. $ quilt new parallelmake.patch
  8031. Patch patches/parallelmake.patch is now on top
  8032. $ quilt add Makefile.am
  8033. File Makefile.am added to patch patches/parallelmake.patch
  8034. </literallayout>
  8035. For more information on using Quilt, see the
  8036. "<link linkend='using-a-quilt-workflow'>Using a Quilt Workflow</link>"
  8037. section.
  8038. </para>
  8039. <para>
  8040. At this point you need to make the edits to
  8041. <filename>Makefile.am</filename> to add the missing
  8042. dependency.
  8043. For our example, you have to add the following line
  8044. to the file:
  8045. <literallayout class='monospaced'>
  8046. tools/snep-send.$(OBJEXT): include/near/dbus.h
  8047. </literallayout>
  8048. </para>
  8049. <para>
  8050. Once you have edited the file, use the
  8051. <filename>refresh</filename> command to create the patch:
  8052. <literallayout class='monospaced'>
  8053. $ quilt refresh
  8054. Refreshed patch patches/parallelmake.patch
  8055. </literallayout>
  8056. Once the patch file exists, you need to add it back to the
  8057. originating recipe folder.
  8058. Here is an example assuming a top-level
  8059. <link linkend='source-directory'>Source Directory</link>
  8060. named <filename>poky</filename>:
  8061. <literallayout class='monospaced'>
  8062. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  8063. </literallayout>
  8064. The final thing you need to do to implement the fix in the
  8065. build is to update the "neard" recipe (i.e.
  8066. <filename>neard-0.14.bb</filename>) so that the
  8067. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  8068. statement includes the patch file.
  8069. The recipe file is in the folder above the patch.
  8070. Here is what the edited <filename>SRC_URI</filename>
  8071. statement would look like:
  8072. <literallayout class='monospaced'>
  8073. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  8074. file://neard.in \
  8075. file://neard.service.in \
  8076. file://parallelmake.patch \
  8077. "
  8078. </literallayout>
  8079. </para>
  8080. <para>
  8081. With the patch complete and moved to the correct folder and
  8082. the <filename>SRC_URI</filename> statement updated, you can
  8083. exit the <filename>devshell</filename>:
  8084. <literallayout class='monospaced'>
  8085. $ exit
  8086. </literallayout>
  8087. </para>
  8088. </section>
  8089. <section id='testing-the-build'>
  8090. <title>Testing the Build</title>
  8091. <para>
  8092. With everything in place, you can get back to trying the
  8093. build again locally:
  8094. <literallayout class='monospaced'>
  8095. $ bitbake neard
  8096. </literallayout>
  8097. This build should succeed.
  8098. </para>
  8099. <para>
  8100. Now you can open up a <filename>devshell</filename> again
  8101. and repeat the clean and make operations as follows:
  8102. <literallayout class='monospaced'>
  8103. $ bitbake neard -c devshell
  8104. $ make clean
  8105. $ make tools/snep-send.o
  8106. </literallayout>
  8107. The build should work without issue.
  8108. </para>
  8109. <para>
  8110. As with all solved problems, if they originated upstream, you
  8111. need to submit the fix for the recipe in OE-Core and upstream
  8112. so that the problem is taken care of at its source.
  8113. See the
  8114. "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>"
  8115. section for more information.
  8116. </para>
  8117. </section>
  8118. </section>
  8119. <section id="examining-builds-using-toaster">
  8120. <title>Examining Builds Using the Toaster API</title>
  8121. <para>
  8122. Toaster is an Application Programming Interface (API) and
  8123. web-based interface to the OpenEmbedded build system, which uses
  8124. BitBake.
  8125. Both interfaces are based on a Representational State Transfer
  8126. (REST) API that queries for and returns build information using
  8127. <filename>GET</filename> and <filename>JSON</filename>.
  8128. These types of search operations retrieve sets of objects from
  8129. a datastore used to collect build information.
  8130. The results contain all the data for the objects being returned.
  8131. You can order the results of the search by key and the search
  8132. parameters are consistent for all object types.
  8133. </para>
  8134. <para>
  8135. Using the interfaces you can do the following:
  8136. <itemizedlist>
  8137. <listitem><para>See information about the tasks executed
  8138. and reused during the build.</para></listitem>
  8139. <listitem><para>See what is built (recipes and
  8140. packages) and what packages were installed into the final
  8141. image.</para></listitem>
  8142. <listitem><para>See performance-related information such
  8143. as build time, CPU usage, and disk I/O.</para></listitem>
  8144. <listitem><para>Examine error, warning and trace messages
  8145. to aid in debugging.</para></listitem>
  8146. </itemizedlist>
  8147. </para>
  8148. <note>
  8149. <para>This release of Toaster provides you with information
  8150. about a BitBake run.
  8151. The tool does not allow you to configure and launch a build.
  8152. However, future development includes plans to integrate the
  8153. configuration and build launching capabilities of
  8154. <ulink url='&YOCTO_HOME_URL;/tools-resources/projects/hob'>Hob</ulink>.
  8155. </para>
  8156. <para>For more information on using Hob to build an image,
  8157. see the
  8158. "<link linkend='image-development-using-hob'>Image Development Using Hob</link>"
  8159. section.</para>
  8160. </note>
  8161. <para>
  8162. The remainder of this section describes what you need to have in
  8163. place to use Toaster, how to start it, use it, and stop it.
  8164. For additional information on installing and running Toaster, see the
  8165. "<ulink url='https://wiki.yoctoproject.org/wiki/Toaster#Installation_and_Running'>Installation and Running</ulink>"
  8166. section of the "Toaster" wiki page.
  8167. For complete information on the API and its search operation
  8168. URI, parameters, and responses, see the
  8169. <ulink url='https://wiki.yoctoproject.org/wiki/REST_API_Contracts'>REST API Contracts</ulink>
  8170. Wiki page.
  8171. </para>
  8172. <section id='starting-toaster'>
  8173. <title>Starting Toaster</title>
  8174. <para>
  8175. Getting set up to use and start Toaster is simple.
  8176. First, be sure you have met the following requirements:
  8177. <itemizedlist>
  8178. <listitem><para>You have set up your
  8179. <link linkend='source-directory'>Source Directory</link>
  8180. by cloning the upstream <filename>poky</filename>
  8181. repository.
  8182. See the
  8183. <link linkend='local-yp-release'>Yocto Project Release</link>
  8184. item for information on how to set up the Source
  8185. Directory.</para></listitem>
  8186. <listitem><para>Be sure your build machine has
  8187. <ulink url='http://en.wikipedia.org/wiki/Django_%28web_framework%29'>Django</ulink>
  8188. version 1.5 installed.</para></listitem>
  8189. <listitem><para>Make sure that port 8000 and 8200 are
  8190. free (i.e. they have no servers on them).
  8191. </para></listitem>
  8192. </itemizedlist>
  8193. </para>
  8194. <para>
  8195. Once you have met the requirements, follow these steps to
  8196. start Toaster running in the background of your shell:
  8197. <orderedlist>
  8198. <listitem><para><emphasis>Set up your build environment:</emphasis>
  8199. Source a build environment script (i.e.
  8200. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  8201. or
  8202. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>).
  8203. </para></listitem>
  8204. <listitem><para><emphasis>Start Toaster:</emphasis>
  8205. Start the Toaster service using this
  8206. command from within your
  8207. <link linkend='build-directory'>Build Directory</link>:
  8208. <literallayout class='monospaced'>
  8209. $ source toaster start
  8210. </literallayout></para></listitem>
  8211. <note>
  8212. The Toaster must be started and running in order
  8213. for it to collect data.
  8214. </note>
  8215. </orderedlist>
  8216. </para>
  8217. <para>
  8218. When Toaster starts, it creates some additional files in your
  8219. Build Directory.
  8220. Deleting these files will cause you to lose data or interrupt
  8221. Toaster:
  8222. <itemizedlist>
  8223. <listitem><para><emphasis><filename>toaster.sqlite</filename>:</emphasis>
  8224. Toaster's database file.</para></listitem>
  8225. <listitem><para><emphasis><filename>toaster_web.log</filename>:</emphasis>
  8226. The log file of the web server.</para></listitem>
  8227. <listitem><para><emphasis><filename>toaster_ui.log</filename>:</emphasis>
  8228. The log file of the user interface component.
  8229. </para></listitem>
  8230. <listitem><para><emphasis><filename>toastermain.pid</filename>:</emphasis>
  8231. The PID of the web server.</para></listitem>
  8232. <listitem><para><emphasis><filename>toasterui.pid</filename>:</emphasis>
  8233. The PID of the DSI data bridge.</para></listitem>
  8234. <listitem><para><emphasis><filename>bitbake-cookerdaemon.log</filename>:</emphasis>
  8235. The BitBake server's log file.</para></listitem>
  8236. </itemizedlist>
  8237. </para>
  8238. </section>
  8239. <section id='using-toaster'>
  8240. <title>Using Toaster</title>
  8241. <para>
  8242. Once Toaster is running, it logs information for any BitBake
  8243. run from your Build Directory.
  8244. This logging is automatic.
  8245. All you need to do is access and use the information.
  8246. </para>
  8247. <para>
  8248. You access the information one of two ways:
  8249. <itemizedlist>
  8250. <listitem><para>Open a Browser and enter
  8251. <filename>http://localhost:8000</filename>
  8252. for the URL.
  8253. </para></listitem>
  8254. <listitem><para>Use the <filename>xdg-open</filename>
  8255. tool from the shell and pass it the same URL.
  8256. </para></listitem>
  8257. </itemizedlist>
  8258. Either method opens the home page for the Toaster interface.
  8259. </para>
  8260. <note><title>Notes</title>
  8261. <itemizedlist>
  8262. <listitem><para>
  8263. For information on how to delete information from the
  8264. Toaster database, see the
  8265. <ulink url='https://wiki.yoctoproject.org/wiki/Toaster#Deleting_a_Build_from_the_Toaster_Database'>Deleting a Build from the Toaster Database</ulink>
  8266. wiki page.
  8267. </para></listitem>
  8268. <listitem><para>
  8269. For information on how to set up an instance of Toaster
  8270. on a remote host, see the
  8271. <ulink url='https://wiki.yoctoproject.org/wiki/Toaster#Setting_up_a_Toaster_Instance_on_a_Remote_Host'>Setting Up a Toaster Instance on a Remote Host</ulink>
  8272. wiki page.
  8273. </para></listitem>
  8274. </itemizedlist>
  8275. </note>
  8276. </section>
  8277. <section id='examining-toaster-data'>
  8278. <title>Examining Toaster Data</title>
  8279. <para>
  8280. The Toaster database is persistent regardless of whether you
  8281. start or stop the service.
  8282. </para>
  8283. <para>
  8284. Toaster's interface shows you a list of builds
  8285. (successful and unsuccessful) for which it has data.
  8286. You can click on any build to see related information.
  8287. This information includes configuration details, information
  8288. about tasks, all recipes and packages built and their
  8289. dependencies, packages and their directory structure as
  8290. installed in your final image,
  8291. execution time, CPU usage and disk I/O per task.
  8292. </para>
  8293. <para>
  8294. For details on the interface, see the
  8295. <ulink url='https://www.yoctoproject.org/documentation/toaster-manual'>Toaster Manual</ulink>.
  8296. </para>
  8297. </section>
  8298. <section id='stopping-toaster'>
  8299. <title>Stopping Toaster</title>
  8300. <para>
  8301. Stop the Toaster service with the following command
  8302. from with the
  8303. <link linkend='build-directory'>Build Directory</link>:
  8304. <literallayout class='monospaced'>
  8305. $ source toaster stop
  8306. </literallayout>
  8307. The service stops but the Toaster database remains persistent.
  8308. </para>
  8309. </section>
  8310. </section>
  8311. <section id="platdev-oprofile">
  8312. <title>Profiling with OProfile</title>
  8313. <para>
  8314. <ulink url="http://oprofile.sourceforge.net/">OProfile</ulink> is a
  8315. statistical profiler well suited for finding performance
  8316. bottlenecks in both user-space software and in the kernel.
  8317. This profiler provides answers to questions like "Which functions does my application spend
  8318. the most time in when doing X?"
  8319. Because the OpenEmbedded build system is well integrated with OProfile, it makes profiling
  8320. applications on target hardware straight forward.
  8321. <note>
  8322. For more information on how to set up and run OProfile, see the
  8323. "<ulink url='&YOCTO_DOCS_PROF_URL;#profile-manual-oprofile'>oprofile</ulink>"
  8324. section in the Yocto Project Profiling and Tracing Manual.
  8325. </note>
  8326. </para>
  8327. <para>
  8328. To use OProfile, you need an image that has OProfile installed.
  8329. The easiest way to do this is with "tools-profile" in the
  8330. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'>IMAGE_FEATURES</ulink></filename> variable.
  8331. You also need debugging symbols to be available on the system where the analysis
  8332. takes place.
  8333. You can gain access to the symbols by using "dbg-pkgs" in the
  8334. <filename>IMAGE_FEATURES</filename> variable or by
  8335. installing the appropriate debug (<filename>-dbg</filename>)
  8336. packages.
  8337. </para>
  8338. <para>
  8339. For successful call graph analysis, the binaries must preserve the frame
  8340. pointer register and should also be compiled with the
  8341. <filename>-fno-omit-framepointer</filename> flag.
  8342. You can achieve this by setting the
  8343. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SELECTED_OPTIMIZATION'>SELECTED_OPTIMIZATION</ulink></filename>
  8344. variable with the following options:
  8345. <literallayout class='monospaced'>
  8346. -fexpensive-optimizations
  8347. -fno-omit-framepointer
  8348. -frename-registers
  8349. -O2
  8350. </literallayout>
  8351. You can also achieve it by setting the
  8352. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_BUILD'>DEBUG_BUILD</ulink></filename>
  8353. variable to "1" in the <filename>local.conf</filename> configuration file.
  8354. If you use the <filename>DEBUG_BUILD</filename> variable,
  8355. you also add extra debugging information that can make the debug
  8356. packages large.
  8357. </para>
  8358. <section id="platdev-oprofile-target">
  8359. <title>Profiling on the Target</title>
  8360. <para>
  8361. Using OProfile, you can perform all the profiling work on the target device.
  8362. A simple OProfile session might look like the following:
  8363. </para>
  8364. <para>
  8365. <literallayout class='monospaced'>
  8366. # opcontrol &dash;&dash;reset
  8367. # opcontrol &dash;&dash;start &dash;&dash;separate=lib &dash;&dash;no-vmlinux -c 5
  8368. .
  8369. .
  8370. [do whatever is being profiled]
  8371. .
  8372. .
  8373. # opcontrol &dash;&dash;stop
  8374. $ opreport -cl
  8375. </literallayout>
  8376. </para>
  8377. <para>
  8378. In this example, the <filename>reset</filename> command clears any previously profiled data.
  8379. The next command starts OProfile.
  8380. The options used when starting the profiler separate dynamic library data
  8381. within applications, disable kernel profiling, and enable callgraphing up to
  8382. five levels deep.
  8383. <note>
  8384. To profile the kernel, you would specify the
  8385. <filename>&dash;&dash;vmlinux=/path/to/vmlinux</filename> option.
  8386. The <filename>vmlinux</filename> file is usually in the source directory in the
  8387. <filename>/boot/</filename> directory and must match the running kernel.
  8388. </note>
  8389. </para>
  8390. <para>
  8391. After you perform your profiling tasks, the next command stops the profiler.
  8392. After that, you can view results with the <filename>opreport</filename> command with options
  8393. to see the separate library symbols and callgraph information.
  8394. </para>
  8395. <para>
  8396. Callgraphing logs information about time spent in functions and about a function's
  8397. calling function (parent) and called functions (children).
  8398. The higher the callgraphing depth, the more accurate the results.
  8399. However, higher depths also increase the logging overhead.
  8400. Consequently, you should take care when setting the callgraphing depth.
  8401. <note>
  8402. On ARM, binaries need to have the frame pointer enabled for callgraphing to work.
  8403. To accomplish this use the <filename>-fno-omit-framepointer</filename> option
  8404. with <filename>gcc</filename>.
  8405. </note>
  8406. </para>
  8407. <para>
  8408. For more information on using OProfile, see the OProfile
  8409. online documentation at
  8410. <ulink url="http://oprofile.sourceforge.net/docs/"/>.
  8411. </para>
  8412. </section>
  8413. <section id="platdev-oprofile-oprofileui">
  8414. <title>Using OProfileUI</title>
  8415. <para>
  8416. A graphical user interface for OProfile is also available.
  8417. You can download and build this interface from the Yocto Project at
  8418. <ulink url="&YOCTO_GIT_URL;/cgit.cgi/oprofileui/"></ulink>.
  8419. If the "tools-profile" image feature is selected, all necessary binaries
  8420. are installed onto the target device for OProfileUI interaction.
  8421. For a list of image features that ship with the Yocto Project,
  8422. see the
  8423. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-features-image'>Image Features</ulink>"
  8424. section in the Yocto Project Reference Manual.
  8425. </para>
  8426. <para>
  8427. Even though the source directory usually includes all needed patches on the target device, you
  8428. might find you need other OProfile patches for recent OProfileUI features.
  8429. If so, see the <ulink url='&YOCTO_GIT_URL;/cgit.cgi/oprofileui/tree/README'>
  8430. OProfileUI README</ulink> for the most recent information.
  8431. </para>
  8432. <section id="platdev-oprofile-oprofileui-online">
  8433. <title>Online Mode</title>
  8434. <para>
  8435. Using OProfile in online mode assumes a working network connection with the target
  8436. hardware.
  8437. With this connection, you just need to run "oprofile-server" on the device.
  8438. By default, OProfile listens on port 4224.
  8439. <note>
  8440. You can change the port using the <filename>&dash;&dash;port</filename> command-line
  8441. option.
  8442. </note>
  8443. </para>
  8444. <para>
  8445. The client program is called <filename>oprofile-viewer</filename> and its UI is relatively
  8446. straight forward.
  8447. You access key functionality through the buttons on the toolbar, which
  8448. are duplicated in the menus.
  8449. Here are the buttons:
  8450. <itemizedlist>
  8451. <listitem><para><emphasis>Connect:</emphasis> Connects to the remote host.
  8452. You can also supply the IP address or hostname.</para></listitem>
  8453. <listitem><para><emphasis>Disconnect:</emphasis> Disconnects from the target.
  8454. </para></listitem>
  8455. <listitem><para><emphasis>Start:</emphasis> Starts profiling on the device.
  8456. </para></listitem>
  8457. <listitem><para><emphasis>Stop:</emphasis> Stops profiling on the device and
  8458. downloads the data to the local host.
  8459. Stopping the profiler generates the profile and displays it in the viewer.
  8460. </para></listitem>
  8461. <listitem><para><emphasis>Download:</emphasis> Downloads the data from the
  8462. target and generates the profile, which appears in the viewer.</para></listitem>
  8463. <listitem><para><emphasis>Reset:</emphasis> Resets the sample data on the device.
  8464. Resetting the data removes sample information collected from previous
  8465. sampling runs.
  8466. Be sure you reset the data if you do not want to include old sample information.
  8467. </para></listitem>
  8468. <listitem><para><emphasis>Save:</emphasis> Saves the data downloaded from the
  8469. target to another directory for later examination.</para></listitem>
  8470. <listitem><para><emphasis>Open:</emphasis> Loads previously saved data.
  8471. </para></listitem>
  8472. </itemizedlist>
  8473. </para>
  8474. <para>
  8475. The client downloads the complete profile archive from
  8476. the target to the host for processing.
  8477. This archive is a directory that contains the sample data, the object files,
  8478. and the debug information for the object files.
  8479. The archive is then converted using the <filename>oparchconv</filename> script, which is
  8480. included in this distribution.
  8481. The script uses <filename>opimport</filename> to convert the archive from
  8482. the target to something that can be processed on the host.
  8483. </para>
  8484. <para>
  8485. Downloaded archives reside in the
  8486. <link linkend='build-directory'>Build Directory</link> in
  8487. <filename>tmp</filename> and are cleared up when they are no longer in use.
  8488. </para>
  8489. <para>
  8490. If you wish to perform kernel profiling, you need to be sure
  8491. a <filename>vmlinux</filename> file that matches the running kernel is available.
  8492. In the source directory, that file is usually located in
  8493. <filename>/boot/vmlinux-<replaceable>kernelversion</replaceable></filename>, where
  8494. <filename><replaceable>kernelversion</replaceable></filename> is the version of the kernel.
  8495. The OpenEmbedded build system generates separate <filename>vmlinux</filename>
  8496. packages for each kernel it builds.
  8497. Thus, it should just be a question of making sure a matching package is
  8498. installed (e.g. <filename>opkg install kernel-vmlinux</filename>).
  8499. The files are automatically installed into development and profiling images
  8500. alongside OProfile.
  8501. A configuration option exists within the OProfileUI settings page that you can use to
  8502. enter the location of the <filename>vmlinux</filename> file.
  8503. </para>
  8504. <para>
  8505. Waiting for debug symbols to transfer from the device can be slow, and it
  8506. is not always necessary to actually have them on the device for OProfile use.
  8507. All that is needed is a copy of the filesystem with the debug symbols present
  8508. on the viewer system.
  8509. The "<link linkend='platdev-gdb-remotedebug-launch-gdb'>Launch GDB on the Host Computer</link>"
  8510. section covers how to create such a directory within
  8511. the source directory and how to use the OProfileUI Settings
  8512. Dialog to specify the location.
  8513. If you specify the directory, it will be used when the file checksums
  8514. match those on the system you are profiling.
  8515. </para>
  8516. </section>
  8517. <section id="platdev-oprofile-oprofileui-offline">
  8518. <title>Offline Mode</title>
  8519. <para>
  8520. If network access to the target is unavailable, you can generate
  8521. an archive for processing in <filename>oprofile-viewer</filename> as follows:
  8522. <literallayout class='monospaced'>
  8523. # opcontrol &dash;&dash;reset
  8524. # opcontrol &dash;&dash;start &dash;&dash;separate=lib &dash;&dash;no-vmlinux -c 5
  8525. .
  8526. .
  8527. [do whatever is being profiled]
  8528. .
  8529. .
  8530. # opcontrol &dash;&dash;stop
  8531. # oparchive -o my_archive
  8532. </literallayout>
  8533. </para>
  8534. <para>
  8535. In the above example, <filename>my_archive</filename> is the name of the
  8536. archive directory where you would like the profile archive to be kept.
  8537. After the directory is created, you can copy it to another host and load it
  8538. using <filename>oprofile-viewer</filename> open functionality.
  8539. If necessary, the archive is converted.
  8540. </para>
  8541. </section>
  8542. </section>
  8543. </section>
  8544. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  8545. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  8546. <para>
  8547. One of the concerns for a development organization using open source
  8548. software is how to maintain compliance with various open source
  8549. licensing during the lifecycle of the product.
  8550. While this section does not provide legal advice or
  8551. comprehensively cover all scenarios, it does
  8552. present methods that you can use to
  8553. assist you in meeting the compliance requirements during a software
  8554. release.
  8555. </para>
  8556. <para>
  8557. With hundreds of different open source licenses that the Yocto
  8558. Project tracks, it is difficult to know the requirements of each
  8559. and every license.
  8560. However, the requirements of the major FLOSS licenses can begin
  8561. to be covered by
  8562. assuming that three main areas of concern exist:
  8563. <itemizedlist>
  8564. <listitem><para>Source code must be provided.</para></listitem>
  8565. <listitem><para>License text for the software must be
  8566. provided.</para></listitem>
  8567. <listitem><para>Compilation scripts and modifications to the
  8568. source code must be provided.
  8569. </para></listitem>
  8570. </itemizedlist>
  8571. There are other requirements beyond the scope of these
  8572. three and the methods described in this section
  8573. (e.g. the mechanism through which source code is distributed).
  8574. </para>
  8575. <para>
  8576. As different organizations have different methods of complying with
  8577. open source licensing, this section is not meant to imply that
  8578. there is only one single way to meet your compliance obligations,
  8579. but rather to describe one method of achieving compliance.
  8580. The remainder of this section describes methods supported to meet the
  8581. previously mentioned three requirements.
  8582. Once you take steps to meet these requirements,
  8583. and prior to releasing images, sources, and the build system,
  8584. you should audit all artifacts to ensure completeness.
  8585. <note>
  8586. The Yocto Project generates a license manifest during
  8587. image creation that is located
  8588. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  8589. to assist with any audits.
  8590. </note>
  8591. </para>
  8592. <section id='providing-the-source-code'>
  8593. <title>Providing the Source Code</title>
  8594. <para>
  8595. Compliance activities should begin before you generate the
  8596. final image.
  8597. The first thing you should look at is the requirement that
  8598. tops the list for most compliance groups - providing
  8599. the source.
  8600. The Yocto Project has a few ways of meeting this
  8601. requirement.
  8602. </para>
  8603. <para>
  8604. One of the easiest ways to meet this requirement is
  8605. to provide the entire
  8606. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  8607. used by the build.
  8608. This method, however, has a few issues.
  8609. The most obvious is the size of the directory since it includes
  8610. all sources used in the build and not just the source used in
  8611. the released image.
  8612. It will include toolchain source, and other artifacts, which
  8613. you would not generally release.
  8614. However, the more serious issue for most companies is accidental
  8615. release of proprietary software.
  8616. The Yocto Project provides an
  8617. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  8618. class to help avoid some of these concerns.
  8619. </para>
  8620. <para>
  8621. Before you employ <filename>DL_DIR</filename> or the
  8622. archiver class, you need to decide how you choose to
  8623. provide source.
  8624. The source archiver class can generate tarballs and SRPMs
  8625. and can create them with various levels of compliance in mind.
  8626. </para>
  8627. <para>
  8628. One way of doing this (but certainly not the only way) is to
  8629. release just the source as a tarball.
  8630. You can do this by adding the following to the
  8631. <filename>local.conf</filename> file found in the
  8632. <link linkend='build-directory'>Build Directory</link>:
  8633. <literallayout class='monospaced'>
  8634. INHERIT += "archiver"
  8635. ARCHIVER_MODE[src] = "original"
  8636. </literallayout>
  8637. During the creation of your image, the source from all
  8638. recipes that deploy packages to the image is placed within
  8639. subdirectories of
  8640. <filename>DEPLOY_DIR/sources</filename> based on the
  8641. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  8642. for each recipe.
  8643. Releasing the entire directory enables you to comply with
  8644. requirements concerning providing the unmodified source.
  8645. It is important to note that the size of the directory can
  8646. get large.
  8647. </para>
  8648. <para>
  8649. A way to help mitigate the size issue is to only release
  8650. tarballs for licenses that require the release of
  8651. source.
  8652. Let us assume you are only concerned with GPL code as
  8653. identified with the following:
  8654. <literallayout class='monospaced'>
  8655. $ cd poky/build/tmp/deploy/sources
  8656. $ mkdir ~/gpl_source_release
  8657. $ for dir in */*GPL*; do cp -r $dir ~/gpl_source_release; done
  8658. </literallayout>
  8659. At this point, you could create a tarball from the
  8660. <filename>gpl_source_release</filename> directory and
  8661. provide that to the end user.
  8662. This method would be a step toward achieving compliance
  8663. with section 3a of GPLv2 and with section 6 of GPLv3.
  8664. </para>
  8665. </section>
  8666. <section id='providing-license-text'>
  8667. <title>Providing License Text</title>
  8668. <para>
  8669. One requirement that is often overlooked is inclusion
  8670. of license text.
  8671. This requirement also needs to be dealt with prior to
  8672. generating the final image.
  8673. Some licenses require the license text to accompany
  8674. the binary.
  8675. You can achieve this by adding the following to your
  8676. <filename>local.conf</filename> file:
  8677. <literallayout class='monospaced'>
  8678. COPY_LIC_MANIFEST = "1"
  8679. COPY_LIC_DIRS = "1"
  8680. </literallayout>
  8681. Adding these statements to the configuration file ensures
  8682. that the licenses collected during package generation
  8683. are included on your image.
  8684. As the source archiver has already archived the original
  8685. unmodified source that contains the license files,
  8686. you would have already met the requirements for inclusion
  8687. of the license information with source as defined by the GPL
  8688. and other open source licenses.
  8689. </para>
  8690. </section>
  8691. <section id='providing-compilation-scripts-and-source-code-modifications'>
  8692. <title>Providing Compilation Scripts and Source Code Modifications</title>
  8693. <para>
  8694. At this point, we have addressed all we need to address
  8695. prior to generating the image.
  8696. The next two requirements are addressed during the final
  8697. packaging of the release.
  8698. </para>
  8699. <para>
  8700. By releasing the version of the OpenEmbedded build system
  8701. and the layers used during the build, you will be providing both
  8702. compilation scripts and the source code modifications in one
  8703. step.
  8704. </para>
  8705. <para>
  8706. If the deployment team has a
  8707. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  8708. and a distro layer, and those those layers are used to patch,
  8709. compile, package, or modify (in any way) any open source
  8710. software included in your released images, you
  8711. might be required to to release those layers under section 3 of
  8712. GPLv2 or section 1 of GPLv3.
  8713. One way of doing that is with a clean
  8714. checkout of the version of the Yocto Project and layers used
  8715. during your build.
  8716. Here is an example:
  8717. <literallayout class='monospaced'>
  8718. # We built using the &DISTRO_NAME; branch of the poky repo
  8719. $ git clone -b &DISTRO_NAME; git://git.yoctoproject.org/poky
  8720. $ cd poky
  8721. # We built using the release_branch for our layers
  8722. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  8723. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  8724. # clean up the .git repos
  8725. $ find . -name ".git" -type d -exec rm -rf {} \;
  8726. </literallayout>
  8727. One thing a development organization might want to consider
  8728. for end-user convenience is to modify
  8729. <filename>meta-yocto/conf/bblayers.conf.sample</filename> to
  8730. ensure that when the end user utilizes the released build
  8731. system to build an image, the development organization's
  8732. layers are included in the <filename>bblayers.conf</filename>
  8733. file automatically:
  8734. <literallayout class='monospaced'>
  8735. # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
  8736. # changes incompatibly
  8737. LCONF_VERSION = "6"
  8738. BBPATH = "${TOPDIR}"
  8739. BBFILES ?= ""
  8740. BBLAYERS ?= " \
  8741. ##OEROOT##/meta \
  8742. ##OEROOT##/meta-yocto \
  8743. ##OEROOT##/meta-yocto-bsp \
  8744. ##OEROOT##/meta-mylayer \
  8745. "
  8746. BBLAYERS_NON_REMOVABLE ?= " \
  8747. ##OEROOT##/meta \
  8748. ##OEROOT##/meta-yocto \
  8749. "
  8750. </literallayout>
  8751. Creating and providing an archive of the
  8752. <link linkend='metadata'>Metadata</link> layers
  8753. (recipes, configuration files, and so forth)
  8754. enables you to meet your
  8755. requirements to include the scripts to control compilation
  8756. as well as any modifications to the original source.
  8757. </para>
  8758. </section>
  8759. </section>
  8760. <section id='using-the-error-reporting-tool'>
  8761. <title>Using the Error Reporting Tool</title>
  8762. <para>
  8763. The error reporting tool allows you to
  8764. submit errors encountered during builds to a central database.
  8765. Outside of the build environment, you can use a web interface to
  8766. browse errors, view statistics, and query for errors.
  8767. The tool works using a client-server system where the client
  8768. portion is integrated with the installed Yocto Project
  8769. <link linkend='source-directory'>Source Directory</link>
  8770. (e.g. <filename>poky</filename>).
  8771. The server receives the information collected and saves it in a
  8772. database.
  8773. </para>
  8774. <para>
  8775. A live instance of the error reporting server exists at
  8776. <ulink url='http://errors.yoctoproject.org'></ulink>.
  8777. This server exists so that when you want to get help with
  8778. build failures, you can submit all of the information on the
  8779. failure easily and then point to the URL in your bug report
  8780. or send an email to the mailing list.
  8781. <note>
  8782. If you send error reports to this server, the reports become
  8783. publicly visible.
  8784. </note>
  8785. </para>
  8786. <section id='enabling-and-using-the-tool'>
  8787. <title>Enabling and Using the Tool</title>
  8788. <para>
  8789. By default, the error reporting tool is disabled.
  8790. You can enable it by inheriting the
  8791. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  8792. class by adding the following statement to the end of
  8793. your <filename>local.conf</filename> file in your
  8794. <link linkend='build-directory'>Build Directory</link>.
  8795. <literallayout class='monospaced'>
  8796. INHERIT += "report-error"
  8797. </literallayout>
  8798. </para>
  8799. <para>
  8800. By default, the error reporting feature stores information in
  8801. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  8802. However, you can specify a directory to use by adding the following
  8803. to your <filename>local.conf</filename> file:
  8804. <literallayout class='monospaced'>
  8805. ERR_REPORT_DIR = "path"
  8806. </literallayout>
  8807. Enabling error reporting causes the build process to collect
  8808. the errors and store them in a file as previously described.
  8809. When the build system encounters an error, it includes a command
  8810. as part of the console output.
  8811. You can run the command to send the error file to the server.
  8812. For example, the following command sends the errors to an upstream
  8813. server:
  8814. <literallayout class='monospaced'>
  8815. send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt [server]
  8816. </literallayout>
  8817. In the above example, the <filename>server</filename> parameter is
  8818. optional.
  8819. By default, the errors are sent to a database used by the entire
  8820. community.
  8821. If you specify a particular server, you can send them to a different
  8822. database.
  8823. </para>
  8824. <para>
  8825. When sending the error file, you receive a link that corresponds
  8826. to your entry in the database.
  8827. For example, here is a typical link:
  8828. <literallayout class='monospaced'>
  8829. http://localhost:8000/Errors/Search/1/158
  8830. </literallayout>
  8831. Following the link takes you to a web interface where you can
  8832. browse, query the errors, and view statistics.
  8833. </para>
  8834. </section>
  8835. <section id='disabling-the-tool'>
  8836. <title>Disabling the Tool</title>
  8837. <para>
  8838. To disable the error reporting feature, simply remove or comment
  8839. out the following statement from the end of your
  8840. <filename>local.conf</filename> file in your
  8841. <link linkend='build-directory'>Build Directory</link>.
  8842. <literallayout class='monospaced'>
  8843. INHERIT += "report-error"
  8844. </literallayout>
  8845. </para>
  8846. </section>
  8847. <section id='setting-up-your-own-error-reporting-server'>
  8848. <title>Setting Up Your Own Error Reporting Server</title>
  8849. <para>
  8850. If you want to set up your own error reporting server, you
  8851. can obtain the code from the Git repository at
  8852. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  8853. Instructions on how to set it up are in the README document.
  8854. </para>
  8855. </section>
  8856. </section>
  8857. </chapter>
  8858. <!--
  8859. vim: expandtab tw=80 ts=4
  8860. -->