dev-manual-common-tasks.xml 614 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811
  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. <note>
  44. For general information on BSP layer structure, see the
  45. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp'>Board Support Packages (BSP) - Developer's Guide</ulink>.
  46. </note>
  47. </para>
  48. <para>
  49. </para>
  50. <section id='yocto-project-layers'>
  51. <title>Layers</title>
  52. <para>
  53. The <link linkend='source-directory'>Source Directory</link>
  54. contains both general layers and BSP
  55. layers right out of the box.
  56. You can easily identify layers that ship with a
  57. Yocto Project release in the Source Directory by their
  58. folder names.
  59. Folders that represent layers typically have names that begin with
  60. the string <filename>meta-</filename>.
  61. <note>
  62. It is not a requirement that a layer name begin with the
  63. prefix <filename>meta-</filename>, but it is a commonly
  64. accepted standard in the Yocto Project community.
  65. </note>
  66. For example, when you set up the Source Directory structure,
  67. you will see several layers:
  68. <filename>meta</filename>,
  69. <filename>meta-skeleton</filename>,
  70. <filename>meta-selftest</filename>,
  71. <filename>meta-poky</filename>, and
  72. <filename>meta-yocto-bsp</filename>.
  73. Each of these folders represents a distinct layer.
  74. </para>
  75. <para>
  76. As another example, if you set up a local copy of the
  77. <filename>meta-intel</filename> Git repository
  78. and then explore the folder of that general layer,
  79. you will discover many Intel-specific BSP layers inside.
  80. For more information on BSP layers, see the
  81. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  82. section in the Yocto Project Board Support Package (BSP)
  83. Developer's Guide.
  84. </para>
  85. </section>
  86. <section id='creating-your-own-layer'>
  87. <title>Creating Your Own Layer</title>
  88. <para>
  89. It is very easy to create your own layers to use with the
  90. OpenEmbedded build system.
  91. The Yocto Project ships with scripts that speed up creating
  92. general layers and BSP layers.
  93. This section describes the steps you perform by hand to create
  94. a layer so that you can better understand them.
  95. For information about the layer-creation scripts, see the
  96. "<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>"
  97. section in the Yocto Project Board Support Package (BSP)
  98. Developer's Guide and the
  99. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  100. section further down in this manual.
  101. </para>
  102. <para>
  103. Follow these general steps to create your layer:
  104. <orderedlist>
  105. <listitem><para><emphasis>Check Existing Layers:</emphasis>
  106. Before creating a new layer, you should be sure someone
  107. has not already created a layer containing the Metadata
  108. you need.
  109. You can see the
  110. <ulink url='http://layers.openembedded.org/layerindex/layers/'><filename>OpenEmbedded Metadata Index</filename></ulink>
  111. for a list of layers from the OpenEmbedded community
  112. that can be used in the Yocto Project.
  113. </para></listitem>
  114. <listitem><para><emphasis>Create a Directory:</emphasis>
  115. Create the directory for your layer.
  116. While not strictly required, prepend the name of the
  117. folder with the string <filename>meta-</filename>.
  118. For example:
  119. <literallayout class='monospaced'>
  120. meta-mylayer
  121. meta-GUI_xyz
  122. meta-mymachine
  123. </literallayout>
  124. </para></listitem>
  125. <listitem><para><emphasis>Create a Layer Configuration
  126. File:</emphasis>
  127. Inside your new layer folder, you need to create a
  128. <filename>conf/layer.conf</filename> file.
  129. It is easiest to take an existing layer configuration
  130. file and copy that to your layer's
  131. <filename>conf</filename> directory and then modify the
  132. file as needed.</para>
  133. <para>The
  134. <filename>meta-yocto-bsp/conf/layer.conf</filename> file
  135. demonstrates the required syntax:
  136. <literallayout class='monospaced'>
  137. # We have a conf and classes directory, add to BBPATH
  138. BBPATH .= ":${LAYERDIR}"
  139. # We have recipes-* directories, add to BBFILES
  140. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  141. ${LAYERDIR}/recipes-*/*/*.bbappend"
  142. BBFILE_COLLECTIONS += "yoctobsp"
  143. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  144. BBFILE_PRIORITY_yoctobsp = "5"
  145. LAYERVERSION_yoctobsp = "3"
  146. </literallayout></para>
  147. <para>Here is an explanation of the example:
  148. <itemizedlist>
  149. <listitem><para>The configuration and
  150. classes directory is appended to
  151. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>.
  152. <note>
  153. All non-distro layers, which include all BSP
  154. layers, are expected to append the layer
  155. directory to the
  156. <filename>BBPATH</filename>.
  157. On the other hand, distro layers, such as
  158. <filename>meta-poky</filename>, can choose
  159. to enforce their own precedence over
  160. <filename>BBPATH</filename>.
  161. For an example of that syntax, see the
  162. <filename>layer.conf</filename> file for
  163. the <filename>meta-poky</filename> layer.
  164. </note></para></listitem>
  165. <listitem><para>The recipes for the layers are
  166. appended to
  167. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'>BBFILES</ulink></filename>.
  168. </para></listitem>
  169. <listitem><para>The
  170. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</ulink></filename>
  171. variable is then appended with the layer name.
  172. </para></listitem>
  173. <listitem><para>The
  174. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'>BBFILE_PATTERN</ulink></filename>
  175. variable is set to a regular expression and is
  176. used to match files from
  177. <filename>BBFILES</filename> into a particular
  178. layer.
  179. In this case,
  180. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  181. is used to make <filename>BBFILE_PATTERN</filename> match within the
  182. layer's path.</para></listitem>
  183. <listitem><para>The
  184. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'>BBFILE_PRIORITY</ulink></filename>
  185. variable then assigns a priority to the layer.
  186. Applying priorities is useful in situations
  187. where the same recipe might appear in multiple
  188. layers and allows you to choose the layer
  189. that takes precedence.</para></listitem>
  190. <listitem><para>The
  191. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'>LAYERVERSION</ulink></filename>
  192. variable optionally specifies the version of a
  193. layer as a single number.</para></listitem>
  194. </itemizedlist></para>
  195. <para>Note the use of the
  196. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  197. variable, which expands to the directory of the current
  198. layer.</para>
  199. <para>Through the use of the <filename>BBPATH</filename>
  200. variable, BitBake locates class files
  201. (<filename>.bbclass</filename>),
  202. configuration files, and files that are included
  203. with <filename>include</filename> and
  204. <filename>require</filename> statements.
  205. For these cases, BitBake uses the first file that
  206. matches the name found in <filename>BBPATH</filename>.
  207. This is similar to the way the <filename>PATH</filename>
  208. variable is used for binaries.
  209. It is recommended, therefore, that you use unique
  210. class and configuration
  211. filenames in your custom layer.</para></listitem>
  212. <listitem><para><emphasis>Add Content:</emphasis> Depending
  213. on the type of layer, add the content.
  214. If the layer adds support for a machine, add the machine
  215. configuration in a <filename>conf/machine/</filename>
  216. file within the layer.
  217. If the layer adds distro policy, add the distro
  218. configuration in a <filename>conf/distro/</filename>
  219. file within the layer.
  220. If the layer introduces new recipes, put the recipes
  221. you need in <filename>recipes-*</filename>
  222. subdirectories within the layer.
  223. <note>In order to be compliant with the Yocto Project,
  224. a layer must contain a
  225. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout-readme'>README file.</ulink>
  226. </note>
  227. </para></listitem>
  228. <listitem><para>
  229. <emphasis>Optionally Test for Compatibility:</emphasis>
  230. If you want permission to use the Yocto Project
  231. Compatibility logo with your layer or application that
  232. uses your layer, perform the steps to apply for
  233. compatibility.
  234. See the
  235. "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>"
  236. section for more information.
  237. </para></listitem>
  238. </orderedlist>
  239. </para>
  240. </section>
  241. <section id='best-practices-to-follow-when-creating-layers'>
  242. <title>Best Practices to Follow When Creating Layers</title>
  243. <para>
  244. To create layers that are easier to maintain and that will
  245. not impact builds for other machines, you should consider the
  246. information in the following sections.
  247. </para>
  248. <section id='avoid-overlaying-entire-recipes'>
  249. <title>Avoid "Overlaying" Entire Recipes</title>
  250. <para>
  251. Avoid "overlaying" entire recipes from other layers in your
  252. configuration.
  253. In other words, do not copy an entire recipe into your
  254. layer and then modify it.
  255. Rather, use an append file (<filename>.bbappend</filename>)
  256. to override
  257. only those parts of the original recipe you need to modify.
  258. </para>
  259. </section>
  260. <section id='avoid-duplicating-include-files'>
  261. <title>Avoid Duplicating Include Files</title>
  262. <para>
  263. Avoid duplicating include files.
  264. Use append files (<filename>.bbappend</filename>)
  265. for each recipe
  266. that uses an include file.
  267. Or, if you are introducing a new recipe that requires
  268. the included file, use the path relative to the original
  269. layer directory to refer to the file.
  270. For example, use
  271. <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename>
  272. instead of <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>.
  273. If you're finding you have to overlay the include file,
  274. it could indicate a deficiency in the include file in
  275. the layer to which it originally belongs.
  276. If this is the case, you should try to address that
  277. deficiency instead of overlaying the include file.
  278. For example, you could address this by getting the
  279. maintainer of the include file to add a variable or
  280. variables to make it easy to override the parts needing
  281. to be overridden.
  282. </para>
  283. </section>
  284. <section id='structure-your-layers'>
  285. <title>Structure Your Layers</title>
  286. <para>
  287. Proper use of overrides within append files and placement
  288. of machine-specific files within your layer can ensure that
  289. a build is not using the wrong Metadata and negatively
  290. impacting a build for a different machine.
  291. Following are some examples:
  292. <itemizedlist>
  293. <listitem><para><emphasis>Modifying Variables to Support
  294. a Different Machine:</emphasis>
  295. Suppose you have a layer named
  296. <filename>meta-one</filename> that adds support
  297. for building machine "one".
  298. To do so, you use an append file named
  299. <filename>base-files.bbappend</filename> and
  300. create a dependency on "foo" by altering the
  301. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  302. variable:
  303. <literallayout class='monospaced'>
  304. DEPENDS = "foo"
  305. </literallayout>
  306. The dependency is created during any build that
  307. includes the layer
  308. <filename>meta-one</filename>.
  309. However, you might not want this dependency
  310. for all machines.
  311. For example, suppose you are building for
  312. machine "two" but your
  313. <filename>bblayers.conf</filename> file has the
  314. <filename>meta-one</filename> layer included.
  315. During the build, the
  316. <filename>base-files</filename> for machine
  317. "two" will also have the dependency on
  318. <filename>foo</filename>.</para>
  319. <para>To make sure your changes apply only when
  320. building machine "one", use a machine override
  321. with the <filename>DEPENDS</filename> statement:
  322. <literallayout class='monospaced'>
  323. DEPENDS_one = "foo"
  324. </literallayout>
  325. You should follow the same strategy when using
  326. <filename>_append</filename> and
  327. <filename>_prepend</filename> operations:
  328. <literallayout class='monospaced'>
  329. DEPENDS_append_one = " foo"
  330. DEPENDS_prepend_one = "foo "
  331. </literallayout>
  332. As an actual example, here's a line from the recipe
  333. for gnutls, which adds dependencies on
  334. "argp-standalone" when building with the musl C
  335. library:
  336. <literallayout class='monospaced'>
  337. DEPENDS_append_libc-musl = " argp-standalone"
  338. </literallayout>
  339. <note>
  340. Avoiding "+=" and "=+" and using
  341. machine-specific
  342. <filename>_append</filename>
  343. and <filename>_prepend</filename> operations
  344. is recommended as well.
  345. </note></para></listitem>
  346. <listitem><para><emphasis>Place Machine-Specific Files
  347. in Machine-Specific Locations:</emphasis>
  348. When you have a base recipe, such as
  349. <filename>base-files.bb</filename>, that
  350. contains a
  351. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  352. statement to a file, you can use an append file
  353. to cause the build to use your own version of
  354. the file.
  355. For example, an append file in your layer at
  356. <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename>
  357. could extend
  358. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  359. using
  360. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  361. as follows:
  362. <literallayout class='monospaced'>
  363. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  364. </literallayout>
  365. The build for machine "one" will pick up your
  366. machine-specific file as long as you have the
  367. file in
  368. <filename>meta-one/recipes-core/base-files/base-files/</filename>.
  369. However, if you are building for a different
  370. machine and the
  371. <filename>bblayers.conf</filename> file includes
  372. the <filename>meta-one</filename> layer and
  373. the location of your machine-specific file is
  374. the first location where that file is found
  375. according to <filename>FILESPATH</filename>,
  376. builds for all machines will also use that
  377. machine-specific file.</para>
  378. <para>You can make sure that a machine-specific
  379. file is used for a particular machine by putting
  380. the file in a subdirectory specific to the
  381. machine.
  382. For example, rather than placing the file in
  383. <filename>meta-one/recipes-core/base-files/base-files/</filename>
  384. as shown above, put it in
  385. <filename>meta-one/recipes-core/base-files/base-files/one/</filename>.
  386. Not only does this make sure the file is used
  387. only when building for machine "one", but the
  388. build process locates the file more quickly.</para>
  389. <para>In summary, you need to place all files
  390. referenced from <filename>SRC_URI</filename>
  391. in a machine-specific subdirectory within the
  392. layer in order to restrict those files to
  393. machine-specific builds.</para></listitem>
  394. </itemizedlist>
  395. </para>
  396. </section>
  397. <section id='other-recommendations'>
  398. <title>Other Recommendations</title>
  399. <para>
  400. We also recommend the following:
  401. <itemizedlist>
  402. <listitem><para>If you want permission to use the
  403. Yocto Project Compatibility logo with your layer
  404. or application that uses your layer, perform the
  405. steps to apply for compatibility.
  406. See the
  407. "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>"
  408. section for more information.
  409. </para></listitem>
  410. <listitem><para>Store custom layers in a Git repository
  411. that uses the
  412. <filename>meta-<replaceable>layer_name</replaceable></filename> format.
  413. </para></listitem>
  414. <listitem><para>Clone the repository alongside other
  415. <filename>meta</filename> directories in the
  416. <link linkend='source-directory'>Source Directory</link>.
  417. </para></listitem>
  418. </itemizedlist>
  419. Following these recommendations keeps your Source Directory and
  420. its configuration entirely inside the Yocto Project's core
  421. base.
  422. </para>
  423. </section>
  424. </section>
  425. <section id='making-sure-your-layer-is-compatible-with-yocto-project'>
  426. <title>Making Sure Your Layer is Compatible With Yocto Project</title>
  427. <para>
  428. When you create a layer used with the Yocto Project, it is
  429. advantageous to make sure that the layer interacts well with
  430. existing Yocto Project layers (i.e. the layer is compatible
  431. with the Yocto Project).
  432. Ensuring compatibility makes the layer easy to be consumed
  433. by others in the Yocto Project community and allows you
  434. permission to use the Yocto Project Compatibility logo.
  435. </para>
  436. <para>
  437. Version 1.0 of the Yocto Project Compatibility Program has
  438. been in existence for a number of releases.
  439. This version of the program consists of the layer application
  440. process that requests permission to use the Yocto Project
  441. Compatibility logo for your layer and application.
  442. You can find version 1.0 of the form at
  443. <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>.
  444. To be granted permission to use the logo, you need to be able
  445. to answer "Yes" to the questions or have an acceptable
  446. explanation for any questions answered "No".
  447. </para>
  448. <para>
  449. A second version (2.0) of the Yocto Project Compatibility
  450. Program is currently under development.
  451. Included as part of version 2.0 (and currently available) is
  452. the <filename>yocto-compat-layer.py</filename> script.
  453. When run against a layer, this script tests the layer against
  454. tighter constraints based on experiences of how layers have
  455. worked in the real world and where pitfalls have been found.
  456. </para>
  457. <para>
  458. Part of the 2.0 version of the program that is not currently
  459. available but is in development is an updated compatibility
  460. application form.
  461. This updated form, among other questions, specifically
  462. asks if your layer has passed the test using the
  463. <filename>yocto-compat-layer.py</filename> script.
  464. <note><title>Tip</title>
  465. Even though the updated application form is currently
  466. unavailable for version 2.0 of the Yocto Project
  467. Compatibility Program, the
  468. <filename>yocto-compat-layer.py</filename> script is
  469. available in OE-Core.
  470. You can use the script to assess the status of your
  471. layers in advance of the 2.0 release of the program.
  472. </note>
  473. </para>
  474. <para>
  475. The remainder of this section presents information on the
  476. version 1.0 registration form and on the
  477. <filename>yocto-compat-layer.py</filename> script.
  478. </para>
  479. <section id='yocto-project-compatibility-program-application'>
  480. <title>Yocto Project Compatibility Program Application</title>
  481. <para>
  482. Use the 1.0 version of the form to apply for your
  483. layer's compatibility approval.
  484. Upon successful application, you can use the Yocto
  485. Project Compatibility logo with your layer and the
  486. application that uses your layer.
  487. </para>
  488. <para>
  489. To access the form, use this link:
  490. <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>.
  491. Follow the instructions on the form to complete your
  492. application.
  493. </para>
  494. <para>
  495. The application consists of the following sections:
  496. <itemizedlist>
  497. <listitem><para>
  498. <emphasis>Contact Information:</emphasis>
  499. Provide your contact information as the fields
  500. require.
  501. Along with your information, provide the
  502. released versions of the Yocto Project for which
  503. your layer is compatible.
  504. </para></listitem>
  505. <listitem><para>
  506. <emphasis>Acceptance Criteria:</emphasis>
  507. Provide "Yes" or "No" answers for each of the
  508. items in the checklist.
  509. Space exists at the bottom of the form for any
  510. explanations for items for which you answered "No".
  511. </para></listitem>
  512. <listitem><para>
  513. <emphasis>Recommendations:</emphasis>
  514. Provide answers for the questions regarding Linux
  515. kernel use and build success.
  516. </para></listitem>
  517. </itemizedlist>
  518. </para>
  519. </section>
  520. <section id='yocto-compat-layer-py-script'>
  521. <title><filename>yocto-compat-layer.py</filename> Script</title>
  522. <para>
  523. The <filename>yocto-compat-layer.py</filename> script,
  524. which is currently available, provides you a way to
  525. assess how compatible your layer is with the Yocto
  526. Project.
  527. You should run this script prior to using the form to
  528. apply for compatibility as described in the previous
  529. section.
  530. <note>
  531. Because the script is part of the 2.0 release of the
  532. Yocto Project Compatibility Program, you are not
  533. required to successfully run your layer against it
  534. in order to be granted compatibility status.
  535. However, it is a good idea as it promotes
  536. well-behaved layers and gives you an idea of where your
  537. layer stands regarding compatibility.
  538. </note>
  539. </para>
  540. <para>
  541. The script divides tests into three areas: COMMON, BSD,
  542. and DISTRO.
  543. For example, given a distribution layer (DISTRO), the
  544. layer must pass both the COMMON and DISTRO related tests.
  545. Furthermore, if your layer is a BSP layer, the layer must
  546. pass the COMMON and BSP set of tests.
  547. </para>
  548. <para>
  549. To execute the script, enter the following commands from
  550. your build directory:
  551. <literallayout class='monospaced'>
  552. $ source oe-init-build-env
  553. $ yocto-compat-layer.py <replaceable>your_layer_directory</replaceable>
  554. </literallayout>
  555. Be sure to provide the actual directory for your layer
  556. as part of the command.
  557. </para>
  558. <para>
  559. Entering the command causes the script to determine the
  560. type of layer and then to execute a set of specific
  561. tests against the layer.
  562. The following list overviews the test:
  563. <itemizedlist>
  564. <listitem><para>
  565. <filename>common.test_readme</filename>:
  566. Tests if a <filename>README</filename> file
  567. exists in the layer and the file is not empty.
  568. </para></listitem>
  569. <listitem><para>
  570. <filename>common.test_parse</filename>:
  571. Tests to make sure that BitBake can parse the
  572. files without error (i.e.
  573. <filename>bitbake -p</filename>).
  574. </para></listitem>
  575. <listitem><para>
  576. <filename>common.test_show_environment</filename>:
  577. Tests that the global or per-recipe environment
  578. is in order without errors (i.e.
  579. <filename>bitbake -e</filename>).
  580. </para></listitem>
  581. <listitem><para>
  582. <filename>common.test_signatures</filename>:
  583. Tests to be sure that BSP and DISTRO layers do not
  584. come with recipes that change signatures.
  585. </para></listitem>
  586. <listitem><para>
  587. <filename>bsp.test_bsp_defines_machines</filename>:
  588. Tests if a BSP layer has machine configurations.
  589. </para></listitem>
  590. <listitem><para>
  591. <filename>bsp.test_bsp_no_set_machine</filename>:
  592. Tests to ensure a BSP layer does not set the
  593. machine when the layer is added.
  594. </para></listitem>
  595. <listitem><para>
  596. <filename>distro.test_distro_defines_distros</filename>:
  597. Tests if a DISTRO layer has distro configurations.
  598. </para></listitem>
  599. <listitem><para>
  600. <filename>distro.test_distro_no_set_distro</filename>:
  601. Tests to ensure a DISTRO layer does not set the
  602. distribution when the layer is added.
  603. </para></listitem>
  604. </itemizedlist>
  605. </para>
  606. </section>
  607. </section>
  608. <section id='enabling-your-layer'>
  609. <title>Enabling Your Layer</title>
  610. <para>
  611. Before the OpenEmbedded build system can use your new layer,
  612. you need to enable it.
  613. To enable your layer, simply add your layer's path to the
  614. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename>
  615. variable in your <filename>conf/bblayers.conf</filename> file,
  616. which is found in the
  617. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  618. The following example shows how to enable a layer named
  619. <filename>meta-mylayer</filename>:
  620. <literallayout class='monospaced'>
  621. LCONF_VERSION = "6"
  622. BBPATH = "${TOPDIR}"
  623. BBFILES ?= ""
  624. BBLAYERS ?= " \
  625. $HOME/poky/meta \
  626. $HOME/poky/meta-poky \
  627. $HOME/poky/meta-yocto-bsp \
  628. $HOME/poky/meta-mylayer \
  629. "
  630. </literallayout>
  631. </para>
  632. <para>
  633. BitBake parses each <filename>conf/layer.conf</filename> file
  634. as specified in the <filename>BBLAYERS</filename> variable
  635. within the <filename>conf/bblayers.conf</filename> file.
  636. During the processing of each
  637. <filename>conf/layer.conf</filename> file, BitBake adds the
  638. recipes, classes and configurations contained within the
  639. particular layer to the source directory.
  640. </para>
  641. </section>
  642. <section id='using-bbappend-files'>
  643. <title>Using .bbappend Files</title>
  644. <para>
  645. Recipes used to append Metadata to other recipes are called
  646. BitBake append files.
  647. BitBake append files use the <filename>.bbappend</filename> file
  648. type suffix, while the corresponding recipes to which Metadata
  649. is being appended use the <filename>.bb</filename> file type
  650. suffix.
  651. </para>
  652. <para>
  653. A <filename>.bbappend</filename> file allows your layer to make
  654. additions or changes to the content of another layer's recipe
  655. without having to copy the other recipe into your layer.
  656. Your <filename>.bbappend</filename> file resides in your layer,
  657. while the main <filename>.bb</filename> recipe file to
  658. which you are appending Metadata resides in a different layer.
  659. </para>
  660. <para>
  661. Append files must have the same root names as their corresponding
  662. recipes.
  663. For example, the append file
  664. <filename>someapp_&DISTRO;.bbappend</filename> must apply to
  665. <filename>someapp_&DISTRO;.bb</filename>.
  666. This means the original recipe and append file names are version
  667. number-specific.
  668. If the corresponding recipe is renamed to update to a newer
  669. version, the corresponding <filename>.bbappend</filename> file must
  670. be renamed (and possibly updated) as well.
  671. During the build process, BitBake displays an error on starting
  672. if it detects a <filename>.bbappend</filename> file that does
  673. not have a corresponding recipe with a matching name.
  674. See the
  675. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink>
  676. variable for information on how to handle this error.
  677. </para>
  678. <para>
  679. Being able to append information to an existing recipe not only
  680. avoids duplication, but also automatically applies recipe
  681. changes in a different layer to your layer.
  682. If you were copying recipes, you would have to manually merge
  683. changes as they occur.
  684. </para>
  685. <para>
  686. As an example, consider the main formfactor recipe and a
  687. corresponding formfactor append file both from the
  688. <link linkend='source-directory'>Source Directory</link>.
  689. Here is the main formfactor recipe, which is named
  690. <filename>formfactor_0.0.bb</filename> and located in the
  691. "meta" layer at
  692. <filename>meta/recipes-bsp/formfactor</filename>:
  693. <literallayout class='monospaced'>
  694. SUMMARY = "Device formfactor information"
  695. SECTION = "base"
  696. LICENSE = "MIT"
  697. LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
  698. file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  699. PR = "r45"
  700. SRC_URI = "file://config file://machconfig"
  701. S = "${WORKDIR}"
  702. PACKAGE_ARCH = "${MACHINE_ARCH}"
  703. INHIBIT_DEFAULT_DEPS = "1"
  704. do_install() {
  705. # Install file only if it has contents
  706. install -d ${D}${sysconfdir}/formfactor/
  707. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  708. if [ -s "${S}/machconfig" ]; then
  709. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  710. fi
  711. }
  712. </literallayout>
  713. In the main recipe, note the
  714. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  715. variable, which tells the OpenEmbedded build system where to
  716. find files during the build.
  717. </para>
  718. <para>
  719. Following is the append file, which is named
  720. <filename>formfactor_0.0.bbappend</filename> and is from the
  721. Raspberry Pi BSP Layer named
  722. <filename>meta-raspberrypi</filename>.
  723. The file is in <filename>recipes-bsp/formfactor</filename>:
  724. <literallayout class='monospaced'>
  725. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  726. </literallayout>
  727. </para>
  728. <para>
  729. By default, the build system uses the
  730. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  731. variable to locate files.
  732. This append file extends the locations by setting the
  733. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  734. variable.
  735. Setting this variable in the <filename>.bbappend</filename>
  736. file is the most reliable and recommended method for adding
  737. directories to the search path used by the build system
  738. to find files.
  739. </para>
  740. <para>
  741. The statement in this example extends the directories to include
  742. <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>,
  743. which resolves to a directory named
  744. <filename>formfactor</filename> in the same directory
  745. in which the append file resides (i.e.
  746. <filename>meta-raspberrypi/recipes-bsp/formfactor/formfactor</filename>.
  747. This implies that you must have the supporting directory
  748. structure set up that will contain any files or patches you
  749. will be including from the layer.
  750. </para>
  751. <para>
  752. Using the immediate expansion assignment operator
  753. <filename>:=</filename> is important because of the reference to
  754. <filename>THISDIR</filename>.
  755. The trailing colon character is important as it ensures that
  756. items in the list remain colon-separated.
  757. <note>
  758. <para>
  759. BitBake automatically defines the
  760. <filename>THISDIR</filename> variable.
  761. You should never set this variable yourself.
  762. Using "_prepend" as part of the
  763. <filename>FILESEXTRAPATHS</filename> ensures your path
  764. will be searched prior to other paths in the final
  765. list.
  766. </para>
  767. <para>
  768. Also, not all append files add extra files.
  769. Many append files simply exist to add build options
  770. (e.g. <filename>systemd</filename>).
  771. For these cases, your append file would not even
  772. use the <filename>FILESEXTRAPATHS</filename> statement.
  773. </para>
  774. </note>
  775. </para>
  776. </section>
  777. <section id='prioritizing-your-layer'>
  778. <title>Prioritizing Your Layer</title>
  779. <para>
  780. Each layer is assigned a priority value.
  781. Priority values control which layer takes precedence if there
  782. are recipe files with the same name in multiple layers.
  783. For these cases, the recipe file from the layer with a higher
  784. priority number takes precedence.
  785. Priority values also affect the order in which multiple
  786. <filename>.bbappend</filename> files for the same recipe are
  787. applied.
  788. You can either specify the priority manually, or allow the
  789. build system to calculate it based on the layer's dependencies.
  790. </para>
  791. <para>
  792. To specify the layer's priority manually, use the
  793. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  794. variable.
  795. For example:
  796. <literallayout class='monospaced'>
  797. BBFILE_PRIORITY_mylayer = "1"
  798. </literallayout>
  799. </para>
  800. <note>
  801. <para>It is possible for a recipe with a lower version number
  802. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  803. in a layer that has a higher priority to take precedence.</para>
  804. <para>Also, the layer priority does not currently affect the
  805. precedence order of <filename>.conf</filename>
  806. or <filename>.bbclass</filename> files.
  807. Future versions of BitBake might address this.</para>
  808. </note>
  809. </section>
  810. <section id='managing-layers'>
  811. <title>Managing Layers</title>
  812. <para>
  813. You can use the BitBake layer management tool to provide a view
  814. into the structure of recipes across a multi-layer project.
  815. Being able to generate output that reports on configured layers
  816. with their paths and priorities and on
  817. <filename>.bbappend</filename> files and their applicable
  818. recipes can help to reveal potential problems.
  819. </para>
  820. <para>
  821. Use the following form when running the layer management tool.
  822. <literallayout class='monospaced'>
  823. $ bitbake-layers <replaceable>command</replaceable> [<replaceable>arguments</replaceable>]
  824. </literallayout>
  825. The following list describes the available commands:
  826. <itemizedlist>
  827. <listitem><para><filename><emphasis>help:</emphasis></filename>
  828. Displays general help or help on a specified command.
  829. </para></listitem>
  830. <listitem><para><filename><emphasis>show-layers:</emphasis></filename>
  831. Shows the current configured layers.
  832. </para></listitem>
  833. <listitem><para><filename><emphasis>show-recipes:</emphasis></filename>
  834. Lists available recipes and the layers that provide them.
  835. </para></listitem>
  836. <listitem><para><filename><emphasis>show-overlayed:</emphasis></filename>
  837. Lists overlayed recipes.
  838. A recipe is overlayed when a recipe with the same name
  839. exists in another layer that has a higher layer
  840. priority.
  841. </para></listitem>
  842. <listitem><para><filename><emphasis>show-appends:</emphasis></filename>
  843. Lists <filename>.bbappend</filename> files and the
  844. recipe files to which they apply.
  845. </para></listitem>
  846. <listitem><para><filename><emphasis>show-cross-depends:</emphasis></filename>
  847. Lists dependency relationships between recipes that
  848. cross layer boundaries.
  849. </para></listitem>
  850. <listitem><para><filename><emphasis>add-layer:</emphasis></filename>
  851. Adds a layer to <filename>bblayers.conf</filename>.
  852. </para></listitem>
  853. <listitem><para><filename><emphasis>remove-layer:</emphasis></filename>
  854. Removes a layer from <filename>bblayers.conf</filename>
  855. </para></listitem>
  856. <listitem><para><filename><emphasis>flatten:</emphasis></filename>
  857. Flattens the layer configuration into a separate output
  858. directory.
  859. Flattening your layer configuration builds a "flattened"
  860. directory that contains the contents of all layers,
  861. with any overlayed recipes removed and any
  862. <filename>.bbappend</filename> files appended to the
  863. corresponding recipes.
  864. You might have to perform some manual cleanup of the
  865. flattened layer as follows:
  866. <itemizedlist>
  867. <listitem><para>Non-recipe files (such as patches)
  868. are overwritten.
  869. The flatten command shows a warning for these
  870. files.
  871. </para></listitem>
  872. <listitem><para>Anything beyond the normal layer
  873. setup has been added to the
  874. <filename>layer.conf</filename> file.
  875. Only the lowest priority layer's
  876. <filename>layer.conf</filename> is used.
  877. </para></listitem>
  878. <listitem><para>Overridden and appended items from
  879. <filename>.bbappend</filename> files need to be
  880. cleaned up.
  881. The contents of each
  882. <filename>.bbappend</filename> end up in the
  883. flattened recipe.
  884. However, if there are appended or changed
  885. variable values, you need to tidy these up
  886. yourself.
  887. Consider the following example.
  888. Here, the <filename>bitbake-layers</filename>
  889. command adds the line
  890. <filename>#### bbappended ...</filename> so that
  891. you know where the following lines originate:
  892. <literallayout class='monospaced'>
  893. ...
  894. DESCRIPTION = "A useful utility"
  895. ...
  896. EXTRA_OECONF = "--enable-something"
  897. ...
  898. #### bbappended from meta-anotherlayer ####
  899. DESCRIPTION = "Customized utility"
  900. EXTRA_OECONF += "--enable-somethingelse"
  901. </literallayout>
  902. Ideally, you would tidy up these utilities as
  903. follows:
  904. <literallayout class='monospaced'>
  905. ...
  906. DESCRIPTION = "Customized utility"
  907. ...
  908. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  909. ...
  910. </literallayout></para></listitem>
  911. </itemizedlist></para></listitem>
  912. </itemizedlist>
  913. </para>
  914. </section>
  915. <section id='creating-a-general-layer-using-the-yocto-layer-script'>
  916. <title>Creating a General Layer Using the yocto-layer Script</title>
  917. <para>
  918. The <filename>yocto-layer</filename> script simplifies
  919. creating a new general layer.
  920. <note>
  921. For information on BSP layers, see the
  922. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  923. section in the Yocto Project Board Specific (BSP)
  924. Developer's Guide.
  925. </note>
  926. The default mode of the script's operation is to prompt you for
  927. information needed to generate the layer:
  928. <itemizedlist>
  929. <listitem><para>The layer priority.
  930. </para></listitem>
  931. <listitem><para>Whether or not to create a sample recipe.
  932. </para></listitem>
  933. <listitem><para>Whether or not to create a sample
  934. append file.
  935. </para></listitem>
  936. </itemizedlist>
  937. </para>
  938. <para>
  939. Use the <filename>yocto-layer create</filename> sub-command
  940. to create a new general layer.
  941. In its simplest form, you can create a layer as follows:
  942. <literallayout class='monospaced'>
  943. $ yocto-layer create mylayer
  944. </literallayout>
  945. The previous example creates a layer named
  946. <filename>meta-mylayer</filename> in the current directory.
  947. </para>
  948. <para>
  949. As the <filename>yocto-layer create</filename> command runs,
  950. default values for the prompts appear in brackets.
  951. Pressing enter without supplying anything for the prompts
  952. or pressing enter and providing an invalid response causes the
  953. script to accept the default value.
  954. Once the script completes, the new layer
  955. is created in the current working directory.
  956. The script names the layer by prepending
  957. <filename>meta-</filename> to the name you provide.
  958. </para>
  959. <para>
  960. Minimally, the script creates the following within the layer:
  961. <itemizedlist>
  962. <listitem><para><emphasis>The <filename>conf</filename>
  963. directory:</emphasis>
  964. This directory contains the layer's configuration file.
  965. The root name for the file is the same as the root name
  966. your provided for the layer (e.g.
  967. <filename><replaceable>layer</replaceable>.conf</filename>).
  968. </para></listitem>
  969. <listitem><para><emphasis>The
  970. <filename>COPYING.MIT</filename> file:</emphasis>
  971. The copyright and use notice for the software.
  972. </para></listitem>
  973. <listitem><para><emphasis>The <filename>README</filename>
  974. file:</emphasis>
  975. A file describing the contents of your new layer.
  976. </para></listitem>
  977. </itemizedlist>
  978. </para>
  979. <para>
  980. If you choose to generate a sample recipe file, the script
  981. prompts you for the name for the recipe and then creates it
  982. in <filename><replaceable>layer</replaceable>/recipes-example/example/</filename>.
  983. The script creates a <filename>.bb</filename> file and a
  984. directory, which contains a sample
  985. <filename>helloworld.c</filename> source file, along with
  986. a sample patch file.
  987. If you do not provide a recipe name, the script uses
  988. "example".
  989. </para>
  990. <para>
  991. If you choose to generate a sample append file, the script
  992. prompts you for the name for the file and then creates it
  993. in <filename><replaceable>layer</replaceable>/recipes-example-bbappend/example-bbappend/</filename>.
  994. The script creates a <filename>.bbappend</filename> file and a
  995. directory, which contains a sample patch file.
  996. If you do not provide a recipe name, the script uses
  997. "example".
  998. The script also prompts you for the version of the append file.
  999. The version should match the recipe to which the append file
  1000. is associated.
  1001. </para>
  1002. <para>
  1003. The easiest way to see how the <filename>yocto-layer</filename>
  1004. script works is to experiment with the script.
  1005. You can also read the usage information by entering the
  1006. following:
  1007. <literallayout class='monospaced'>
  1008. $ yocto-layer help
  1009. </literallayout>
  1010. </para>
  1011. <para>
  1012. Once you create your general layer, you must add it to your
  1013. <filename>bblayers.conf</filename> file.
  1014. Here is an example where a layer named
  1015. <filename>meta-mylayer</filename> is added:
  1016. <literallayout class='monospaced'>
  1017. BBLAYERS = ?" \
  1018. /usr/local/src/yocto/meta \
  1019. /usr/local/src/yocto/meta-poky \
  1020. /usr/local/src/yocto/meta-yocto-bsp \
  1021. /usr/local/src/yocto/meta-mylayer \
  1022. "
  1023. </literallayout>
  1024. Adding the layer to this file enables the build system to
  1025. locate the layer during the build.
  1026. </para>
  1027. </section>
  1028. </section>
  1029. <section id='usingpoky-extend-customimage'>
  1030. <title>Customizing Images</title>
  1031. <para>
  1032. You can customize images to satisfy particular requirements.
  1033. This section describes several methods and provides guidelines for each.
  1034. </para>
  1035. <section id='usingpoky-extend-customimage-localconf'>
  1036. <title>Customizing Images Using <filename>local.conf</filename></title>
  1037. <para>
  1038. Probably the easiest way to customize an image is to add a
  1039. package by way of the <filename>local.conf</filename>
  1040. configuration file.
  1041. Because it is limited to local use, this method generally only
  1042. allows you to add packages and is not as flexible as creating
  1043. your own customized image.
  1044. When you add packages using local variables this way, you need
  1045. to realize that these variable changes are in effect for every
  1046. build and consequently affect all images, which might not
  1047. be what you require.
  1048. </para>
  1049. <para>
  1050. To add a package to your image using the local configuration
  1051. file, use the
  1052. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1053. variable with the <filename>_append</filename> operator:
  1054. <literallayout class='monospaced'>
  1055. IMAGE_INSTALL_append = " strace"
  1056. </literallayout>
  1057. Use of the syntax is important - specifically, the space between
  1058. the quote and the package name, which is
  1059. <filename>strace</filename> in this example.
  1060. This space is required since the <filename>_append</filename>
  1061. operator does not add the space.
  1062. </para>
  1063. <para>
  1064. Furthermore, you must use <filename>_append</filename> instead
  1065. of the <filename>+=</filename> operator if you want to avoid
  1066. ordering issues.
  1067. The reason for this is because doing so unconditionally appends
  1068. to the variable and avoids ordering problems due to the
  1069. variable being set in image recipes and
  1070. <filename>.bbclass</filename> files with operators like
  1071. <filename>?=</filename>.
  1072. Using <filename>_append</filename> ensures the operation takes
  1073. affect.
  1074. </para>
  1075. <para>
  1076. As shown in its simplest use,
  1077. <filename>IMAGE_INSTALL_append</filename> affects all images.
  1078. It is possible to extend the syntax so that the variable
  1079. applies to a specific image only.
  1080. Here is an example:
  1081. <literallayout class='monospaced'>
  1082. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  1083. </literallayout>
  1084. This example adds <filename>strace</filename> to the
  1085. <filename>core-image-minimal</filename> image only.
  1086. </para>
  1087. <para>
  1088. You can add packages using a similar approach through the
  1089. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename>
  1090. variable.
  1091. If you use this variable, only
  1092. <filename>core-image-*</filename> images are affected.
  1093. </para>
  1094. </section>
  1095. <section id='usingpoky-extend-customimage-imagefeatures'>
  1096. <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and
  1097. <filename>EXTRA_IMAGE_FEATURES</filename></title>
  1098. <para>
  1099. Another method for customizing your image is to enable or
  1100. disable high-level image features by using the
  1101. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  1102. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  1103. variables.
  1104. Although the functions for both variables are nearly equivalent,
  1105. best practices dictate using <filename>IMAGE_FEATURES</filename>
  1106. from within a recipe and using
  1107. <filename>EXTRA_IMAGE_FEATURES</filename> from within
  1108. your <filename>local.conf</filename> file, which is found in the
  1109. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1110. </para>
  1111. <para>
  1112. To understand how these features work, the best reference is
  1113. <filename>meta/classes/core-image.bbclass</filename>.
  1114. This class lists out the available
  1115. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  1116. of which most map to package groups while some, such as
  1117. <filename>debug-tweaks</filename> and
  1118. <filename>read-only-rootfs</filename>, resolve as general
  1119. configuration settings.
  1120. </para>
  1121. <para>
  1122. In summary, the file looks at the contents of the
  1123. <filename>IMAGE_FEATURES</filename> variable and then maps
  1124. or configures the feature accordingly.
  1125. Based on this information, the build system automatically
  1126. adds the appropriate packages or configurations to the
  1127. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  1128. variable.
  1129. Effectively, you are enabling extra features by extending the
  1130. class or creating a custom class for use with specialized image
  1131. <filename>.bb</filename> files.
  1132. </para>
  1133. <para>
  1134. Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable
  1135. from within your local configuration file.
  1136. Using a separate area from which to enable features with
  1137. this variable helps you avoid overwriting the features in the
  1138. image recipe that are enabled with
  1139. <filename>IMAGE_FEATURES</filename>.
  1140. The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added
  1141. to <filename>IMAGE_FEATURES</filename> within
  1142. <filename>meta/conf/bitbake.conf</filename>.
  1143. </para>
  1144. <para>
  1145. To illustrate how you can use these variables to modify your
  1146. image, consider an example that selects the SSH server.
  1147. The Yocto Project ships with two SSH servers you can use
  1148. with your images: Dropbear and OpenSSH.
  1149. Dropbear is a minimal SSH server appropriate for
  1150. resource-constrained environments, while OpenSSH is a
  1151. well-known standard SSH server implementation.
  1152. By default, the <filename>core-image-sato</filename> image
  1153. is configured to use Dropbear.
  1154. The <filename>core-image-full-cmdline</filename> and
  1155. <filename>core-image-lsb</filename> images both
  1156. include OpenSSH.
  1157. The <filename>core-image-minimal</filename> image does not
  1158. contain an SSH server.
  1159. </para>
  1160. <para>
  1161. You can customize your image and change these defaults.
  1162. Edit the <filename>IMAGE_FEATURES</filename> variable
  1163. in your recipe or use the
  1164. <filename>EXTRA_IMAGE_FEATURES</filename> in your
  1165. <filename>local.conf</filename> file so that it configures the
  1166. image you are working with to include
  1167. <filename>ssh-server-dropbear</filename> or
  1168. <filename>ssh-server-openssh</filename>.
  1169. </para>
  1170. <note>
  1171. See the
  1172. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  1173. section in the Yocto Project Reference Manual for a complete
  1174. list of image features that ship with the Yocto Project.
  1175. </note>
  1176. </section>
  1177. <section id='usingpoky-extend-customimage-custombb'>
  1178. <title>Customizing Images Using Custom .bb Files</title>
  1179. <para>
  1180. You can also customize an image by creating a custom recipe
  1181. that defines additional software as part of the image.
  1182. The following example shows the form for the two lines you need:
  1183. <literallayout class='monospaced'>
  1184. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  1185. inherit core-image
  1186. </literallayout>
  1187. </para>
  1188. <para>
  1189. Defining the software using a custom recipe gives you total
  1190. control over the contents of the image.
  1191. It is important to use the correct names of packages in the
  1192. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1193. variable.
  1194. You must use the OpenEmbedded notation and not the Debian notation for the names
  1195. (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>).
  1196. </para>
  1197. <para>
  1198. The other method for creating a custom image is to base it on an existing image.
  1199. For example, if you want to create an image based on <filename>core-image-sato</filename>
  1200. but add the additional package <filename>strace</filename> to the image,
  1201. copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a
  1202. new <filename>.bb</filename> and add the following line to the end of the copy:
  1203. <literallayout class='monospaced'>
  1204. IMAGE_INSTALL += "strace"
  1205. </literallayout>
  1206. </para>
  1207. </section>
  1208. <section id='usingpoky-extend-customimage-customtasks'>
  1209. <title>Customizing Images Using Custom Package Groups</title>
  1210. <para>
  1211. For complex custom images, the best approach for customizing
  1212. an image is to create a custom package group recipe that is
  1213. used to build the image or images.
  1214. A good example of a package group recipe is
  1215. <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>.
  1216. </para>
  1217. <para>
  1218. If you examine that recipe, you see that the
  1219. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename>
  1220. variable lists the package group packages to produce.
  1221. The <filename>inherit packagegroup</filename> statement
  1222. sets appropriate default values and automatically adds
  1223. <filename>-dev</filename>, <filename>-dbg</filename>, and
  1224. <filename>-ptest</filename> complementary packages for each
  1225. package specified in the <filename>PACKAGES</filename>
  1226. statement.
  1227. <note>
  1228. The <filename>inherit packages</filename> should be
  1229. located near the top of the recipe, certainly before
  1230. the <filename>PACKAGES</filename> statement.
  1231. </note>
  1232. </para>
  1233. <para>
  1234. For each package you specify in <filename>PACKAGES</filename>,
  1235. you can use
  1236. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename>
  1237. and
  1238. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename>
  1239. entries to provide a list of packages the parent task package
  1240. should contain.
  1241. You can see examples of these further down in the
  1242. <filename>packagegroup-base.bb</filename> recipe.
  1243. </para>
  1244. <para>
  1245. Here is a short, fabricated example showing the same basic
  1246. pieces:
  1247. <literallayout class='monospaced'>
  1248. DESCRIPTION = "My Custom Package Groups"
  1249. inherit packagegroup
  1250. PACKAGES = "\
  1251. packagegroup-custom-apps \
  1252. packagegroup-custom-tools \
  1253. "
  1254. RDEPENDS_packagegroup-custom-apps = "\
  1255. dropbear \
  1256. portmap \
  1257. psplash"
  1258. RDEPENDS_packagegroup-custom-tools = "\
  1259. oprofile \
  1260. oprofileui-server \
  1261. lttng-tools"
  1262. RRECOMMENDS_packagegroup-custom-tools = "\
  1263. kernel-module-oprofile"
  1264. </literallayout>
  1265. </para>
  1266. <para>
  1267. In the previous example, two package group packages are created with their dependencies and their
  1268. recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and
  1269. <filename>packagegroup-custom-tools</filename>.
  1270. To build an image using these package group packages, you need to add
  1271. <filename>packagegroup-custom-apps</filename> and/or
  1272. <filename>packagegroup-custom-tools</filename> to
  1273. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>.
  1274. For other forms of image dependencies see the other areas of this section.
  1275. </para>
  1276. </section>
  1277. <section id='usingpoky-extend-customimage-image-name'>
  1278. <title>Customizing an Image Hostname</title>
  1279. <para>
  1280. By default, the configured hostname (i.e.
  1281. <filename>/etc/hostname</filename>) in an image is the
  1282. same as the machine name.
  1283. For example, if
  1284. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  1285. equals "qemux86", the configured hostname written to
  1286. <filename>/etc/hostname</filename> is "qemux86".
  1287. </para>
  1288. <para>
  1289. You can customize this name by altering the value of the
  1290. "hostname" variable in the
  1291. <filename>base-files</filename> recipe using either
  1292. an append file or a configuration file.
  1293. Use the following in an append file:
  1294. <literallayout class='monospaced'>
  1295. hostname="myhostname"
  1296. </literallayout>
  1297. Use the following in a configuration file:
  1298. <literallayout class='monospaced'>
  1299. hostname_pn-base-files = "myhostname"
  1300. </literallayout>
  1301. </para>
  1302. <para>
  1303. Changing the default value of the variable "hostname" can be
  1304. useful in certain situations.
  1305. For example, suppose you need to do extensive testing on an
  1306. image and you would like to easily identify the image
  1307. under test from existing images with typical default
  1308. hostnames.
  1309. In this situation, you could change the default hostname to
  1310. "testme", which results in all the images using the name
  1311. "testme".
  1312. Once testing is complete and you do not need to rebuild the
  1313. image for test any longer, you can easily reset the default
  1314. hostname.
  1315. </para>
  1316. <para>
  1317. Another point of interest is that if you unset the variable,
  1318. the image will have no default hostname in the filesystem.
  1319. Here is an example that unsets the variable in a
  1320. configuration file:
  1321. <literallayout class='monospaced'>
  1322. hostname_pn-base-files = ""
  1323. </literallayout>
  1324. Having no default hostname in the filesystem is suitable for
  1325. environments that use dynamic hostnames such as virtual
  1326. machines.
  1327. </para>
  1328. </section>
  1329. </section>
  1330. <section id='new-recipe-writing-a-new-recipe'>
  1331. <title>Writing a New Recipe</title>
  1332. <para>
  1333. Recipes (<filename>.bb</filename> files) are fundamental components
  1334. in the Yocto Project environment.
  1335. Each software component built by the OpenEmbedded build system
  1336. requires a recipe to define the component.
  1337. This section describes how to create, write, and test a new
  1338. recipe.
  1339. <note>
  1340. For information on variables that are useful for recipes and
  1341. for information about recipe naming issues, see the
  1342. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>"
  1343. section of the Yocto Project Reference Manual.
  1344. </note>
  1345. </para>
  1346. <section id='new-recipe-overview'>
  1347. <title>Overview</title>
  1348. <para>
  1349. The following figure shows the basic process for creating a
  1350. new recipe.
  1351. The remainder of the section provides details for the steps.
  1352. <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" />
  1353. </para>
  1354. </section>
  1355. <section id='new-recipe-locate-or-automatically-create-a-base-recipe'>
  1356. <title>Locate or Automatically Create a Base Recipe</title>
  1357. <para>
  1358. You can always write a recipe from scratch.
  1359. However, three choices exist that can help you quickly get a
  1360. start on a new recipe:
  1361. <itemizedlist>
  1362. <listitem><para>
  1363. <emphasis><filename>devtool add</filename>:</emphasis>
  1364. A command that assists in creating a recipe and
  1365. an environment conducive to development.
  1366. </para></listitem>
  1367. <listitem><para>
  1368. <emphasis><filename>recipetool create</filename>:</emphasis>
  1369. A command provided by the Yocto Project that automates
  1370. creation of a base recipe based on the source
  1371. files.
  1372. </para></listitem>
  1373. <listitem><para>
  1374. <emphasis>Existing Recipes:</emphasis>
  1375. Location and modification of an existing recipe that is
  1376. similar in function to the recipe you need.
  1377. </para></listitem>
  1378. </itemizedlist>
  1379. </para>
  1380. <section id='new-recipe-creating-the-base-recipe-using-devtool'>
  1381. <title>Creating the Base Recipe Using <filename>devtool add</filename></title>
  1382. <para>
  1383. The <filename>devtool add</filename> command uses the same
  1384. logic for auto-creating the recipe as
  1385. <filename>recipetool create</filename>, which is listed
  1386. below.
  1387. Additionally, however, <filename>devtool add</filename>
  1388. sets up an environment that makes it easy for you to
  1389. patch the source and to make changes to the recipe as
  1390. is often necessary when adding a recipe to build a new
  1391. piece of software to be included in a build.
  1392. </para>
  1393. <para>
  1394. You can find a complete description of the
  1395. <filename>devtool add</filename> command in the
  1396. "<link linkend='use-devtool-to-integrate-new-code'>Use <filename>devtool add</filename> to Add an Application</link>"
  1397. section.
  1398. </para>
  1399. </section>
  1400. <section id='new-recipe-creating-the-base-recipe-using-recipetool'>
  1401. <title>Creating the Base Recipe Using <filename>recipetool create</filename></title>
  1402. <para>
  1403. <filename>recipetool create</filename> automates creation
  1404. of a base recipe given a set of source code files.
  1405. As long as you can extract or point to the source files,
  1406. the tool will construct a recipe and automatically
  1407. configure all pre-build information into the recipe.
  1408. For example, suppose you have an application that builds
  1409. using Autotools.
  1410. Creating the base recipe using
  1411. <filename>recipetool</filename> results in a recipe
  1412. that has the pre-build dependencies, license requirements,
  1413. and checksums configured.
  1414. </para>
  1415. <para>
  1416. To run the tool, you just need to be in your
  1417. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1418. and have sourced the build environment setup script
  1419. (i.e.
  1420. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
  1421. or
  1422. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>).
  1423. Here is the basic <filename>recipetool</filename> syntax:
  1424. <note>
  1425. Running <filename>recipetool -h</filename> or
  1426. <filename>recipetool create -h</filename> produces the
  1427. Python-generated help, which presented differently
  1428. than what follows here.
  1429. </note>
  1430. <literallayout class='monospaced'>
  1431. recipetool -h
  1432. recipetool create [-h]
  1433. recipetool [-d] [-q] [--color auto | always | never ] create -o <replaceable>OUTFILE</replaceable> [-m] [-x <replaceable>EXTERNALSRC</replaceable>] <replaceable>source</replaceable>
  1434. -d Enables debug output.
  1435. -q Outputs only errors (quiet mode).
  1436. --color Colorizes the output automatically, always, or never.
  1437. -h Displays Python generated syntax for recipetool.
  1438. create Causes recipetool to create a base recipe. The create
  1439. command is further defined with these options:
  1440. -o <replaceable>OUTFILE</replaceable> Specifies the full path and filename for the generated
  1441. recipe.
  1442. -m Causes the recipe to be machine-specific rather than
  1443. architecture-specific (default).
  1444. -x <replaceable>EXTERNALSRC</replaceable> Fetches and extracts source files from <replaceable>source</replaceable>
  1445. and places them in <replaceable>EXTERNALSRC</replaceable>.
  1446. <replaceable>source</replaceable> must be a URL.
  1447. -h Displays Python-generated syntax for create.
  1448. <replaceable>source</replaceable> Specifies the source code on which to base the
  1449. recipe.
  1450. </literallayout>
  1451. </para>
  1452. <para>
  1453. Running <filename>recipetool create -o</filename>&nbsp;<replaceable>OUTFILE</replaceable>
  1454. creates the base recipe and locates it properly in the
  1455. layer that contains your source files.
  1456. Following are some syntax examples:
  1457. </para>
  1458. <para>
  1459. Use this syntax to generate a recipe based on <replaceable>source</replaceable>.
  1460. Once generated, the recipe resides in the existing source
  1461. code layer:
  1462. <literallayout class='monospaced'>
  1463. recipetool create -o <replaceable>OUTFILE</replaceable>&nbsp;<replaceable>source</replaceable>
  1464. </literallayout>
  1465. Use this syntax to generate a recipe using code that you
  1466. extract from <replaceable>source</replaceable>.
  1467. The extracted code is placed in its own layer defined
  1468. by <replaceable>EXTERNALSRC</replaceable>.
  1469. <literallayout class='monospaced'>
  1470. recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable>
  1471. </literallayout>
  1472. Use this syntax to generate a recipe based on <replaceable>source</replaceable>.
  1473. The options direct <filename>recipetool</filename> to
  1474. generate debugging information.
  1475. Once generated, the recipe resides in the existing source
  1476. code layer:
  1477. <literallayout class='monospaced'>
  1478. recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable>
  1479. </literallayout>
  1480. </para>
  1481. </section>
  1482. <section id='new-recipe-locating-and-using-a-similar-recipe'>
  1483. <title>Locating and Using a Similar Recipe</title>
  1484. <para>
  1485. Before writing a recipe from scratch, it is often useful to
  1486. discover whether someone else has already written one that
  1487. meets (or comes close to meeting) your needs.
  1488. The Yocto Project and OpenEmbedded communities maintain many
  1489. recipes that might be candidates for what you are doing.
  1490. You can find a good central index of these recipes in the
  1491. <ulink url='http://layers.openembedded.org'>OpenEmbedded metadata index</ulink>.
  1492. </para>
  1493. <para>
  1494. Working from an existing recipe or a skeleton recipe is the
  1495. best way to get started.
  1496. Here are some points on both methods:
  1497. <itemizedlist>
  1498. <listitem><para><emphasis>Locate and modify a recipe that
  1499. is close to what you want to do:</emphasis>
  1500. This method works when you are familiar with the
  1501. current recipe space.
  1502. The method does not work so well for those new to
  1503. the Yocto Project or writing recipes.</para>
  1504. <para>Some risks associated with this method are
  1505. using a recipe that has areas totally unrelated to
  1506. what you are trying to accomplish with your recipe,
  1507. not recognizing areas of the recipe that you might
  1508. have to add from scratch, and so forth.
  1509. All these risks stem from unfamiliarity with the
  1510. existing recipe space.</para></listitem>
  1511. <listitem><para><emphasis>Use and modify the following
  1512. skeleton recipe:</emphasis>
  1513. If for some reason you do not want to use
  1514. <filename>recipetool</filename> and you cannot
  1515. find an existing recipe that is close to meeting
  1516. your needs, you can use the following structure to
  1517. provide the fundamental areas of a new recipe.
  1518. <literallayout class='monospaced'>
  1519. DESCRIPTION = ""
  1520. HOMEPAGE = ""
  1521. LICENSE = ""
  1522. SECTION = ""
  1523. DEPENDS = ""
  1524. LIC_FILES_CHKSUM = ""
  1525. SRC_URI = ""
  1526. </literallayout>
  1527. </para></listitem>
  1528. </itemizedlist>
  1529. </para>
  1530. </section>
  1531. </section>
  1532. <section id='new-recipe-storing-and-naming-the-recipe'>
  1533. <title>Storing and Naming the Recipe</title>
  1534. <para>
  1535. Once you have your base recipe, you should put it in your
  1536. own layer and name it appropriately.
  1537. Locating it correctly ensures that the OpenEmbedded build
  1538. system can find it when you use BitBake to process the
  1539. recipe.
  1540. </para>
  1541. <itemizedlist>
  1542. <listitem><para><emphasis>Storing Your Recipe:</emphasis>
  1543. The OpenEmbedded build system locates your recipe
  1544. through the layer's <filename>conf/layer.conf</filename>
  1545. file and the
  1546. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>
  1547. variable.
  1548. This variable sets up a path from which the build system can
  1549. locate recipes.
  1550. Here is the typical use:
  1551. <literallayout class='monospaced'>
  1552. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  1553. ${LAYERDIR}/recipes-*/*/*.bbappend"
  1554. </literallayout>
  1555. Consequently, you need to be sure you locate your new recipe
  1556. inside your layer such that it can be found.</para>
  1557. <para>You can find more information on how layers are
  1558. structured in the
  1559. "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
  1560. section.</para></listitem>
  1561. <listitem><para><emphasis>Naming Your Recipe:</emphasis>
  1562. When you name your recipe, you need to follow this naming
  1563. convention:
  1564. <literallayout class='monospaced'>
  1565. <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb
  1566. </literallayout>
  1567. Use lower-cased characters and do not include the reserved
  1568. suffixes <filename>-native</filename>,
  1569. <filename>-cross</filename>, <filename>-initial</filename>,
  1570. or <filename>-dev</filename> casually (i.e. do not use them
  1571. as part of your recipe name unless the string applies).
  1572. Here are some examples:
  1573. <literallayout class='monospaced'>
  1574. cups_1.7.0.bb
  1575. gawk_4.0.2.bb
  1576. irssi_0.8.16-rc1.bb
  1577. </literallayout></para></listitem>
  1578. </itemizedlist>
  1579. </section>
  1580. <section id='understanding-recipe-syntax'>
  1581. <title>Understanding Recipe Syntax</title>
  1582. <para>
  1583. Understanding recipe file syntax is important for
  1584. writing recipes.
  1585. The following list overviews the basic items that make up a
  1586. BitBake recipe file.
  1587. For more complete BitBake syntax descriptions, see the
  1588. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  1589. chapter of the BitBake User Manual.
  1590. <itemizedlist>
  1591. <listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis>
  1592. Variable assignments allow a value to be assigned to a
  1593. variable.
  1594. The assignment can be static text or might include
  1595. the contents of other variables.
  1596. In addition to the assignment, appending and prepending
  1597. operations are also supported.</para>
  1598. <para>The following example shows some of the ways
  1599. you can use variables in recipes:
  1600. <literallayout class='monospaced'>
  1601. S = "${WORKDIR}/postfix-${PV}"
  1602. CFLAGS += "-DNO_ASM"
  1603. SRC_URI_append = " file://fixup.patch"
  1604. </literallayout>
  1605. </para></listitem>
  1606. <listitem><para><emphasis>Functions:</emphasis>
  1607. Functions provide a series of actions to be performed.
  1608. You usually use functions to override the default
  1609. implementation of a task function or to complement
  1610. a default function (i.e. append or prepend to an
  1611. existing function).
  1612. Standard functions use <filename>sh</filename> shell
  1613. syntax, although access to OpenEmbedded variables and
  1614. internal methods are also available.</para>
  1615. <para>The following is an example function from the
  1616. <filename>sed</filename> recipe:
  1617. <literallayout class='monospaced'>
  1618. do_install () {
  1619. autotools_do_install
  1620. install -d ${D}${base_bindir}
  1621. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  1622. rmdir ${D}${bindir}/
  1623. }
  1624. </literallayout>
  1625. It is also possible to implement new functions that
  1626. are called between existing tasks as long as the
  1627. new functions are not replacing or complementing the
  1628. default functions.
  1629. You can implement functions in Python
  1630. instead of shell.
  1631. Both of these options are not seen in the majority of
  1632. recipes.</para></listitem>
  1633. <listitem><para><emphasis>Keywords:</emphasis>
  1634. BitBake recipes use only a few keywords.
  1635. You use keywords to include common
  1636. functions (<filename>inherit</filename>), load parts
  1637. of a recipe from other files
  1638. (<filename>include</filename> and
  1639. <filename>require</filename>) and export variables
  1640. to the environment (<filename>export</filename>).</para>
  1641. <para>The following example shows the use of some of
  1642. these keywords:
  1643. <literallayout class='monospaced'>
  1644. export POSTCONF = "${STAGING_BINDIR}/postconf"
  1645. inherit autoconf
  1646. require otherfile.inc
  1647. </literallayout>
  1648. </para></listitem>
  1649. <listitem><para><emphasis>Comments:</emphasis>
  1650. Any lines that begin with the hash character
  1651. (<filename>#</filename>) are treated as comment lines
  1652. and are ignored:
  1653. <literallayout class='monospaced'>
  1654. # This is a comment
  1655. </literallayout>
  1656. </para></listitem>
  1657. </itemizedlist>
  1658. </para>
  1659. <para>
  1660. This next list summarizes the most important and most commonly
  1661. used parts of the recipe syntax.
  1662. For more information on these parts of the syntax, you can
  1663. reference the
  1664. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>
  1665. chapter in the BitBake User Manual.
  1666. <itemizedlist>
  1667. <listitem><para><emphasis>Line Continuation: <filename>\</filename></emphasis> -
  1668. Use the backward slash (<filename>\</filename>)
  1669. character to split a statement over multiple lines.
  1670. Place the slash character at the end of the line that
  1671. is to be continued on the next line:
  1672. <literallayout class='monospaced'>
  1673. VAR = "A really long \
  1674. line"
  1675. </literallayout>
  1676. <note>
  1677. You cannot have any characters including spaces
  1678. or tabs after the slash character.
  1679. </note>
  1680. </para></listitem>
  1681. <listitem><para>
  1682. <emphasis>Using Variables: <filename>${...}</filename></emphasis> -
  1683. Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> syntax to
  1684. access the contents of a variable:
  1685. <literallayout class='monospaced'>
  1686. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  1687. </literallayout>
  1688. <note>
  1689. It is important to understand that the value of a
  1690. variable expressed in this form does not get
  1691. substituted automatically.
  1692. The expansion of these expressions happens
  1693. on-demand later (e.g. usually when a function that
  1694. makes reference to the variable executes).
  1695. This behavior ensures that the values are most
  1696. appropriate for the context in which they are
  1697. finally used.
  1698. On the rare occasion that you do need the variable
  1699. expression to be expanded immediately, you can use
  1700. the <filename>:=</filename> operator instead of
  1701. <filename>=</filename> when you make the
  1702. assignment, but this is not generally needed.
  1703. </note>
  1704. </para></listitem>
  1705. <listitem><para><emphasis>Quote All Assignments: <filename>"<replaceable>value</replaceable>"</filename></emphasis> -
  1706. Use double quotes around the value in all variable
  1707. assignments.
  1708. <literallayout class='monospaced'>
  1709. VAR1 = "${OTHERVAR}"
  1710. VAR2 = "The version is ${PV}"
  1711. </literallayout>
  1712. </para></listitem>
  1713. <listitem><para><emphasis>Conditional Assignment: <filename>?=</filename></emphasis> -
  1714. Conditional assignment is used to assign a value to
  1715. a variable, but only when the variable is currently
  1716. unset.
  1717. Use the question mark followed by the equal sign
  1718. (<filename>?=</filename>) to make a "soft" assignment
  1719. used for conditional assignment.
  1720. Typically, "soft" assignments are used in the
  1721. <filename>local.conf</filename> file for variables
  1722. that are allowed to come through from the external
  1723. environment.
  1724. </para>
  1725. <para>Here is an example where
  1726. <filename>VAR1</filename> is set to "New value" if
  1727. it is currently empty.
  1728. However, if <filename>VAR1</filename> has already been
  1729. set, it remains unchanged:
  1730. <literallayout class='monospaced'>
  1731. VAR1 ?= "New value"
  1732. </literallayout>
  1733. In this next example, <filename>VAR1</filename>
  1734. is left with the value "Original value":
  1735. <literallayout class='monospaced'>
  1736. VAR1 = "Original value"
  1737. VAR1 ?= "New value"
  1738. </literallayout>
  1739. </para></listitem>
  1740. <listitem><para><emphasis>Appending: <filename>+=</filename></emphasis> -
  1741. Use the plus character followed by the equals sign
  1742. (<filename>+=</filename>) to append values to existing
  1743. variables.
  1744. <note>
  1745. This operator adds a space between the existing
  1746. content of the variable and the new content.
  1747. </note></para>
  1748. <para>Here is an example:
  1749. <literallayout class='monospaced'>
  1750. SRC_URI += "file://fix-makefile.patch"
  1751. </literallayout>
  1752. </para></listitem>
  1753. <listitem><para><emphasis>Prepending: <filename>=+</filename></emphasis> -
  1754. Use the equals sign followed by the plus character
  1755. (<filename>=+</filename>) to prepend values to existing
  1756. variables.
  1757. <note>
  1758. This operator adds a space between the new content
  1759. and the existing content of the variable.
  1760. </note></para>
  1761. <para>Here is an example:
  1762. <literallayout class='monospaced'>
  1763. VAR =+ "Starts"
  1764. </literallayout>
  1765. </para></listitem>
  1766. <listitem><para><emphasis>Appending: <filename>_append</filename></emphasis> -
  1767. Use the <filename>_append</filename> operator to
  1768. append values to existing variables.
  1769. This operator does not add any additional space.
  1770. Also, the operator is applied after all the
  1771. <filename>+=</filename>, and
  1772. <filename>=+</filename> operators have been applied and
  1773. after all <filename>=</filename> assignments have
  1774. occurred.
  1775. </para>
  1776. <para>The following example shows the space being
  1777. explicitly added to the start to ensure the appended
  1778. value is not merged with the existing value:
  1779. <literallayout class='monospaced'>
  1780. SRC_URI_append = " file://fix-makefile.patch"
  1781. </literallayout>
  1782. You can also use the <filename>_append</filename>
  1783. operator with overrides, which results in the actions
  1784. only being performed for the specified target or
  1785. machine:
  1786. <literallayout class='monospaced'>
  1787. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  1788. </literallayout>
  1789. </para></listitem>
  1790. <listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> -
  1791. Use the <filename>_prepend</filename> operator to
  1792. prepend values to existing variables.
  1793. This operator does not add any additional space.
  1794. Also, the operator is applied after all the
  1795. <filename>+=</filename>, and
  1796. <filename>=+</filename> operators have been applied and
  1797. after all <filename>=</filename> assignments have
  1798. occurred.
  1799. </para>
  1800. <para>The following example shows the space being
  1801. explicitly added to the end to ensure the prepended
  1802. value is not merged with the existing value:
  1803. <literallayout class='monospaced'>
  1804. CFLAGS_prepend = "-I${S}/myincludes "
  1805. </literallayout>
  1806. You can also use the <filename>_prepend</filename>
  1807. operator with overrides, which results in the actions
  1808. only being performed for the specified target or
  1809. machine:
  1810. <literallayout class='monospaced'>
  1811. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  1812. </literallayout>
  1813. </para></listitem>
  1814. <listitem><para><emphasis>Overrides:</emphasis> -
  1815. You can use overrides to set a value conditionally,
  1816. typically based on how the recipe is being built.
  1817. For example, to set the
  1818. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  1819. variable's value to "standard/base" for any target
  1820. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  1821. except for qemuarm where it should be set to
  1822. "standard/arm-versatile-926ejs", you would do the
  1823. following:
  1824. <literallayout class='monospaced'>
  1825. KBRANCH = "standard/base"
  1826. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  1827. </literallayout>
  1828. Overrides are also used to separate alternate values
  1829. of a variable in other situations.
  1830. For example, when setting variables such as
  1831. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  1832. and
  1833. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  1834. that are specific to individual packages produced by
  1835. a recipe, you should always use an override that
  1836. specifies the name of the package.
  1837. </para></listitem>
  1838. <listitem><para><emphasis>Indentation:</emphasis>
  1839. Use spaces for indentation rather than than tabs.
  1840. For shell functions, both currently work.
  1841. However, it is a policy decision of the Yocto Project
  1842. to use tabs in shell functions.
  1843. Realize that some layers have a policy to use spaces
  1844. for all indentation.
  1845. </para></listitem>
  1846. <listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<replaceable>python_code</replaceable>}</filename></emphasis> -
  1847. For more advanced processing, it is possible to use
  1848. Python code during variable assignments (e.g.
  1849. search and replacement on a variable).</para>
  1850. <para>You indicate Python code using the
  1851. <filename>${@<replaceable>python_code</replaceable>}</filename>
  1852. syntax for the variable assignment:
  1853. <literallayout class='monospaced'>
  1854. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  1855. </literallayout>
  1856. </para></listitem>
  1857. <listitem><para><emphasis>Shell Function Syntax:</emphasis>
  1858. Write shell functions as if you were writing a shell
  1859. script when you describe a list of actions to take.
  1860. You should ensure that your script works with a generic
  1861. <filename>sh</filename> and that it does not require
  1862. any <filename>bash</filename> or other shell-specific
  1863. functionality.
  1864. The same considerations apply to various system
  1865. utilities (e.g. <filename>sed</filename>,
  1866. <filename>grep</filename>, <filename>awk</filename>,
  1867. and so forth) that you might wish to use.
  1868. If in doubt, you should check with multiple
  1869. implementations - including those from BusyBox.
  1870. </para></listitem>
  1871. </itemizedlist>
  1872. </para>
  1873. </section>
  1874. <section id='new-recipe-running-a-build-on-the-recipe'>
  1875. <title>Running a Build on the Recipe</title>
  1876. <para>
  1877. Creating a new recipe is usually an iterative process that
  1878. requires using BitBake to process the recipe multiple times in
  1879. order to progressively discover and add information to the
  1880. recipe file.
  1881. </para>
  1882. <para>
  1883. Assuming you have sourced a build environment setup script (i.e.
  1884. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  1885. or
  1886. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  1887. and you are in the
  1888. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  1889. use BitBake to process your recipe.
  1890. All you need to provide is the
  1891. <filename><replaceable>basename</replaceable></filename> of the recipe as described
  1892. in the previous section:
  1893. <literallayout class='monospaced'>
  1894. $ bitbake <replaceable>basename</replaceable>
  1895. </literallayout>
  1896. </para>
  1897. <para>
  1898. During the build, the OpenEmbedded build system creates a
  1899. temporary work directory for each recipe
  1900. (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>)
  1901. where it keeps extracted source files, log files, intermediate
  1902. compilation and packaging files, and so forth.
  1903. </para>
  1904. <para>
  1905. The path to the per-recipe temporary work directory depends
  1906. on the context in which it is being built.
  1907. The quickest way to find this path is to have BitBake return it
  1908. by running the following:
  1909. <literallayout class='monospaced'>
  1910. $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR=
  1911. </literallayout>
  1912. As an example, assume a Source Directory top-level folder named
  1913. <filename>poky</filename>, a default Build Directory at
  1914. <filename>poky/build</filename>, and a
  1915. <filename>qemux86-poky-linux</filename> machine target system.
  1916. Furthermore, suppose your recipe is named
  1917. <filename>foo_1.3.0.bb</filename>.
  1918. In this case, the work directory the build system uses to
  1919. build the package would be as follows:
  1920. <literallayout class='monospaced'>
  1921. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1922. </literallayout>
  1923. Inside this directory you can find sub-directories such as
  1924. <filename>image</filename>, <filename>packages-split</filename>,
  1925. and <filename>temp</filename>.
  1926. After the build, you can examine these to determine how well
  1927. the build went.
  1928. <note>
  1929. You can find log files for each task in the recipe's
  1930. <filename>temp</filename> directory (e.g.
  1931. <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>).
  1932. Log files are named <filename>log.<replaceable>taskname</replaceable></filename>
  1933. (e.g. <filename>log.do_configure</filename>,
  1934. <filename>log.do_fetch</filename>, and
  1935. <filename>log.do_compile</filename>).
  1936. </note>
  1937. </para>
  1938. <para>
  1939. You can find more information about the build process in the
  1940. "<ulink url='&YOCTO_DOCS_REF_URL;#closer-look'>A Closer Look at the Yocto Project Development Environment</ulink>"
  1941. chapter of the Yocto Project Reference Manual.
  1942. </para>
  1943. </section>
  1944. <section id='new-recipe-fetching-code'>
  1945. <title>Fetching Code</title>
  1946. <para>
  1947. The first thing your recipe must do is specify how to fetch
  1948. the source files.
  1949. Fetching is controlled mainly through the
  1950. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1951. variable.
  1952. Your recipe must have a <filename>SRC_URI</filename> variable
  1953. that points to where the source is located.
  1954. For a graphical representation of source locations, see the
  1955. "<ulink url='&YOCTO_DOCS_REF_URL;#sources-dev-environment'>Sources</ulink>"
  1956. section in the Yocto Project Reference Manual.
  1957. </para>
  1958. <para>
  1959. The
  1960. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1961. task uses the prefix of each entry in the
  1962. <filename>SRC_URI</filename> variable value to determine which
  1963. fetcher to use to get your source files.
  1964. It is the <filename>SRC_URI</filename> variable that triggers
  1965. the fetcher.
  1966. The
  1967. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1968. task uses the variable after source is fetched to apply
  1969. patches.
  1970. The OpenEmbedded build system uses
  1971. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink>
  1972. for scanning directory locations for local files in
  1973. <filename>SRC_URI</filename>.
  1974. </para>
  1975. <para>
  1976. The <filename>SRC_URI</filename> variable in your recipe must
  1977. define each unique location for your source files.
  1978. It is good practice to not hard-code pathnames in an URL used
  1979. in <filename>SRC_URI</filename>.
  1980. Rather than hard-code these paths, use
  1981. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1982. which causes the fetch process to use the version specified in
  1983. the recipe filename.
  1984. Specifying the version in this manner means that upgrading the
  1985. recipe to a future version is as simple as renaming the recipe
  1986. to match the new version.
  1987. </para>
  1988. <para>
  1989. Here is a simple example from the
  1990. <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename>
  1991. recipe where the source comes from a single tarball.
  1992. Notice the use of the
  1993. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1994. variable:
  1995. <literallayout class='monospaced'>
  1996. SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2"
  1997. </literallayout>
  1998. </para>
  1999. <para>
  2000. Files mentioned in <filename>SRC_URI</filename> whose names end
  2001. in a typical archive extension (e.g. <filename>.tar</filename>,
  2002. <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>,
  2003. <filename>.zip</filename>, and so forth), are automatically
  2004. extracted during the
  2005. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  2006. task.
  2007. For another example that specifies these types of files, see
  2008. the
  2009. "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>"
  2010. section.
  2011. </para>
  2012. <para>
  2013. Another way of specifying source is from an SCM.
  2014. For Git repositories, you must specify
  2015. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  2016. and you should specify
  2017. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2018. to include the revision with
  2019. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  2020. Here is an example from the recipe
  2021. <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>:
  2022. <literallayout class='monospaced'>
  2023. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  2024. PR = "r6"
  2025. PV = "1.0.5+git${SRCPV}"
  2026. SRC_URI = "git://git.kernel.dk/blktrace.git \
  2027. file://ldflags.patch"
  2028. </literallayout>
  2029. </para>
  2030. <para>
  2031. If your <filename>SRC_URI</filename> statement includes
  2032. URLs pointing to individual files fetched from a remote server
  2033. other than a version control system, BitBake attempts to
  2034. verify the files against checksums defined in your recipe to
  2035. ensure they have not been tampered with or otherwise modified
  2036. since the recipe was written.
  2037. Two checksums are used:
  2038. <filename>SRC_URI[md5sum]</filename> and
  2039. <filename>SRC_URI[sha256sum]</filename>.
  2040. </para>
  2041. <para>
  2042. If your <filename>SRC_URI</filename> variable points to
  2043. more than a single URL (excluding SCM URLs), you need to
  2044. provide the <filename>md5</filename> and
  2045. <filename>sha256</filename> checksums for each URL.
  2046. For these cases, you provide a name for each URL as part of
  2047. the <filename>SRC_URI</filename> and then reference that name
  2048. in the subsequent checksum statements.
  2049. Here is an example:
  2050. <literallayout class='monospaced'>
  2051. SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \
  2052. ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch"
  2053. SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
  2054. SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
  2055. SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92"
  2056. SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
  2057. </literallayout>
  2058. </para>
  2059. <para>
  2060. Proper values for <filename>md5</filename> and
  2061. <filename>sha256</filename> checksums might be available
  2062. with other signatures on the download page for the upstream
  2063. source (e.g. <filename>md5</filename>,
  2064. <filename>sha1</filename>, <filename>sha256</filename>,
  2065. <filename>GPG</filename>, and so forth).
  2066. Because the OpenEmbedded build system only deals with
  2067. <filename>sha256sum</filename> and <filename>md5sum</filename>,
  2068. you should verify all the signatures you find by hand.
  2069. </para>
  2070. <para>
  2071. If no <filename>SRC_URI</filename> checksums are specified
  2072. when you attempt to build the recipe, or you provide an
  2073. incorrect checksum, the build will produce an error for each
  2074. missing or incorrect checksum.
  2075. As part of the error message, the build system provides
  2076. the checksum string corresponding to the fetched file.
  2077. Once you have the correct checksums, you can copy and paste
  2078. them into your recipe and then run the build again to continue.
  2079. <note>
  2080. As mentioned, if the upstream source provides signatures
  2081. for verifying the downloaded source code, you should
  2082. verify those manually before setting the checksum values
  2083. in the recipe and continuing with the build.
  2084. </note>
  2085. </para>
  2086. <para>
  2087. This final example is a bit more complicated and is from the
  2088. <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename>
  2089. recipe.
  2090. The example's <filename>SRC_URI</filename> statement identifies
  2091. multiple files as the source files for the recipe: a tarball, a
  2092. patch file, a desktop file, and an icon.
  2093. <literallayout class='monospaced'>
  2094. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  2095. file://xwc.patch \
  2096. file://rxvt.desktop \
  2097. file://rxvt.png"
  2098. </literallayout>
  2099. </para>
  2100. <para>
  2101. When you specify local files using the
  2102. <filename>file://</filename> URI protocol, the build system
  2103. fetches files from the local machine.
  2104. The path is relative to the
  2105. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  2106. variable and searches specific directories in a certain order:
  2107. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>,
  2108. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>,
  2109. and <filename>files</filename>.
  2110. The directories are assumed to be subdirectories of the
  2111. directory in which the recipe or append file resides.
  2112. For another example that specifies these types of files, see the
  2113. "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>"
  2114. section.
  2115. </para>
  2116. <para>
  2117. The previous example also specifies a patch file.
  2118. Patch files are files whose names usually end in
  2119. <filename>.patch</filename> or <filename>.diff</filename> but
  2120. can end with compressed suffixes such as
  2121. <filename>diff.gz</filename> and
  2122. <filename>patch.bz2</filename>, for example.
  2123. The build system automatically applies patches as described
  2124. in the
  2125. "<link linkend='new-recipe-patching-code'>Patching Code</link>" section.
  2126. </para>
  2127. </section>
  2128. <section id='new-recipe-unpacking-code'>
  2129. <title>Unpacking Code</title>
  2130. <para>
  2131. During the build, the
  2132. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  2133. task unpacks the source with
  2134. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>
  2135. pointing to where it is unpacked.
  2136. </para>
  2137. <para>
  2138. If you are fetching your source files from an upstream source
  2139. archived tarball and the tarball's internal structure matches
  2140. the common convention of a top-level subdirectory named
  2141. <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>,
  2142. then you do not need to set <filename>S</filename>.
  2143. However, if <filename>SRC_URI</filename> specifies to fetch
  2144. source from an archive that does not use this convention,
  2145. or from an SCM like Git or Subversion, your recipe needs to
  2146. define <filename>S</filename>.
  2147. </para>
  2148. <para>
  2149. If processing your recipe using BitBake successfully unpacks
  2150. the source files, you need to be sure that the directory
  2151. pointed to by <filename>${S}</filename> matches the structure
  2152. of the source.
  2153. </para>
  2154. </section>
  2155. <section id='new-recipe-patching-code'>
  2156. <title>Patching Code</title>
  2157. <para>
  2158. Sometimes it is necessary to patch code after it has been
  2159. fetched.
  2160. Any files mentioned in <filename>SRC_URI</filename> whose
  2161. names end in <filename>.patch</filename> or
  2162. <filename>.diff</filename> or compressed versions of these
  2163. suffixes (e.g. <filename>diff.gz</filename> are treated as
  2164. patches.
  2165. The
  2166. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  2167. task automatically applies these patches.
  2168. </para>
  2169. <para>
  2170. The build system should be able to apply patches with the "-p1"
  2171. option (i.e. one directory level in the path will be stripped
  2172. off).
  2173. If your patch needs to have more directory levels stripped off,
  2174. specify the number of levels using the "striplevel" option in
  2175. the <filename>SRC_URI</filename> entry for the patch.
  2176. Alternatively, if your patch needs to be applied in a specific
  2177. subdirectory that is not specified in the patch file, use the
  2178. "patchdir" option in the entry.
  2179. </para>
  2180. <para>
  2181. As with all local files referenced in
  2182. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  2183. using <filename>file://</filename>, you should place
  2184. patch files in a directory next to the recipe either
  2185. named the same as the base name of the recipe
  2186. (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  2187. and
  2188. <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>)
  2189. or "files".
  2190. </para>
  2191. </section>
  2192. <section id='new-recipe-licensing'>
  2193. <title>Licensing</title>
  2194. <para>
  2195. Your recipe needs to have both the
  2196. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  2197. and
  2198. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  2199. variables:
  2200. <itemizedlist>
  2201. <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis>
  2202. This variable specifies the license for the software.
  2203. If you do not know the license under which the software
  2204. you are building is distributed, you should go to the
  2205. source code and look for that information.
  2206. Typical files containing this information include
  2207. <filename>COPYING</filename>,
  2208. <filename>LICENSE</filename>, and
  2209. <filename>README</filename> files.
  2210. You could also find the information near the top of
  2211. a source file.
  2212. For example, given a piece of software licensed under
  2213. the GNU General Public License version 2, you would
  2214. set <filename>LICENSE</filename> as follows:
  2215. <literallayout class='monospaced'>
  2216. LICENSE = "GPLv2"
  2217. </literallayout></para>
  2218. <para>The licenses you specify within
  2219. <filename>LICENSE</filename> can have any name as long
  2220. as you do not use spaces, since spaces are used as
  2221. separators between license names.
  2222. For standard licenses, use the names of the files in
  2223. <filename>meta/files/common-licenses/</filename>
  2224. or the <filename>SPDXLICENSEMAP</filename> flag names
  2225. defined in <filename>meta/conf/licenses.conf</filename>.
  2226. </para></listitem>
  2227. <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis>
  2228. The OpenEmbedded build system uses this variable to
  2229. make sure the license text has not changed.
  2230. If it has, the build produces an error and it affords
  2231. you the chance to figure it out and correct the problem.
  2232. </para>
  2233. <para>You need to specify all applicable licensing
  2234. files for the software.
  2235. At the end of the configuration step, the build process
  2236. will compare the checksums of the files to be sure
  2237. the text has not changed.
  2238. Any differences result in an error with the message
  2239. containing the current checksum.
  2240. For more explanation and examples of how to set the
  2241. <filename>LIC_FILES_CHKSUM</filename> variable, see the
  2242. "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  2243. section in the Yocto Project Reference Manual.</para>
  2244. <para>To determine the correct checksum string, you
  2245. can list the appropriate files in the
  2246. <filename>LIC_FILES_CHKSUM</filename> variable with
  2247. incorrect md5 strings, attempt to build the software,
  2248. and then note the resulting error messages that will
  2249. report the correct md5 strings.
  2250. See the
  2251. "<link linkend='new-recipe-fetching-code'>Fetching Code</link>"
  2252. section for additional information.
  2253. </para>
  2254. <para>
  2255. Here is an example that assumes the software has a
  2256. <filename>COPYING</filename> file:
  2257. <literallayout class='monospaced'>
  2258. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  2259. </literallayout>
  2260. When you try to build the software, the build system
  2261. will produce an error and give you the correct string
  2262. that you can substitute into the recipe file for a
  2263. subsequent build.
  2264. </para></listitem>
  2265. </itemizedlist>
  2266. </para>
  2267. <!--
  2268. <para>
  2269. For trying this out I created a new recipe named
  2270. <filename>htop_1.0.2.bb</filename> and put it in
  2271. <filename>poky/meta/recipes-extended/htop</filename>.
  2272. There are two license type statements in my very simple
  2273. recipe:
  2274. <literallayout class='monospaced'>
  2275. LICENSE = ""
  2276. LIC_FILES_CHKSUM = ""
  2277. SRC_URI[md5sum] = ""
  2278. SRC_URI[sha256sum] = ""
  2279. </literallayout>
  2280. Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>.
  2281. Next, you delete or comment out the two <filename>SRC_URI</filename>
  2282. lines at the end and then attempt to build the software with
  2283. <filename>bitbake htop</filename>.
  2284. Doing so causes BitBake to report some errors and and give
  2285. you the actual strings you need for the last two
  2286. <filename>SRC_URI</filename> lines.
  2287. Prior to this, you have to dig around in the home page of the
  2288. source for <filename>htop</filename> and determine that the
  2289. software is released under GPLv2.
  2290. You can provide that in the <filename>LICENSE</filename>
  2291. statement.
  2292. Now you edit your recipe to have those two strings for
  2293. the <filename>SRC_URI</filename> statements:
  2294. <literallayout class='monospaced'>
  2295. LICENSE = "GPLv2"
  2296. LIC_FILES_CHKSUM = ""
  2297. SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz"
  2298. SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e"
  2299. SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1"
  2300. </literallayout>
  2301. At this point, you can build the software again using the
  2302. <filename>bitbake htop</filename> command.
  2303. There is just a set of errors now associated with the
  2304. empty <filename>LIC_FILES_CHKSUM</filename> variable now.
  2305. </para>
  2306. -->
  2307. </section>
  2308. <section id='new-dependencies'>
  2309. <title>Dependencies</title>
  2310. <para>
  2311. Most software packages have a short list of other packages
  2312. that they require, which are called dependencies.
  2313. These dependencies fall into two main categories: build-time
  2314. dependencies, which are required when the software is built;
  2315. and runtime dependencies, which are required to be installed
  2316. on the target in order for the software to run.
  2317. </para>
  2318. <para>
  2319. Within a recipe, you specify build-time dependencies using the
  2320. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2321. variable.
  2322. Although nuances exist, items specified in
  2323. <filename>DEPENDS</filename> should be names of other recipes.
  2324. It is important that you specify all build-time dependencies
  2325. explicitly.
  2326. If you do not, due to the parallel nature of BitBake's
  2327. execution, you can end up with a race condition where the
  2328. dependency is present for one task of a recipe (e.g.
  2329. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>)
  2330. and then gone when the next task runs (e.g.
  2331. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>).
  2332. </para>
  2333. <para>
  2334. Another consideration is that configure scripts might
  2335. automatically check for optional dependencies and enable
  2336. corresponding functionality if those dependencies are found.
  2337. This behavior means that to ensure deterministic results and
  2338. thus avoid more race conditions, you need to either explicitly
  2339. specify these dependencies as well, or tell the configure
  2340. script explicitly to disable the functionality.
  2341. If you wish to make a recipe that is more generally useful
  2342. (e.g. publish the recipe in a layer for others to use),
  2343. instead of hard-disabling the functionality, you can use the
  2344. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink>
  2345. variable to allow functionality and the corresponding
  2346. dependencies to be enabled and disabled easily by other
  2347. users of the recipe.
  2348. </para>
  2349. <para>
  2350. Similar to build-time dependencies, you specify runtime
  2351. dependencies through a variable -
  2352. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  2353. which is package-specific.
  2354. All variables that are package-specific need to have the name
  2355. of the package added to the end as an override.
  2356. Since the main package for a recipe has the same name as the
  2357. recipe, and the recipe's name can be found through the
  2358. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2359. variable, then you specify the dependencies for the main
  2360. package by setting <filename>RDEPENDS_${PN}</filename>.
  2361. If the package were named <filename>${PN}-tools</filename>,
  2362. then you would set <filename>RDEPENDS_${PN}-tools</filename>,
  2363. and so forth.
  2364. </para>
  2365. <para>
  2366. Some runtime dependencies will be set automatically at
  2367. packaging time.
  2368. These dependencies include any shared library dependencies
  2369. (i.e. if a package "example" contains "libexample" and
  2370. another package "mypackage" contains a binary that links to
  2371. "libexample" then the OpenEmbedded build system will
  2372. automatically add a runtime dependency to "mypackage" on
  2373. "example").
  2374. See the
  2375. "<ulink url='&YOCTO_DOCS_REF_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  2376. in the Yocto Project Reference Manual for further details.
  2377. </para>
  2378. </section>
  2379. <section id='new-recipe-configuring-the-recipe'>
  2380. <title>Configuring the Recipe</title>
  2381. <para>
  2382. Most software provides some means of setting build-time
  2383. configuration options before compilation.
  2384. Typically, setting these options is accomplished by running a
  2385. configure script with some options, or by modifying a build
  2386. configuration file.
  2387. <note>
  2388. As of Yocto Project Release 1.7, some of the core recipes
  2389. that package binary configuration scripts now disable the
  2390. scripts due to the scripts previously requiring error-prone
  2391. path substitution.
  2392. The OpenEmbedded build system uses
  2393. <filename>pkg-config</filename> now, which is much more
  2394. robust.
  2395. You can find a list of the <filename>*-config</filename>
  2396. scripts that are disabled list in the
  2397. "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>"
  2398. section in the Yocto Project Reference Manual.
  2399. </note>
  2400. </para>
  2401. <para>
  2402. A major part of build-time configuration is about checking for
  2403. build-time dependencies and possibly enabling optional
  2404. functionality as a result.
  2405. You need to specify any build-time dependencies for the
  2406. software you are building in your recipe's
  2407. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2408. value, in terms of other recipes that satisfy those
  2409. dependencies.
  2410. You can often find build-time or runtime
  2411. dependencies described in the software's documentation.
  2412. </para>
  2413. <para>
  2414. The following list provides configuration items of note based
  2415. on how your software is built:
  2416. <itemizedlist>
  2417. <listitem><para><emphasis>Autotools:</emphasis>
  2418. If your source files have a
  2419. <filename>configure.ac</filename> file, then your
  2420. software is built using Autotools.
  2421. If this is the case, you just need to worry about
  2422. modifying the configuration.</para>
  2423. <para>When using Autotools, your recipe needs to inherit
  2424. the
  2425. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2426. class and your recipe does not have to contain a
  2427. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2428. task.
  2429. However, you might still want to make some adjustments.
  2430. For example, you can set
  2431. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  2432. or
  2433. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2434. to pass any needed configure options that are specific
  2435. to the recipe.</para></listitem>
  2436. <listitem><para><emphasis>CMake:</emphasis>
  2437. If your source files have a
  2438. <filename>CMakeLists.txt</filename> file, then your
  2439. software is built using CMake.
  2440. If this is the case, you just need to worry about
  2441. modifying the configuration.</para>
  2442. <para>When you use CMake, your recipe needs to inherit
  2443. the
  2444. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2445. class and your recipe does not have to contain a
  2446. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2447. task.
  2448. You can make some adjustments by setting
  2449. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
  2450. to pass any needed configure options that are specific
  2451. to the recipe.</para></listitem>
  2452. <listitem><para><emphasis>Other:</emphasis>
  2453. If your source files do not have a
  2454. <filename>configure.ac</filename> or
  2455. <filename>CMakeLists.txt</filename> file, then your
  2456. software is built using some method other than Autotools
  2457. or CMake.
  2458. If this is the case, you normally need to provide a
  2459. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2460. task in your recipe
  2461. unless, of course, there is nothing to configure.
  2462. </para>
  2463. <para>Even if your software is not being built by
  2464. Autotools or CMake, you still might not need to deal
  2465. with any configuration issues.
  2466. You need to determine if configuration is even a required step.
  2467. You might need to modify a Makefile or some configuration file
  2468. used for the build to specify necessary build options.
  2469. Or, perhaps you might need to run a provided, custom
  2470. configure script with the appropriate options.</para>
  2471. <para>For the case involving a custom configure
  2472. script, you would run
  2473. <filename>./configure --help</filename> and look for
  2474. the options you need to set.</para></listitem>
  2475. </itemizedlist>
  2476. </para>
  2477. <para>
  2478. Once configuration succeeds, it is always good practice to
  2479. look at the <filename>log.do_configure</filename> file to
  2480. ensure that the appropriate options have been enabled and no
  2481. additional build-time dependencies need to be added to
  2482. <filename>DEPENDS</filename>.
  2483. For example, if the configure script reports that it found
  2484. something not mentioned in <filename>DEPENDS</filename>, or
  2485. that it did not find something that it needed for some
  2486. desired optional functionality, then you would need to add
  2487. those to <filename>DEPENDS</filename>.
  2488. Looking at the log might also reveal items being checked for,
  2489. enabled, or both that you do not want, or items not being found
  2490. that are in <filename>DEPENDS</filename>, in which case
  2491. you would need to look at passing extra options to the
  2492. configure script as needed.
  2493. For reference information on configure options specific to the
  2494. software you are building, you can consult the output of the
  2495. <filename>./configure --help</filename> command within
  2496. <filename>${S}</filename> or consult the software's upstream
  2497. documentation.
  2498. </para>
  2499. </section>
  2500. <section id='new-recipe-using-headers-to-interface-with-devices'>
  2501. <title>Using Headers to Interface with Devices</title>
  2502. <para>
  2503. If your recipe builds an application that needs to
  2504. communicate with some device or needs an API into a custom
  2505. kernel, you will need to provide appropriate header files.
  2506. Under no circumstances should you ever modify the existing
  2507. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>
  2508. file.
  2509. These headers are used to build <filename>libc</filename> and
  2510. must not be compromised with custom or machine-specific
  2511. header information.
  2512. If you customize <filename>libc</filename> through modified
  2513. headers all other applications that use
  2514. <filename>libc</filename> thus become affected.
  2515. <note><title>Warning</title>
  2516. Never copy and customize the <filename>libc</filename>
  2517. header file (i.e.
  2518. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>).
  2519. </note>
  2520. The correct way to interface to a device or custom kernel is
  2521. to use a separate package that provides the additional headers
  2522. for the driver or other unique interfaces.
  2523. When doing so, your application also becomes responsible for
  2524. creating a dependency on that specific provider.
  2525. </para>
  2526. <para>
  2527. Consider the following:
  2528. <itemizedlist>
  2529. <listitem><para>
  2530. Never modify
  2531. <filename>linux-libc-headers.inc</filename>.
  2532. Consider that file to be part of the
  2533. <filename>libc</filename> system, and not something
  2534. you use to access the kernel directly.
  2535. You should access <filename>libc</filename> through
  2536. specific <filename>libc</filename> calls.
  2537. </para></listitem>
  2538. <listitem><para>
  2539. Applications that must talk directly to devices
  2540. should either provide necessary headers themselves,
  2541. or establish a dependency on a special headers package
  2542. that is specific to that driver.
  2543. </para></listitem>
  2544. </itemizedlist>
  2545. </para>
  2546. <para>
  2547. For example, suppose you want to modify an existing header
  2548. that adds I/O control or network support.
  2549. If the modifications are used by a small number programs,
  2550. providing a unique version of a header is easy and has little
  2551. impact.
  2552. When doing so, bear in mind the guidelines in the previous
  2553. list.
  2554. <note>
  2555. If for some reason your changes need to modify the behavior
  2556. of the <filename>libc</filename>, and subsequently all
  2557. other applications on the system, use a
  2558. <filename>.bbappend</filename> to modify the
  2559. <filename>linux-kernel-headers.inc</filename> file.
  2560. However, take care to not make the changes
  2561. machine specific.
  2562. </note>
  2563. </para>
  2564. <para>
  2565. Consider a case where your kernel is older and you need
  2566. an older <filename>libc</filename> ABI.
  2567. The headers installed by your recipe should still be a
  2568. standard mainline kernel, not your own custom one.
  2569. </para>
  2570. <para>
  2571. When you use custom kernel headers you need to get them from
  2572. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>,
  2573. which is the directory with kernel headers that are
  2574. required to build out-of-tree modules.
  2575. Your recipe will also need the following:
  2576. <literallayout class='monospaced'>
  2577. do_configure[depends] += "virtual/kernel:do_shared_workdir"
  2578. </literallayout>
  2579. </para>
  2580. </section>
  2581. <section id='new-recipe-compilation'>
  2582. <title>Compilation</title>
  2583. <para>
  2584. During a build, the <filename>do_compile</filename> task
  2585. happens after source is fetched, unpacked, and configured.
  2586. If the recipe passes through <filename>do_compile</filename>
  2587. successfully, nothing needs to be done.
  2588. </para>
  2589. <para>
  2590. However, if the compile step fails, you need to diagnose the
  2591. failure.
  2592. Here are some common issues that cause failures.
  2593. <note>
  2594. For cases where improper paths are detected for
  2595. configuration files or for when libraries/headers cannot
  2596. be found, be sure you are using the more robust
  2597. <filename>pkg-config</filename>.
  2598. See the note in section
  2599. "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>"
  2600. for additional information.
  2601. </note>
  2602. <itemizedlist>
  2603. <listitem><para><emphasis>Parallel build failures:</emphasis>
  2604. These failures manifest themselves as intermittent
  2605. errors, or errors reporting that a file or directory
  2606. that should be created by some other part of the build
  2607. process could not be found.
  2608. This type of failure can occur even if, upon inspection,
  2609. the file or directory does exist after the build has
  2610. failed, because that part of the build process happened
  2611. in the wrong order.</para>
  2612. <para>To fix the problem, you need to either satisfy
  2613. the missing dependency in the Makefile or whatever
  2614. script produced the Makefile, or (as a workaround)
  2615. set
  2616. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  2617. to an empty string:
  2618. <literallayout class='monospaced'>
  2619. PARALLEL_MAKE = ""
  2620. </literallayout></para>
  2621. <para>
  2622. For information on parallel Makefile issues, see the
  2623. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  2624. section.
  2625. </para></listitem>
  2626. <listitem><para><emphasis>Improper host path usage:</emphasis>
  2627. This failure applies to recipes building for the target
  2628. or <filename>nativesdk</filename> only.
  2629. The failure occurs when the compilation process uses
  2630. improper headers, libraries, or other files from the
  2631. host system when cross-compiling for the target.
  2632. </para>
  2633. <para>To fix the problem, examine the
  2634. <filename>log.do_compile</filename> file to identify
  2635. the host paths being used (e.g.
  2636. <filename>/usr/include</filename>,
  2637. <filename>/usr/lib</filename>, and so forth) and then
  2638. either add configure options, apply a patch, or do both.
  2639. </para></listitem>
  2640. <listitem><para><emphasis>Failure to find required
  2641. libraries/headers:</emphasis>
  2642. If a build-time dependency is missing because it has
  2643. not been declared in
  2644. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  2645. or because the dependency exists but the path used by
  2646. the build process to find the file is incorrect and the
  2647. configure step did not detect it, the compilation
  2648. process could fail.
  2649. For either of these failures, the compilation process
  2650. notes that files could not be found.
  2651. In these cases, you need to go back and add additional
  2652. options to the configure script as well as possibly
  2653. add additional build-time dependencies to
  2654. <filename>DEPENDS</filename>.</para>
  2655. <para>Occasionally, it is necessary to apply a patch
  2656. to the source to ensure the correct paths are used.
  2657. If you need to specify paths to find files staged
  2658. into the sysroot from other recipes, use the variables
  2659. that the OpenEmbedded build system provides
  2660. (e.g.
  2661. <filename>STAGING_BINDIR</filename>,
  2662. <filename>STAGING_INCDIR</filename>,
  2663. <filename>STAGING_DATADIR</filename>, and so forth).
  2664. <!--
  2665. (e.g.
  2666. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>,
  2667. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>,
  2668. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>,
  2669. and so forth).
  2670. -->
  2671. </para></listitem>
  2672. </itemizedlist>
  2673. </para>
  2674. </section>
  2675. <section id='new-recipe-installing'>
  2676. <title>Installing</title>
  2677. <para>
  2678. During <filename>do_install</filename>, the task copies the
  2679. built files along with their hierarchy to locations that
  2680. would mirror their locations on the target device.
  2681. The installation process copies files from the
  2682. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  2683. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>,
  2684. and
  2685. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  2686. directories to the
  2687. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2688. directory to create the structure as it should appear on the
  2689. target system.
  2690. </para>
  2691. <para>
  2692. How your software is built affects what you must do to be
  2693. sure your software is installed correctly.
  2694. The following list describes what you must do for installation
  2695. depending on the type of build system used by the software
  2696. being built:
  2697. <itemizedlist>
  2698. <listitem><para><emphasis>Autotools and CMake:</emphasis>
  2699. If the software your recipe is building uses Autotools
  2700. or CMake, the OpenEmbedded build
  2701. system understands how to install the software.
  2702. Consequently, you do not have to have a
  2703. <filename>do_install</filename> task as part of your
  2704. recipe.
  2705. You just need to make sure the install portion of the
  2706. build completes with no issues.
  2707. However, if you wish to install additional files not
  2708. already being installed by
  2709. <filename>make install</filename>, you should do this
  2710. using a <filename>do_install_append</filename> function
  2711. using the install command as described in
  2712. the "Manual" bulleted item later in this list.
  2713. </para></listitem>
  2714. <listitem><para><emphasis>Other (using
  2715. <filename>make install</filename>):</emphasis>
  2716. You need to define a
  2717. <filename>do_install</filename> function in your
  2718. recipe.
  2719. The function should call
  2720. <filename>oe_runmake install</filename> and will likely
  2721. need to pass in the destination directory as well.
  2722. How you pass that path is dependent on how the
  2723. <filename>Makefile</filename> being run is written
  2724. (e.g. <filename>DESTDIR=${D}</filename>,
  2725. <filename>PREFIX=${D}</filename>,
  2726. <filename>INSTALLROOT=${D}</filename>, and so forth).
  2727. </para>
  2728. <para>For an example recipe using
  2729. <filename>make install</filename>, see the
  2730. "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>"
  2731. section.</para></listitem>
  2732. <listitem><para><emphasis>Manual:</emphasis>
  2733. You need to define a
  2734. <filename>do_install</filename> function in your
  2735. recipe.
  2736. The function must first use
  2737. <filename>install -d</filename> to create the
  2738. directories under
  2739. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
  2740. Once the directories exist, your function can use
  2741. <filename>install</filename> to manually install the
  2742. built software into the directories.</para>
  2743. <para>You can find more information on
  2744. <filename>install</filename> at
  2745. <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>.
  2746. </para></listitem>
  2747. </itemizedlist>
  2748. </para>
  2749. <para>
  2750. For the scenarios that do not use Autotools or
  2751. CMake, you need to track the installation
  2752. and diagnose and fix any issues until everything installs
  2753. correctly.
  2754. You need to look in the default location of
  2755. <filename>${D}</filename>, which is
  2756. <filename>${WORKDIR}/image</filename>, to be sure your
  2757. files have been installed correctly.
  2758. </para>
  2759. <note><title>Notes</title>
  2760. <itemizedlist>
  2761. <listitem><para>
  2762. During the installation process, you might need to
  2763. modify some of the installed files to suit the target
  2764. layout.
  2765. For example, you might need to replace hard-coded paths
  2766. in an initscript with values of variables provided by
  2767. the build system, such as replacing
  2768. <filename>/usr/bin/</filename> with
  2769. <filename>${bindir}</filename>.
  2770. If you do perform such modifications during
  2771. <filename>do_install</filename>, be sure to modify the
  2772. destination file after copying rather than before
  2773. copying.
  2774. Modifying after copying ensures that the build system
  2775. can re-execute <filename>do_install</filename> if
  2776. needed.
  2777. </para></listitem>
  2778. <listitem><para>
  2779. <filename>oe_runmake install</filename>, which can be
  2780. run directly or can be run indirectly by the
  2781. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2782. and
  2783. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2784. classes, runs <filename>make install</filename> in
  2785. parallel.
  2786. Sometimes, a Makefile can have missing dependencies
  2787. between targets that can result in race conditions.
  2788. If you experience intermittent failures during
  2789. <filename>do_install</filename>, you might be able to
  2790. work around them by disabling parallel Makefile
  2791. installs by adding the following to the recipe:
  2792. <literallayout class='monospaced'>
  2793. PARALLEL_MAKEINST = ""
  2794. </literallayout>
  2795. See
  2796. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  2797. for additional information.
  2798. </para></listitem>
  2799. </itemizedlist>
  2800. </note>
  2801. </section>
  2802. <section id='new-recipe-enabling-system-services'>
  2803. <title>Enabling System Services</title>
  2804. <para>
  2805. If you want to install a service, which is a process that
  2806. usually starts on boot and runs in the background, then
  2807. you must include some additional definitions in your recipe.
  2808. </para>
  2809. <para>
  2810. If you are adding services and the service initialization
  2811. script or the service file itself is not installed, you must
  2812. provide for that installation in your recipe using a
  2813. <filename>do_install_append</filename> function.
  2814. If your recipe already has a <filename>do_install</filename>
  2815. function, update the function near its end rather than
  2816. adding an additional <filename>do_install_append</filename>
  2817. function.
  2818. </para>
  2819. <para>
  2820. When you create the installation for your services, you need
  2821. to accomplish what is normally done by
  2822. <filename>make install</filename>.
  2823. In other words, make sure your installation arranges the output
  2824. similar to how it is arranged on the target system.
  2825. </para>
  2826. <para>
  2827. The OpenEmbedded build system provides support for starting
  2828. services two different ways:
  2829. <itemizedlist>
  2830. <listitem><para><emphasis>SysVinit:</emphasis>
  2831. SysVinit is a system and service manager that
  2832. manages the init system used to control the very basic
  2833. functions of your system.
  2834. The init program is the first program
  2835. started by the Linux kernel when the system boots.
  2836. Init then controls the startup, running and shutdown
  2837. of all other programs.</para>
  2838. <para>To enable a service using SysVinit, your recipe
  2839. needs to inherit the
  2840. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink>
  2841. class.
  2842. The class helps facilitate safely installing the
  2843. package on the target.</para>
  2844. <para>You will need to set the
  2845. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>,
  2846. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>,
  2847. and
  2848. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink>
  2849. variables within your recipe.</para></listitem>
  2850. <listitem><para><emphasis>systemd:</emphasis>
  2851. System Management Daemon (systemd) was designed to
  2852. replace SysVinit and to provide
  2853. enhanced management of services.
  2854. For more information on systemd, see the systemd
  2855. homepage at
  2856. <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>.
  2857. </para>
  2858. <para>To enable a service using systemd, your recipe
  2859. needs to inherit the
  2860. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink>
  2861. class.
  2862. See the <filename>systemd.bbclass</filename> file
  2863. located in your
  2864. <link linkend='source-directory'>Source Directory</link>.
  2865. section for more information.
  2866. </para></listitem>
  2867. </itemizedlist>
  2868. </para>
  2869. </section>
  2870. <section id='new-recipe-packaging'>
  2871. <title>Packaging</title>
  2872. <para>
  2873. Successful packaging is a combination of automated processes
  2874. performed by the OpenEmbedded build system and some
  2875. specific steps you need to take.
  2876. The following list describes the process:
  2877. <itemizedlist>
  2878. <listitem><para><emphasis>Splitting Files</emphasis>:
  2879. The <filename>do_package</filename> task splits the
  2880. files produced by the recipe into logical components.
  2881. Even software that produces a single binary might
  2882. still have debug symbols, documentation, and other
  2883. logical components that should be split out.
  2884. The <filename>do_package</filename> task ensures
  2885. that files are split up and packaged correctly.
  2886. </para></listitem>
  2887. <listitem><para><emphasis>Running QA Checks</emphasis>:
  2888. The
  2889. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2890. class adds a step to
  2891. the package generation process so that output quality
  2892. assurance checks are generated by the OpenEmbedded
  2893. build system.
  2894. This step performs a range of checks to be sure the
  2895. build's output is free of common problems that show
  2896. up during runtime.
  2897. For information on these checks, see the
  2898. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2899. class and the
  2900. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>"
  2901. chapter in the Yocto Project Reference Manual.
  2902. </para></listitem>
  2903. <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>:
  2904. After you build your software, you need to be sure
  2905. your packages are correct.
  2906. Examine the
  2907. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  2908. directory and make sure files are where you expect
  2909. them to be.
  2910. If you discover problems, you can set
  2911. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>,
  2912. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2913. <filename>do_install(_append)</filename>, and so forth as
  2914. needed.
  2915. </para></listitem>
  2916. <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>:
  2917. If you need to split an application into several
  2918. packages, see the
  2919. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2920. section for an example.
  2921. </para></listitem>
  2922. <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>:
  2923. For an example showing how to install a
  2924. post-installation script, see the
  2925. "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>"
  2926. section.
  2927. </para></listitem>
  2928. <listitem><para><emphasis>Marking Package Architecture</emphasis>:
  2929. Depending on what your recipe is building and how it
  2930. is configured, it might be important to mark the
  2931. packages produced as being specific to a particular
  2932. machine, or to mark them as not being specific to
  2933. a particular machine or architecture at all.</para>
  2934. <para>By default, packages apply to any machine with the
  2935. same architecture as the target machine.
  2936. When a recipe produces packages that are
  2937. machine-specific (e.g. the
  2938. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  2939. value is passed into the configure script or a patch
  2940. is applied only for a particular machine), you should
  2941. mark them as such by adding the following to the
  2942. recipe:
  2943. <literallayout class='monospaced'>
  2944. PACKAGE_ARCH = "${MACHINE_ARCH}"
  2945. </literallayout></para>
  2946. <para>On the other hand, if the recipe produces packages
  2947. that do not contain anything specific to the target
  2948. machine or architecture at all (e.g. recipes
  2949. that simply package script files or configuration
  2950. files), you should use the
  2951. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  2952. class to do this for you by adding this to your
  2953. recipe:
  2954. <literallayout class='monospaced'>
  2955. inherit allarch
  2956. </literallayout>
  2957. Ensuring that the package architecture is correct is
  2958. not critical while you are doing the first few builds
  2959. of your recipe.
  2960. However, it is important in order
  2961. to ensure that your recipe rebuilds (or does not
  2962. rebuild) appropriately in response to changes in
  2963. configuration, and to ensure that you get the
  2964. appropriate packages installed on the target machine,
  2965. particularly if you run separate builds for more
  2966. than one target machine.
  2967. </para></listitem>
  2968. </itemizedlist>
  2969. </para>
  2970. </section>
  2971. <section id='new-sharing-files-between-recipes'>
  2972. <title>Sharing Files Between Recipes</title>
  2973. <para>
  2974. Recipes often need to use files provided by other recipes on
  2975. the build host.
  2976. For example, an application linking to a common library needs
  2977. access to the library itself and its associated headers.
  2978. The way this access is accomplished is by populating sysroot
  2979. with files.
  2980. Each recipe has two sysroots in its work directory, one for
  2981. target files
  2982. (<filename>recipe-sysroot</filename>) and one for files that
  2983. are native to the build host
  2984. (<filename>recipe-sysroot-native</filename>).
  2985. <note>
  2986. You could find the term "staging" used within the Yocto
  2987. project regarding files populating sysroot (e.g. the
  2988. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink>
  2989. variable).
  2990. </note>
  2991. </para>
  2992. <para>
  2993. Recipes should never populate the sysroot directly (i.e. write
  2994. files into sysroot).
  2995. Instead, files should be installed into standard locations
  2996. during the
  2997. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2998. task within the
  2999. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  3000. directory.
  3001. The reason for this limitation is that almost all files that
  3002. populate the sysroot are cataloged in manifests in order to
  3003. ensure the files can be removed later when a recipe is either
  3004. modified or removed.
  3005. Thus, the sysroot is able to remain free from stale files.
  3006. </para>
  3007. <para>
  3008. A subset of the files installed by the
  3009. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3010. task are used by the
  3011. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  3012. task as defined by the the
  3013. <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink>
  3014. variable to automatically populate the sysroot.
  3015. It is possible to modify the list of directories that populate
  3016. the sysroot.
  3017. The following example shows how you could add the
  3018. <filename>/opt</filename> directory to the list of
  3019. directories:
  3020. <literallayout class='monospaced'>
  3021. SYSROOT_DIRS += "/opt"
  3022. </literallayout>
  3023. </para>
  3024. <para>
  3025. for a more complete description of the
  3026. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  3027. task and its associated functions, see the
  3028. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-staging'><filename>staging</filename></ulink>
  3029. class.
  3030. </para>
  3031. </section>
  3032. <section id='properly-versioning-pre-release-recipes'>
  3033. <title>Properly Versioning Pre-Release Recipes</title>
  3034. <para>
  3035. Sometimes the name of a recipe can lead to versioning
  3036. problems when the recipe is upgraded to a final release.
  3037. For example, consider the
  3038. <filename>irssi_0.8.16-rc1.bb</filename> recipe file in
  3039. the list of example recipes in the
  3040. "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>"
  3041. section.
  3042. This recipe is at a release candidate stage (i.e.
  3043. "rc1").
  3044. When the recipe is released, the recipe filename becomes
  3045. <filename>irssi_0.8.16.bb</filename>.
  3046. The version change from <filename>0.8.16-rc1</filename>
  3047. to <filename>0.8.16</filename> is seen as a decrease by the
  3048. build system and package managers, so the resulting packages
  3049. will not correctly trigger an upgrade.
  3050. </para>
  3051. <para>
  3052. In order to ensure the versions compare properly, the
  3053. recommended convention is to set
  3054. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  3055. within the recipe to
  3056. "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>".
  3057. You can use an additional variable so that you can use the
  3058. current version elsewhere.
  3059. Here is an example:
  3060. <literallayout class='monospaced'>
  3061. REALPV = "0.8.16-rc1"
  3062. PV = "0.8.15+${REALPV}"
  3063. </literallayout>
  3064. </para>
  3065. </section>
  3066. <section id='new-recipe-post-installation-scripts'>
  3067. <title>Post-Installation Scripts</title>
  3068. <para>
  3069. Post-installation scripts run immediately after installing
  3070. a package on the target or during image creation when a
  3071. package is included in an image.
  3072. To add a post-installation script to a package, add a
  3073. <filename>pkg_postinst_</filename><replaceable>PACKAGENAME</replaceable><filename>()</filename> function to
  3074. the recipe file (<filename>.bb</filename>) and replace
  3075. <replaceable>PACKAGENAME</replaceable> with the name of the package
  3076. you want to attach to the <filename>postinst</filename>
  3077. script.
  3078. To apply the post-installation script to the main package
  3079. for the recipe, which is usually what is required, specify
  3080. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  3081. in place of <replaceable>PACKAGENAME</replaceable>.
  3082. </para>
  3083. <para>
  3084. A post-installation function has the following structure:
  3085. <literallayout class='monospaced'>
  3086. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  3087. # Commands to carry out
  3088. }
  3089. </literallayout>
  3090. </para>
  3091. <para>
  3092. The script defined in the post-installation function is
  3093. called when the root filesystem is created.
  3094. If the script succeeds, the package is marked as installed.
  3095. If the script fails, the package is marked as unpacked and
  3096. the script is executed when the image boots again.
  3097. <note>
  3098. Any RPM post-installation script that runs on the target
  3099. should return a 0 exit code.
  3100. RPM does not allow non-zero exit codes for these scripts,
  3101. and the RPM package manager will cause the package to fail
  3102. installation on the target.
  3103. </note>
  3104. </para>
  3105. <para>
  3106. Sometimes it is necessary for the execution of a
  3107. post-installation script to be delayed until the first boot.
  3108. For example, the script might need to be executed on the
  3109. device itself.
  3110. To delay script execution until boot time, use the following
  3111. structure in the post-installation script:
  3112. <literallayout class='monospaced'>
  3113. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  3114. if [ x"$D" = "x" ]; then
  3115. # Actions to carry out on the device go here
  3116. else
  3117. exit 1
  3118. fi
  3119. }
  3120. </literallayout>
  3121. </para>
  3122. <para>
  3123. The previous example delays execution until the image boots
  3124. again because the environment variable <filename>D</filename>
  3125. points to the directory containing the image when
  3126. the root filesystem is created at build time but is unset
  3127. when executed on the first boot.
  3128. </para>
  3129. <para>
  3130. If you have recipes that use <filename>pkg_postinst</filename>
  3131. scripts and they require the use of non-standard native
  3132. tools that have dependencies during rootfs construction, you
  3133. need to use the
  3134. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink>
  3135. variable in your recipe to list these tools.
  3136. If you do not use this variable, the tools might be missing and
  3137. execution of the post-installation script is deferred until
  3138. first boot.
  3139. Deferring the script to first boot is undesirable and for
  3140. read-only rootfs impossible.
  3141. </para>
  3142. <note>
  3143. Equivalent support for pre-install, pre-uninstall, and
  3144. post-uninstall scripts exist by way of
  3145. <filename>pkg_preinst</filename>,
  3146. <filename>pkg_prerm</filename>, and
  3147. <filename>pkg_postrm</filename>, respectively.
  3148. These scrips work in exactly the same way as does
  3149. <filename>pkg_postinst</filename> with the exception that they
  3150. run at different times.
  3151. Also, because of when they run, they are not applicable to
  3152. being run at image creation time like
  3153. <filename>pkg_postinst</filename>.
  3154. </note>
  3155. </section>
  3156. <section id='new-recipe-testing'>
  3157. <title>Testing</title>
  3158. <para>
  3159. The final step for completing your recipe is to be sure that
  3160. the software you built runs correctly.
  3161. To accomplish runtime testing, add the build's output
  3162. packages to your image and test them on the target.
  3163. </para>
  3164. <para>
  3165. For information on how to customize your image by adding
  3166. specific packages, see the
  3167. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  3168. section.
  3169. </para>
  3170. </section>
  3171. <section id='new-recipe-testing-examples'>
  3172. <title>Examples</title>
  3173. <para>
  3174. To help summarize how to write a recipe, this section provides
  3175. some examples given various scenarios:
  3176. <itemizedlist>
  3177. <listitem><para>Recipes that use local files</para></listitem>
  3178. <listitem><para>Using an Autotooled package</para></listitem>
  3179. <listitem><para>Using a Makefile-based package</para></listitem>
  3180. <listitem><para>Splitting an application into multiple packages</para></listitem>
  3181. <listitem><para>Adding binaries to an image</para></listitem>
  3182. </itemizedlist>
  3183. </para>
  3184. <section id='new-recipe-single-c-file-package-hello-world'>
  3185. <title>Single .c File Package (Hello World!)</title>
  3186. <para>
  3187. Building an application from a single file that is stored
  3188. locally (e.g. under <filename>files</filename>) requires
  3189. a recipe that has the file listed in the
  3190. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  3191. variable.
  3192. Additionally, you need to manually write the
  3193. <filename>do_compile</filename> and
  3194. <filename>do_install</filename> tasks.
  3195. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3196. variable defines the directory containing the source code,
  3197. which is set to
  3198. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  3199. in this case - the directory BitBake uses for the build.
  3200. <literallayout class='monospaced'>
  3201. SUMMARY = "Simple helloworld application"
  3202. SECTION = "examples"
  3203. LICENSE = "MIT"
  3204. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  3205. SRC_URI = "file://helloworld.c"
  3206. S = "${WORKDIR}"
  3207. do_compile() {
  3208. ${CC} helloworld.c -o helloworld
  3209. }
  3210. do_install() {
  3211. install -d ${D}${bindir}
  3212. install -m 0755 helloworld ${D}${bindir}
  3213. }
  3214. </literallayout>
  3215. </para>
  3216. <para>
  3217. By default, the <filename>helloworld</filename>,
  3218. <filename>helloworld-dbg</filename>, and
  3219. <filename>helloworld-dev</filename> packages are built.
  3220. For information on how to customize the packaging process,
  3221. see the
  3222. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  3223. section.
  3224. </para>
  3225. </section>
  3226. <section id='new-recipe-autotooled-package'>
  3227. <title>Autotooled Package</title>
  3228. <para>
  3229. Applications that use Autotools such as <filename>autoconf</filename> and
  3230. <filename>automake</filename> require a recipe that has a source archive listed in
  3231. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  3232. also inherit the
  3233. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  3234. class, which contains the definitions of all the steps
  3235. needed to build an Autotool-based application.
  3236. The result of the build is automatically packaged.
  3237. And, if the application uses NLS for localization, packages with local information are
  3238. generated (one package per language).
  3239. Following is one example: (<filename>hello_2.3.bb</filename>)
  3240. <literallayout class='monospaced'>
  3241. SUMMARY = "GNU Helloworld application"
  3242. SECTION = "examples"
  3243. LICENSE = "GPLv2+"
  3244. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  3245. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  3246. inherit autotools gettext
  3247. </literallayout>
  3248. </para>
  3249. <para>
  3250. The variable
  3251. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  3252. is used to track source license changes as described in the
  3253. "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" section.
  3254. You can quickly create Autotool-based recipes in a manner similar to the previous example.
  3255. </para>
  3256. </section>
  3257. <section id='new-recipe-makefile-based-package'>
  3258. <title>Makefile-Based Package</title>
  3259. <para>
  3260. Applications that use GNU <filename>make</filename> also require a recipe that has
  3261. the source archive listed in
  3262. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3263. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  3264. starts the <filename>make</filename> command to compile the application.
  3265. If you need additional <filename>make</filename> options, you should store them in the
  3266. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
  3267. or
  3268. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  3269. variables.
  3270. BitBake passes these options into the GNU <filename>make</filename> invocation.
  3271. Note that a <filename>do_install</filename> task is still required.
  3272. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  3273. </para>
  3274. <para>
  3275. Some applications might require extra parameters to be passed to the compiler.
  3276. For example, the application might need an additional header path.
  3277. You can accomplish this by adding to the
  3278. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  3279. The following example shows this:
  3280. <literallayout class='monospaced'>
  3281. CFLAGS_prepend = "-I ${S}/include "
  3282. </literallayout>
  3283. </para>
  3284. <para>
  3285. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  3286. <literallayout class='monospaced'>
  3287. SUMMARY = "Tools for managing memory technology devices"
  3288. SECTION = "base"
  3289. DEPENDS = "zlib lzo e2fsprogs util-linux"
  3290. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  3291. LICENSE = "GPLv2+"
  3292. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  3293. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  3294. # Use the latest version at 26 Oct, 2013
  3295. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  3296. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  3297. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  3298. "
  3299. PV = "1.5.1+git${SRCPV}"
  3300. S = "${WORKDIR}/git"
  3301. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  3302. do_install () {
  3303. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  3304. }
  3305. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  3306. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  3307. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  3308. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  3309. PARALLEL_MAKE = ""
  3310. BBCLASSEXTEND = "native"
  3311. </literallayout>
  3312. </para>
  3313. </section>
  3314. <section id='splitting-an-application-into-multiple-packages'>
  3315. <title>Splitting an Application into Multiple Packages</title>
  3316. <para>
  3317. You can use the variables
  3318. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  3319. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  3320. to split an application into multiple packages.
  3321. </para>
  3322. <para>
  3323. Following is an example that uses the <filename>libxpm</filename> recipe.
  3324. By default, this recipe generates a single package that contains the library along
  3325. with a few binaries.
  3326. You can modify the recipe to split the binaries into separate packages:
  3327. <literallayout class='monospaced'>
  3328. require xorg-lib-common.inc
  3329. SUMMARY = "Xpm: X Pixmap extension library"
  3330. LICENSE = "BSD"
  3331. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  3332. DEPENDS += "libxext libsm libxt"
  3333. PE = "1"
  3334. XORG_PN = "libXpm"
  3335. PACKAGES =+ "sxpm cxpm"
  3336. FILES_cxpm = "${bindir}/cxpm"
  3337. FILES_sxpm = "${bindir}/sxpm"
  3338. </literallayout>
  3339. </para>
  3340. <para>
  3341. In the previous example, we want to ship the <filename>sxpm</filename>
  3342. and <filename>cxpm</filename> binaries in separate packages.
  3343. Since <filename>bindir</filename> would be packaged into the main
  3344. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  3345. package by default, we prepend the <filename>PACKAGES</filename>
  3346. variable so additional package names are added to the start of list.
  3347. This results in the extra <filename>FILES_*</filename>
  3348. variables then containing information that define which files and
  3349. directories go into which packages.
  3350. Files included by earlier packages are skipped by latter packages.
  3351. Thus, the main <filename>PN</filename> package
  3352. does not include the above listed files.
  3353. </para>
  3354. </section>
  3355. <section id='packaging-externally-produced-binaries'>
  3356. <title>Packaging Externally Produced Binaries</title>
  3357. <para>
  3358. Sometimes, you need to add pre-compiled binaries to an
  3359. image.
  3360. For example, suppose that binaries for proprietary code
  3361. exist, which are created by a particular division of a
  3362. company.
  3363. Your part of the company needs to use those binaries as
  3364. part of an image that you are building using the
  3365. OpenEmbedded build system.
  3366. Since you only have the binaries and not the source code,
  3367. you cannot use a typical recipe that expects to fetch the
  3368. source specified in
  3369. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  3370. and then compile it.
  3371. </para>
  3372. <para>
  3373. One method is to package the binaries and then install them
  3374. as part of the image.
  3375. Generally, it is not a good idea to package binaries
  3376. since, among other things, it can hinder the ability to
  3377. reproduce builds and could lead to compatibility problems
  3378. with ABI in the future.
  3379. However, sometimes you have no choice.
  3380. </para>
  3381. <para>
  3382. The easiest solution is to create a recipe that uses
  3383. the
  3384. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  3385. class and to be sure that you are using default locations
  3386. for build artifacts.
  3387. In most cases, the <filename>bin_package</filename> class
  3388. handles "skipping" the configure and compile steps as well
  3389. as sets things up to grab packages from the appropriate
  3390. area.
  3391. In particular, this class sets <filename>noexec</filename>
  3392. on both the
  3393. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3394. and
  3395. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3396. tasks, sets
  3397. <filename>FILES_${PN}</filename> to "/" so that it picks
  3398. up all files, and sets up a
  3399. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3400. task, which effectively copies all files from
  3401. <filename>${S}</filename> to <filename>${D}</filename>.
  3402. The <filename>bin_package</filename> class works well when
  3403. the files extracted into <filename>${S}</filename> are
  3404. already laid out in the way they should be laid out
  3405. on the target.
  3406. For more information on these variables, see the
  3407. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  3408. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  3409. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  3410. and
  3411. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  3412. variables in the Yocto Project Reference Manual's variable
  3413. glossary.
  3414. <note><title>Notes</title>
  3415. <itemizedlist>
  3416. <listitem><para>
  3417. Using
  3418. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3419. is a good idea even for components distributed
  3420. in binary form, and is often necessary for
  3421. shared libraries.
  3422. For a shared library, listing the library
  3423. dependencies in
  3424. <filename>DEPENDS</filename> makes sure that
  3425. the libraries are available in the staging
  3426. sysroot when other recipes link against the
  3427. library, which might be necessary for
  3428. successful linking.
  3429. </para></listitem>
  3430. <listitem><para>
  3431. Using <filename>DEPENDS</filename> also
  3432. allows runtime dependencies between packages
  3433. to be added automatically.
  3434. See the
  3435. "<ulink url='&YOCTO_DOCS_REF_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  3436. section in the Yocto Project Reference Manual
  3437. for more information.
  3438. </para></listitem>
  3439. </itemizedlist>
  3440. </note>
  3441. </para>
  3442. <para>
  3443. If you cannot use the <filename>bin_package</filename>
  3444. class, you need to be sure you are doing the following:
  3445. <itemizedlist>
  3446. <listitem><para>
  3447. Create a recipe where the
  3448. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3449. and
  3450. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3451. tasks do nothing:
  3452. It is usually sufficient to just not define these
  3453. tasks in the recipe, because the default
  3454. implementations do nothing unless a Makefile is
  3455. found in
  3456. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>.
  3457. </para>
  3458. <para>If
  3459. <filename>${S}</filename> might contain a Makefile,
  3460. or if you inherit some class that replaces
  3461. <filename>do_configure</filename> and
  3462. <filename>do_compile</filename> with custom
  3463. versions, then you can use the
  3464. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename>
  3465. flag to turn the tasks into no-ops, as follows:
  3466. <literallayout class='monospaced'>
  3467. do_configure[noexec] = "1"
  3468. do_compile[noexec] = "1"
  3469. </literallayout>
  3470. Unlike
  3471. <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>,
  3472. using the flag preserves the dependency chain from
  3473. the
  3474. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>, <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>,
  3475. and
  3476. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3477. tasks to the
  3478. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3479. task.
  3480. </para></listitem>
  3481. <listitem><para>Make sure your
  3482. <filename>do_install</filename> task installs the
  3483. binaries appropriately.
  3484. </para></listitem>
  3485. <listitem><para>Ensure that you set up
  3486. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3487. (usually
  3488. <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>)
  3489. to point to the files you have installed, which of
  3490. course depends on where you have installed them
  3491. and whether those files are in different locations
  3492. than the defaults.
  3493. </para></listitem>
  3494. </itemizedlist>
  3495. </para>
  3496. </section>
  3497. </section>
  3498. <section id="following-recipe-style-guidelines">
  3499. <title>Following Recipe Style Guidelines</title>
  3500. <para>
  3501. When writing recipes, it is good to conform to existing
  3502. style guidelines.
  3503. The
  3504. <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink>
  3505. wiki page provides rough guidelines for preferred recipe style.
  3506. </para>
  3507. <para>
  3508. It is common for existing recipes to deviate a bit from this
  3509. style.
  3510. However, aiming for at least a consistent style is a good idea.
  3511. Some practices, such as omitting spaces around
  3512. <filename>=</filename> operators in assignments or ordering
  3513. recipe components in an erratic way, are widely seen as poor
  3514. style.
  3515. </para>
  3516. </section>
  3517. </section>
  3518. <section id="platdev-newmachine">
  3519. <title>Adding a New Machine</title>
  3520. <para>
  3521. Adding a new machine to the Yocto Project is a straightforward
  3522. process.
  3523. This section describes how to add machines that are similar
  3524. to those that the Yocto Project already supports.
  3525. <note>
  3526. Although well within the capabilities of the Yocto Project,
  3527. adding a totally new architecture might require
  3528. changes to <filename>gcc/glibc</filename> and to the site
  3529. information, which is beyond the scope of this manual.
  3530. </note>
  3531. </para>
  3532. <para>
  3533. For a complete example that shows how to add a new machine,
  3534. see the
  3535. "<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>"
  3536. section in the Yocto Project Board Support Package (BSP) Developer's Guide.
  3537. </para>
  3538. <section id="platdev-newmachine-conffile">
  3539. <title>Adding the Machine Configuration File</title>
  3540. <para>
  3541. To add a new machine, you need to add a new machine
  3542. configuration file to the layer's
  3543. <filename>conf/machine</filename> directory.
  3544. This configuration file provides details about the device
  3545. you are adding.
  3546. </para>
  3547. <para>
  3548. The OpenEmbedded build system uses the root name of the
  3549. machine configuration file to reference the new machine.
  3550. For example, given a machine configuration file named
  3551. <filename>crownbay.conf</filename>, the build system
  3552. recognizes the machine as "crownbay".
  3553. </para>
  3554. <para>
  3555. The most important variables you must set in your machine
  3556. configuration file or include from a lower-level configuration
  3557. file are as follows:
  3558. <itemizedlist>
  3559. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  3560. (e.g. "arm")</para></listitem>
  3561. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  3562. </para></listitem>
  3563. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  3564. (e.g. "apm screen wifi")</para></listitem>
  3565. </itemizedlist>
  3566. </para>
  3567. <para>
  3568. You might also need these variables:
  3569. <itemizedlist>
  3570. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  3571. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  3572. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  3573. (e.g. "zImage")</para></listitem>
  3574. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  3575. (e.g. "tar.gz jffs2")</para></listitem>
  3576. </itemizedlist>
  3577. </para>
  3578. <para>
  3579. You can find full details on these variables in the reference
  3580. section.
  3581. You can leverage existing machine <filename>.conf</filename>
  3582. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  3583. </para>
  3584. </section>
  3585. <section id="platdev-newmachine-kernel">
  3586. <title>Adding a Kernel for the Machine</title>
  3587. <para>
  3588. The OpenEmbedded build system needs to be able to build a kernel
  3589. for the machine.
  3590. You need to either create a new kernel recipe for this machine,
  3591. or extend an existing kernel recipe.
  3592. You can find several kernel recipe examples in the
  3593. Source Directory at
  3594. <filename>meta/recipes-kernel/linux</filename>
  3595. that you can use as references.
  3596. </para>
  3597. <para>
  3598. If you are creating a new kernel recipe, normal recipe-writing
  3599. rules apply for setting up a
  3600. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3601. Thus, you need to specify any necessary patches and set
  3602. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3603. to point at the source code.
  3604. You need to create a <filename>do_configure</filename> task that
  3605. configures the unpacked kernel with a
  3606. <filename>defconfig</filename> file.
  3607. You can do this by using a <filename>make defconfig</filename>
  3608. command or, more commonly, by copying in a suitable
  3609. <filename>defconfig</filename> file and then running
  3610. <filename>make oldconfig</filename>.
  3611. By making use of <filename>inherit kernel</filename> and
  3612. potentially some of the <filename>linux-*.inc</filename> files,
  3613. most other functionality is centralized and the defaults of the
  3614. class normally work well.
  3615. </para>
  3616. <para>
  3617. If you are extending an existing kernel recipe, it is usually
  3618. a matter of adding a suitable <filename>defconfig</filename>
  3619. file.
  3620. The file needs to be added into a location similar to
  3621. <filename>defconfig</filename> files used for other machines
  3622. in a given kernel recipe.
  3623. A possible way to do this is by listing the file in the
  3624. <filename>SRC_URI</filename> and adding the machine to the
  3625. expression in
  3626. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  3627. <literallayout class='monospaced'>
  3628. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  3629. </literallayout>
  3630. For more information on <filename>defconfig</filename> files,
  3631. see the
  3632. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  3633. section in the Yocto Project Linux Kernel Development Manual.
  3634. </para>
  3635. </section>
  3636. <section id="platdev-newmachine-formfactor">
  3637. <title>Adding a Formfactor Configuration File</title>
  3638. <para>
  3639. A formfactor configuration file provides information about the
  3640. target hardware for which the image is being built and information that
  3641. the build system cannot obtain from other sources such as the kernel.
  3642. Some examples of information contained in a formfactor configuration file include
  3643. framebuffer orientation, whether or not the system has a keyboard,
  3644. the positioning of the keyboard in relation to the screen, and
  3645. the screen resolution.
  3646. </para>
  3647. <para>
  3648. The build system uses reasonable defaults in most cases.
  3649. However, if customization is
  3650. necessary, you need to create a <filename>machconfig</filename> file
  3651. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  3652. directory.
  3653. This directory contains directories for specific machines such as
  3654. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  3655. For information about the settings available and the defaults, see the
  3656. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  3657. same area.
  3658. </para>
  3659. <para>
  3660. Following is an example for "qemuarm" machine:
  3661. <literallayout class='monospaced'>
  3662. HAVE_TOUCHSCREEN=1
  3663. HAVE_KEYBOARD=1
  3664. DISPLAY_CAN_ROTATE=0
  3665. DISPLAY_ORIENTATION=0
  3666. #DISPLAY_WIDTH_PIXELS=640
  3667. #DISPLAY_HEIGHT_PIXELS=480
  3668. #DISPLAY_BPP=16
  3669. DISPLAY_DPI=150
  3670. DISPLAY_SUBPIXEL_ORDER=vrgb
  3671. </literallayout>
  3672. </para>
  3673. </section>
  3674. </section>
  3675. <section id='platdev-building-targets-with-multiple-configurations'>
  3676. <title>Building Targets with Multiple Configurations</title>
  3677. <para>
  3678. Bitbake also has functionality that allows you to build
  3679. multiple targets at the same time, where each target uses
  3680. a different configuration.
  3681. </para>
  3682. <para>
  3683. In order to accomplish this, you setup each of the configurations
  3684. you need to use in parallel by placing the configuration files in
  3685. your current build directory alongside the usual
  3686. <filename>local.conf</filename> file.
  3687. </para>
  3688. <para>
  3689. Follow these guidelines to create an environment that supports
  3690. multiple configurations:
  3691. <itemizedlist>
  3692. <listitem><para>
  3693. <emphasis>Create Configuration Files</emphasis>:
  3694. You need to create a single configuration file for each
  3695. configuration for which you want to add support.
  3696. These files would contain lines such as the following:
  3697. <literallayout class='monospaced'>
  3698. MACHINE = "A"
  3699. </literallayout>
  3700. The files would contain any other variables that can
  3701. be set and built in the same directory.
  3702. <note>
  3703. You can change the
  3704. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  3705. to not conflict.
  3706. </note></para>
  3707. <para>
  3708. Furthermore, the configuration file must be located in the
  3709. current build directory in a directory named
  3710. <filename>multiconfig</filename> under the build's
  3711. <filename>conf</filename> directory where
  3712. <filename>local.conf</filename> resides.
  3713. The reason for this restriction is because the
  3714. <filename>BBPATH</filename> variable is not constructed
  3715. until the layers are parsed.
  3716. Consequently, using the configuration file as a
  3717. pre-configuration file is not possible unless it is
  3718. located in the current working directory.
  3719. </para></listitem>
  3720. <listitem><para>
  3721. <emphasis>Add the BitBake Multi-Config Variable to you Local Configuration File</emphasis>:
  3722. Use the
  3723. <filename>BBMULTICONFIG</filename>
  3724. variable in your <filename>conf/local.conf</filename>
  3725. configuration file to specify each separate configuration.
  3726. For example, the following line tells BitBake it should load
  3727. <filename>conf/multiconfig/configA.conf</filename>,
  3728. <filename>conf/multiconfig/configB.conf</filename>, and
  3729. <filename>conf/multiconfig/configC.conf</filename>.
  3730. <literallayout class='monospaced'>
  3731. BBMULTICONFIG = "configA configB configC"
  3732. </literallayout>
  3733. </para></listitem>
  3734. <listitem><para>
  3735. <emphasis>Launch BitBake</emphasis>:
  3736. Use the following BitBake command form to launch the
  3737. build:
  3738. <literallayout class='monospaced'>
  3739. $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ]
  3740. </literallayout>
  3741. Following is an example that supports building a minimal
  3742. image for configuration A alongside a standard
  3743. <filename>core-image-sato</filename>, which takes its
  3744. configuration from <filename>local.conf</filename>:
  3745. <literallayout class='monospaced'>
  3746. $ bitbake multiconfig:configA:core-image-minimal core-image-sato
  3747. </literallayout>
  3748. </para></listitem>
  3749. </itemizedlist>
  3750. </para>
  3751. <para>
  3752. Support for multiple configurations in this current release of
  3753. the Yocto Project (&DISTRO_NAME; &DISTRO;) has some known issues:
  3754. <itemizedlist>
  3755. <listitem><para>
  3756. No inter-multi-configuration dependencies exist.
  3757. </para></listitem>
  3758. <listitem><para>
  3759. Shared State (sstate) optimizations do not exist.
  3760. Consequently, if the build uses the same object twice
  3761. in, for example, two different
  3762. <filename>TMPDIR</filename> directories, the build
  3763. will either load from an existing sstate cache at the
  3764. start or build the object twice.
  3765. </para></listitem>
  3766. </itemizedlist>
  3767. </para>
  3768. </section>
  3769. <section id="platdev-working-with-libraries">
  3770. <title>Working With Libraries</title>
  3771. <para>
  3772. Libraries are an integral part of your system.
  3773. This section describes some common practices you might find
  3774. helpful when working with libraries to build your system:
  3775. <itemizedlist>
  3776. <listitem><para><link linkend='including-static-library-files'>How to include static library files</link>
  3777. </para></listitem>
  3778. <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>
  3779. </para></listitem>
  3780. <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>
  3781. </para></listitem>
  3782. </itemizedlist>
  3783. </para>
  3784. <section id='including-static-library-files'>
  3785. <title>Including Static Library Files</title>
  3786. <para>
  3787. If you are building a library and the library offers static linking, you can control
  3788. which static library files (<filename>*.a</filename> files) get included in the
  3789. built library.
  3790. </para>
  3791. <para>
  3792. The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  3793. and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink>
  3794. variables in the
  3795. <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed
  3796. by the <filename>do_install</filename> task are packaged.
  3797. By default, the <filename>PACKAGES</filename> variable includes
  3798. <filename>${PN}-staticdev</filename>, which represents all static library files.
  3799. <note>
  3800. Some previously released versions of the Yocto Project
  3801. defined the static library files through
  3802. <filename>${PN}-dev</filename>.
  3803. </note>
  3804. Following is part of the BitBake configuration file, where
  3805. you can see how the static library files are defined:
  3806. <literallayout class='monospaced'>
  3807. PACKAGE_BEFORE_PN ?= ""
  3808. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  3809. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  3810. FILES = ""
  3811. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  3812. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  3813. ${base_bindir}/* ${base_sbindir}/* \
  3814. ${base_libdir}/*${SOLIBS} \
  3815. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  3816. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  3817. ${datadir}/pixmaps ${datadir}/applications \
  3818. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  3819. ${libdir}/bonobo/servers"
  3820. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  3821. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  3822. ${datadir}/gnome/help"
  3823. SECTION_${PN}-doc = "doc"
  3824. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  3825. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  3826. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  3827. ${datadir}/aclocal ${base_libdir}/*.o \
  3828. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  3829. SECTION_${PN}-dev = "devel"
  3830. ALLOW_EMPTY_${PN}-dev = "1"
  3831. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  3832. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  3833. SECTION_${PN}-staticdev = "devel"
  3834. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  3835. </literallayout>
  3836. </para>
  3837. </section>
  3838. <section id="combining-multiple-versions-library-files-into-one-image">
  3839. <title>Combining Multiple Versions of Library Files into One Image</title>
  3840. <para>
  3841. The build system offers the ability to build libraries with different
  3842. target optimizations or architecture formats and combine these together
  3843. into one system image.
  3844. You can link different binaries in the image
  3845. against the different libraries as needed for specific use cases.
  3846. This feature is called "Multilib."
  3847. </para>
  3848. <para>
  3849. An example would be where you have most of a system compiled in 32-bit
  3850. mode using 32-bit libraries, but you have something large, like a database
  3851. engine, that needs to be a 64-bit application and uses 64-bit libraries.
  3852. Multilib allows you to get the best of both 32-bit and 64-bit libraries.
  3853. </para>
  3854. <para>
  3855. While the Multilib feature is most commonly used for 32 and 64-bit differences,
  3856. the approach the build system uses facilitates different target optimizations.
  3857. You could compile some binaries to use one set of libraries and other binaries
  3858. to use a different set of libraries.
  3859. The libraries could differ in architecture, compiler options, or other
  3860. optimizations.
  3861. </para>
  3862. <para>
  3863. Several examples exist in the
  3864. <filename>meta-skeleton</filename> layer found in the
  3865. <link linkend='source-directory'>Source Directory</link>:
  3866. <itemizedlist>
  3867. <listitem><para><filename>conf/multilib-example.conf</filename>
  3868. configuration file</para></listitem>
  3869. <listitem><para><filename>conf/multilib-example2.conf</filename>
  3870. configuration file</para></listitem>
  3871. <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename>
  3872. recipe</para></listitem>
  3873. </itemizedlist>
  3874. </para>
  3875. <section id='preparing-to-use-multilib'>
  3876. <title>Preparing to Use Multilib</title>
  3877. <para>
  3878. User-specific requirements drive the Multilib feature.
  3879. Consequently, there is no one "out-of-the-box" configuration that likely
  3880. exists to meet your needs.
  3881. </para>
  3882. <para>
  3883. In order to enable Multilib, you first need to ensure your recipe is
  3884. extended to support multiple libraries.
  3885. Many standard recipes are already extended and support multiple libraries.
  3886. You can check in the <filename>meta/conf/multilib.conf</filename>
  3887. configuration file in the
  3888. <link linkend='source-directory'>Source Directory</link> to see how this is
  3889. done using the
  3890. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink>
  3891. variable.
  3892. Eventually, all recipes will be covered and this list will
  3893. not be needed.
  3894. </para>
  3895. <para>
  3896. For the most part, the Multilib class extension works automatically to
  3897. extend the package name from <filename>${PN}</filename> to
  3898. <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename>
  3899. is the particular multilib (e.g. "lib32-" or "lib64-").
  3900. Standard variables such as
  3901. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  3902. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  3903. <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>,
  3904. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  3905. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and
  3906. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink>
  3907. are automatically extended by the system.
  3908. If you are extending any manual code in the recipe, you can use the
  3909. <filename>${MLPREFIX}</filename> variable to ensure those names are extended
  3910. correctly.
  3911. This automatic extension code resides in <filename>multilib.bbclass</filename>.
  3912. </para>
  3913. </section>
  3914. <section id='using-multilib'>
  3915. <title>Using Multilib</title>
  3916. <para>
  3917. After you have set up the recipes, you need to define the actual
  3918. combination of multiple libraries you want to build.
  3919. You accomplish this through your <filename>local.conf</filename>
  3920. configuration file in the
  3921. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  3922. An example configuration would be as follows:
  3923. <literallayout class='monospaced'>
  3924. MACHINE = "qemux86-64"
  3925. require conf/multilib.conf
  3926. MULTILIBS = "multilib:lib32"
  3927. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  3928. IMAGE_INSTALL_append = " lib32-glib-2.0"
  3929. </literallayout>
  3930. This example enables an
  3931. additional library named <filename>lib32</filename> alongside the
  3932. normal target packages.
  3933. When combining these "lib32" alternatives, the example uses "x86" for tuning.
  3934. For information on this particular tuning, see
  3935. <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>.
  3936. </para>
  3937. <para>
  3938. The example then includes <filename>lib32-glib-2.0</filename>
  3939. in all the images, which illustrates one method of including a
  3940. multiple library dependency.
  3941. You can use a normal image build to include this dependency,
  3942. for example:
  3943. <literallayout class='monospaced'>
  3944. $ bitbake core-image-sato
  3945. </literallayout>
  3946. You can also build Multilib packages specifically with a command like this:
  3947. <literallayout class='monospaced'>
  3948. $ bitbake lib32-glib-2.0
  3949. </literallayout>
  3950. </para>
  3951. </section>
  3952. <section id='additional-implementation-details'>
  3953. <title>Additional Implementation Details</title>
  3954. <para>
  3955. Generic implementation details as well as details that are
  3956. specific to package management systems exist.
  3957. Following are implementation details that exist regardless
  3958. of the package management system:
  3959. <itemizedlist>
  3960. <listitem><para>The typical convention used for the
  3961. class extension code as used by
  3962. Multilib assumes that all package names specified
  3963. in
  3964. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  3965. that contain <filename>${PN}</filename> have
  3966. <filename>${PN}</filename> at the start of the name.
  3967. When that convention is not followed and
  3968. <filename>${PN}</filename> appears at
  3969. the middle or the end of a name, problems occur.
  3970. </para></listitem>
  3971. <listitem><para>The
  3972. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink>
  3973. value under Multilib will be extended to
  3974. "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>"
  3975. (e.g. "-pokymllib32" for a "lib32" Multilib with
  3976. Poky).
  3977. The reason for this slightly unwieldy contraction
  3978. is that any "-" characters in the vendor
  3979. string presently break Autoconf's
  3980. <filename>config.sub</filename>, and
  3981. other separators are problematic for different
  3982. reasons.
  3983. </para></listitem>
  3984. </itemizedlist>
  3985. </para>
  3986. <para>
  3987. For the RPM Package Management System, the following implementation details
  3988. exist:
  3989. <itemizedlist>
  3990. <listitem><para>A unique architecture is defined for the Multilib packages,
  3991. along with creating a unique deploy folder under
  3992. <filename>tmp/deploy/rpm</filename> in the
  3993. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  3994. For example, consider <filename>lib32</filename> in a
  3995. <filename>qemux86-64</filename> image.
  3996. The possible architectures in the system are "all", "qemux86_64",
  3997. "lib32_qemux86_64", and "lib32_x86".</para></listitem>
  3998. <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from
  3999. <filename>${PN}</filename> during RPM packaging.
  4000. The naming for a normal RPM package and a Multilib RPM package in a
  4001. <filename>qemux86-64</filename> system resolves to something similar to
  4002. <filename>bash-4.1-r2.x86_64.rpm</filename> and
  4003. <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively.
  4004. </para></listitem>
  4005. <listitem><para>When installing a Multilib image, the RPM backend first
  4006. installs the base image and then installs the Multilib libraries.
  4007. </para></listitem>
  4008. <listitem><para>The build system relies on RPM to resolve the identical files in the
  4009. two (or more) Multilib packages.</para></listitem>
  4010. </itemizedlist>
  4011. </para>
  4012. <para>
  4013. For the IPK Package Management System, the following implementation details exist:
  4014. <itemizedlist>
  4015. <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from
  4016. <filename>${PN}</filename> during IPK packaging.
  4017. The naming for a normal RPM package and a Multilib IPK package in a
  4018. <filename>qemux86-64</filename> system resolves to something like
  4019. <filename>bash_4.1-r2.x86_64.ipk</filename> and
  4020. <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively.
  4021. </para></listitem>
  4022. <listitem><para>The IPK deploy folder is not modified with
  4023. <filename>${MLPREFIX}</filename> because packages with and without
  4024. the Multilib feature can exist in the same folder due to the
  4025. <filename>${PN}</filename> differences.</para></listitem>
  4026. <listitem><para>IPK defines a sanity check for Multilib installation
  4027. using certain rules for file comparison, overridden, etc.
  4028. </para></listitem>
  4029. </itemizedlist>
  4030. </para>
  4031. </section>
  4032. </section>
  4033. <section id='installing-multiple-versions-of-the-same-library'>
  4034. <title>Installing Multiple Versions of the Same Library</title>
  4035. <para>
  4036. Situations can exist where you need to install and use
  4037. multiple versions of the same library on the same system
  4038. at the same time.
  4039. These situations almost always exist when a library API
  4040. changes and you have multiple pieces of software that
  4041. depend on the separate versions of the library.
  4042. To accommodate these situations, you can install multiple
  4043. versions of the same library in parallel on the same system.
  4044. </para>
  4045. <para>
  4046. The process is straightforward as long as the libraries use
  4047. proper versioning.
  4048. With properly versioned libraries, all you need to do to
  4049. individually specify the libraries is create separate,
  4050. appropriately named recipes where the
  4051. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the
  4052. name includes a portion that differentiates each library version
  4053. (e.g.the major part of the version number).
  4054. Thus, instead of having a single recipe that loads one version
  4055. of a library (e.g. <filename>clutter</filename>), you provide
  4056. multiple recipes that result in different versions
  4057. of the libraries you want.
  4058. As an example, the following two recipes would allow the
  4059. two separate versions of the <filename>clutter</filename>
  4060. library to co-exist on the same system:
  4061. <literallayout class='monospaced'>
  4062. clutter-1.6_1.6.20.bb
  4063. clutter-1.8_1.8.4.bb
  4064. </literallayout>
  4065. Additionally, if you have other recipes that depend on a given
  4066. library, you need to use the
  4067. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  4068. variable to create the dependency.
  4069. Continuing with the same example, if you want to have a recipe
  4070. depend on the 1.8 version of the <filename>clutter</filename>
  4071. library, use the following in your recipe:
  4072. <literallayout class='monospaced'>
  4073. DEPENDS = "clutter-1.8"
  4074. </literallayout>
  4075. </para>
  4076. </section>
  4077. </section>
  4078. <section id='enabling-gobject-introspection-support'>
  4079. <title>Enabling GObject Introspection Support</title>
  4080. <para>
  4081. <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink>
  4082. is the standard mechanism for accessing GObject-based software
  4083. from runtime environments.
  4084. GObject is a feature of the GLib library that provides an object
  4085. framework for the GNOME desktop and related software.
  4086. GObject Introspection adds information to GObject that allows
  4087. objects created within it to be represented across different
  4088. programming languages.
  4089. If you want to construct GStreamer pipelines using Python, or
  4090. control UPnP infrastructure using Javascript and GUPnP,
  4091. GObject introspection is the only way to do it.
  4092. </para>
  4093. <para>
  4094. This section describes the Yocto Project support for generating
  4095. and packaging GObject introspection data.
  4096. GObject introspection data is a description of the
  4097. API provided by libraries built on top of GLib framework,
  4098. and, in particular, that framework's GObject mechanism.
  4099. GObject Introspection Repository (GIR) files go to
  4100. <filename>-dev</filename> packages,
  4101. <filename>typelib</filename> files go to main packages as they
  4102. are packaged together with libraries that are introspected.
  4103. </para>
  4104. <para>
  4105. The data is generated when building such a library, by linking
  4106. the library with a small executable binary that asks the library
  4107. to describe itself, and then executing the binary and
  4108. processing its output.
  4109. </para>
  4110. <para>
  4111. Generating this data in a cross-compilation environment
  4112. is difficult because the library is produced for the target
  4113. architecture, but its code needs to be executed on the build host.
  4114. This problem is solved with the OpenEmbedded build system by
  4115. running the code through QEMU, which allows precisely that.
  4116. Unfortunately, QEMU does not always work perfectly as mentioned
  4117. in the xxx section.
  4118. </para>
  4119. <section id='enabling-the-generation-of-introspection-data'>
  4120. <title>Enabling the Generation of Introspection Data</title>
  4121. <para>
  4122. Enabling the generation of introspection data (GIR files)
  4123. in your library package involves the following:
  4124. <orderedlist>
  4125. <listitem><para>
  4126. Inherit the
  4127. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink>
  4128. class.
  4129. </para></listitem>
  4130. <listitem><para>
  4131. Make sure introspection is not disabled anywhere in
  4132. the recipe or from anything the recipe includes.
  4133. Also, make sure that "gobject-introspection-data" is
  4134. not in
  4135. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  4136. and that "qemu-usermode" is not in
  4137. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  4138. If either of these conditions exist, nothing will
  4139. happen.
  4140. </para></listitem>
  4141. <listitem><para>
  4142. Try to build the recipe.
  4143. If you encounter build errors that look like
  4144. something is unable to find
  4145. <filename>.so</filename> libraries, check where these
  4146. libraries are located in the source tree and add
  4147. the following to the recipe:
  4148. <literallayout class='monospaced'>
  4149. GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs"
  4150. </literallayout>
  4151. <note>
  4152. See recipes in the <filename>oe-core</filename>
  4153. repository that use that
  4154. <filename>GIR_EXTRA_LIBS_PATH</filename> variable
  4155. as an example.
  4156. </note>
  4157. </para></listitem>
  4158. <listitem><para>
  4159. Look for any other errors, which probably mean that
  4160. introspection support in a package is not entirely
  4161. standard, and thus breaks down in a cross-compilation
  4162. environment.
  4163. For such cases, custom-made fixes are needed.
  4164. A good place to ask and receive help in these cases
  4165. is the
  4166. <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>.
  4167. </para></listitem>
  4168. </orderedlist>
  4169. <note>
  4170. Using a library that no longer builds against the latest
  4171. Yocto Project release and prints introspection related
  4172. errors is a good candidate for the previous procedure.
  4173. </note>
  4174. </para>
  4175. </section>
  4176. <section id='disabling-the-generation-of-introspection-data'>
  4177. <title>Disabling the Generation of Introspection Data</title>
  4178. <para>
  4179. You might find that you do not want to generate
  4180. introspection data.
  4181. Or, perhaps QEMU does not work on your build host and
  4182. target architecture combination.
  4183. If so, you can use either of the following methods to
  4184. disable GIR file generations:
  4185. <itemizedlist>
  4186. <listitem><para>
  4187. Add the following to your distro configuration:
  4188. <literallayout class='monospaced'>
  4189. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  4190. </literallayout>
  4191. Adding this statement disables generating
  4192. introspection data using QEMU but will still enable
  4193. building introspection tools and libraries
  4194. (i.e. building them does not require the use of QEMU).
  4195. </para></listitem>
  4196. <listitem><para>
  4197. Add the following to your machine configuration:
  4198. <literallayout class='monospaced'>
  4199. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  4200. </literallayout>
  4201. Adding this statement disables the use of QEMU
  4202. when building packages for your machine.
  4203. Currently, this feature is used only by introspection
  4204. recipes and has the same effect as the previously
  4205. described option.
  4206. <note>
  4207. Future releases of the Yocto Project might have
  4208. other features affected by this option.
  4209. </note>
  4210. </para></listitem>
  4211. </itemizedlist>
  4212. If you disable introspection data, you can still
  4213. obtain it through other means such as copying the data
  4214. from a suitable sysroot, or by generating it on the
  4215. target hardware.
  4216. The OpenEmbedded build system does not currently
  4217. provide specific support for these techniques.
  4218. </para>
  4219. </section>
  4220. <section id='testing-that-introspection-works-in-an-image'>
  4221. <title>Testing that Introspection Works in an Image</title>
  4222. <para>
  4223. Use the following procedure to test if generating
  4224. introspection data is working in an image:
  4225. <orderedlist>
  4226. <listitem><para>
  4227. Make sure that "gobject-introspection-data" is not in
  4228. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  4229. and that "qemu-usermode" is not in
  4230. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  4231. </para></listitem>
  4232. <listitem><para>
  4233. Build <filename>core-image-sato</filename>.
  4234. </para></listitem>
  4235. <listitem><para>
  4236. Launch a Terminal and then start Python in the
  4237. terminal.
  4238. </para></listitem>
  4239. <listitem><para>
  4240. Enter the following in the terminal:
  4241. <literallayout class='monospaced'>
  4242. >>> from gi.repository import GLib
  4243. >>> GLib.get_host_name()
  4244. </literallayout>
  4245. </para></listitem>
  4246. <listitem><para>
  4247. For something a little more advanced, enter the
  4248. following:
  4249. <literallayout class='monospaced'>
  4250. http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
  4251. </literallayout>
  4252. </para></listitem>
  4253. </orderedlist>
  4254. </para>
  4255. </section>
  4256. <section id='known-issues'>
  4257. <title>Known Issues</title>
  4258. <para>
  4259. The following know issues exist for
  4260. GObject Introspection Support:
  4261. <itemizedlist>
  4262. <listitem><para>
  4263. <filename>qemu-ppc64</filename> immediately crashes.
  4264. Consequently, you cannot build introspection data on
  4265. that architecture.
  4266. </para></listitem>
  4267. <listitem><para>
  4268. x32 is not supported by QEMU.
  4269. Consequently, introspection data is disabled.
  4270. </para></listitem>
  4271. <listitem><para>
  4272. musl causes transient GLib binaries to crash on
  4273. assertion failures.
  4274. Consequently, generating introspection data is
  4275. disabled.
  4276. </para></listitem>
  4277. <listitem><para>
  4278. Because QEMU is not able to run the binaries correctly,
  4279. introspection is disabled for some specific packages
  4280. under specific architectures (e.g.
  4281. <filename>gcr</filename>,
  4282. <filename>libsecret</filename>, and
  4283. <filename>webkit</filename>).
  4284. </para></listitem>
  4285. <listitem><para>
  4286. QEMU usermode might not work properly when running
  4287. 64-bit binaries under 32-bit host machines.
  4288. In particular, "qemumips64" is known to not work under
  4289. i686.
  4290. </para></listitem>
  4291. </itemizedlist>
  4292. </para>
  4293. </section>
  4294. </section>
  4295. <section id='dev-optionally-using-an-external-toolchain'>
  4296. <title>Optionally Using an External Toolchain</title>
  4297. <para>
  4298. You might want to use an external toolchain as part of your
  4299. development.
  4300. If this is the case, the fundamental steps you need to accomplish
  4301. are as follows:
  4302. <itemizedlist>
  4303. <listitem><para>
  4304. Understand where the installed toolchain resides.
  4305. For cases where you need to build the external toolchain,
  4306. you would need to take separate steps to build and install
  4307. the toolchain.
  4308. </para></listitem>
  4309. <listitem><para>
  4310. Make sure you add the layer that contains the toolchain to
  4311. your <filename>bblayers.conf</filename> file through the
  4312. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  4313. variable.
  4314. </para></listitem>
  4315. <listitem><para>
  4316. Set the
  4317. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink>
  4318. variable in your <filename>local.conf</filename> file
  4319. to the location in which you installed the toolchain.
  4320. </para></listitem>
  4321. </itemizedlist>
  4322. A good example of an external toolchain used with the Yocto Project
  4323. is <trademark class='registered'>Mentor Graphics</trademark>
  4324. Sourcery G++ Toolchain.
  4325. You can see information on how to use that particular layer in the
  4326. <filename>README</filename> file at
  4327. <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
  4328. You can find further information by reading about the
  4329. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
  4330. variable in the Yocto Project Reference Manual's variable glossary.
  4331. </para>
  4332. </section>
  4333. <section id='creating-partitioned-images'>
  4334. <title>Creating Partitioned Images</title>
  4335. <para>
  4336. Creating an image for a particular hardware target using the
  4337. OpenEmbedded build system does not necessarily mean you can boot
  4338. that image as is on your device.
  4339. Physical devices accept and boot images in various ways depending
  4340. on the specifics of the device.
  4341. Usually, information about the hardware can tell you what image
  4342. format the device requires.
  4343. Should your device require multiple partitions on an SD card, flash,
  4344. or an HDD, you can use the OpenEmbedded Image Creator,
  4345. Wic, to create the properly partitioned image.
  4346. </para>
  4347. <para>
  4348. You can generate partitioned images
  4349. (<replaceable>image</replaceable><filename>.wic</filename>)
  4350. two ways: using the OpenEmbedded build system and by running
  4351. the OpenEmbedded Image Creator Wic directly.
  4352. The former way is preferable as it is easier to use and understand.
  4353. </para>
  4354. <section id='creating-wic-images-oe'>
  4355. <title>Creating Partitioned Images</title>
  4356. <para>
  4357. The OpenEmbedded build system can generate
  4358. partitioned images the same way as it generates
  4359. any other image type.
  4360. To generate a partitioned image, you need to modify
  4361. two variables.
  4362. <itemizedlist>
  4363. <listitem><para>
  4364. Include "wic" as part of the
  4365. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  4366. variable.
  4367. </para></listitem>
  4368. <listitem><para>
  4369. Include the name of the
  4370. <link linkend='openembedded-kickstart-wks-reference'>wic kickstart file</link>
  4371. as part of the
  4372. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink>
  4373. variable
  4374. </para></listitem>
  4375. </itemizedlist>
  4376. Further steps to generate a partitioned image
  4377. are the same as for any other image type.
  4378. For information on image types, see the
  4379. "<link linkend='building-images'>Building Images</link>"
  4380. section.
  4381. </para>
  4382. </section>
  4383. <section id='create-wic-images-wic'>
  4384. <title>Using OpenEmbedded Image Creator Wic to Generate Partitioned Images</title>
  4385. <para>
  4386. The <filename>wic</filename> command generates partitioned
  4387. images from existing OpenEmbedded build artifacts.
  4388. Image generation is driven by partitioning commands
  4389. contained in an Openembedded kickstart file
  4390. (<filename>.wks</filename>) specified either directly on
  4391. the command line or as one of a selection of canned
  4392. <filename>.wks</filename> files as shown with the
  4393. <filename>wic list images</filename> command in the
  4394. "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>"
  4395. section.
  4396. When you apply the command to a given set of build
  4397. artifacts, the result is an image or set of images that
  4398. can be directly written onto media and used on a particular
  4399. system.
  4400. </para>
  4401. <para>
  4402. The <filename>wic</filename> command and the infrastructure
  4403. it is based on is by definition incomplete.
  4404. The purpose of the command is to allow the generation of
  4405. customized images, and as such, was designed to be
  4406. completely extensible through a plug-in interface.
  4407. See the
  4408. "<link linkend='openembedded-kickstart-plugins'>Plug-ins</link>"
  4409. section for information on these plug-ins.
  4410. </para>
  4411. <para>
  4412. This section provides some background information on Wic,
  4413. describes what you need to have in
  4414. place to run the tool, provides instruction on how to use
  4415. the <filename>wic</filename> utility,
  4416. and provides several examples.
  4417. </para>
  4418. <section id='wic-background'>
  4419. <title>Background</title>
  4420. <para>
  4421. This section provides some background on the
  4422. <filename>wic</filename> utility.
  4423. While none of this information is required to use
  4424. Wic, you might find it interesting.
  4425. <itemizedlist>
  4426. <listitem><para>
  4427. The name "Wic" is derived from OpenEmbedded
  4428. Image Creator (oeic).
  4429. The "oe" diphthong in "oeic" was promoted to the
  4430. letter "w", because "oeic" is both difficult to
  4431. remember and to pronounce.
  4432. </para></listitem>
  4433. <listitem><para>
  4434. Wic is loosely based on the
  4435. Meego Image Creator (<filename>mic</filename>)
  4436. framework.
  4437. The Wic implementation has been
  4438. heavily modified to make direct use of OpenEmbedded
  4439. build artifacts instead of package installation and
  4440. configuration, which are already incorporated within
  4441. the OpenEmbedded artifacts.
  4442. </para></listitem>
  4443. <listitem><para>
  4444. Wic is a completely independent
  4445. standalone utility that initially provides
  4446. easier-to-use and more flexible replacements for an
  4447. existing functionality in OE Core's
  4448. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink>
  4449. class and <filename>mkefidisk.sh</filename> script.
  4450. The difference between
  4451. Wic and those examples is
  4452. that with Wic the
  4453. functionality of those scripts is implemented
  4454. by a general-purpose partitioning language, which is
  4455. based on Redhat kickstart syntax.</para></listitem>
  4456. </itemizedlist>
  4457. </para>
  4458. </section>
  4459. <section id='wic-requirements'>
  4460. <title>Requirements</title>
  4461. <para>
  4462. In order to use the <filename>wic</filename> utility
  4463. with the OpenEmbedded Build system, your system needs
  4464. to meet the following requirements:
  4465. <itemizedlist>
  4466. <listitem><para>The Linux distribution on your
  4467. development host must support the Yocto Project.
  4468. See the
  4469. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  4470. section in the Yocto Project Reference Manual for
  4471. the list of distributions that support the
  4472. Yocto Project.
  4473. </para></listitem>
  4474. <listitem><para>
  4475. The standard system utilities, such as
  4476. <filename>cp</filename>, must be installed on your
  4477. development host system.
  4478. </para></listitem>
  4479. <listitem><para>
  4480. You need to have the build artifacts already
  4481. available, which typically means that you must
  4482. have already created an image using the
  4483. Openembedded build system (e.g.
  4484. <filename>core-image-minimal</filename>).
  4485. While it might seem redundant to generate an image
  4486. in order to create an image using
  4487. Wic, the current version of
  4488. Wic requires the artifacts
  4489. in the form generated by the build system.
  4490. </para></listitem>
  4491. <listitem><para>
  4492. You must build several native tools, which are tools
  4493. built to run on the build system:
  4494. <literallayout class='monospaced'>
  4495. $ bitbake parted-native dosfstools-native mtools-native
  4496. </literallayout>
  4497. </para></listitem>
  4498. <listitem><para>
  4499. You must have sourced one of the build environment
  4500. setup scripts (i.e.
  4501. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  4502. or
  4503. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  4504. found in the
  4505. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4506. </para></listitem>
  4507. </itemizedlist>
  4508. </para>
  4509. </section>
  4510. <section id='wic-getting-help'>
  4511. <title>Getting Help</title>
  4512. <para>
  4513. You can get general help for the <filename>wic</filename>
  4514. command by entering the <filename>wic</filename> command
  4515. by itself or by entering the command with a help argument
  4516. as follows:
  4517. <literallayout class='monospaced'>
  4518. $ wic -h
  4519. $ wic --help
  4520. </literallayout>
  4521. </para>
  4522. <para>
  4523. Currently, Wic supports two commands:
  4524. <filename>create</filename> and <filename>list</filename>.
  4525. You can get help for these commands as follows:
  4526. <literallayout class='monospaced'>
  4527. $ wic help <replaceable>command</replaceable>
  4528. with <replaceable>command</replaceable> being either
  4529. <filename>create</filename> or <filename>list</filename>.
  4530. </literallayout>
  4531. </para>
  4532. <para>
  4533. You can also get detailed help on a number of topics
  4534. from the help system.
  4535. The output of <filename>wic --help</filename>
  4536. displays a list of available help
  4537. topics under a "Help topics" heading.
  4538. You can have the help system display the help text for
  4539. a given topic by prefacing the topic with
  4540. <filename>wic help</filename>:
  4541. <literallayout class='monospaced'>
  4542. $ wic help <replaceable>help_topic</replaceable>
  4543. </literallayout>
  4544. </para>
  4545. <para>
  4546. You can find out more about the images
  4547. Wic creates using the existing
  4548. kickstart files with the following form of the command:
  4549. <literallayout class='monospaced'>
  4550. $ wic list <replaceable>image</replaceable> help
  4551. </literallayout>
  4552. with <filename><replaceable>image</replaceable></filename>
  4553. being either <filename>directdisk</filename> or
  4554. <filename>mkefidisk</filename>.
  4555. </para>
  4556. </section>
  4557. <section id='operational-modes'>
  4558. <title>Operational Modes</title>
  4559. <para>
  4560. You can use Wic in two different
  4561. modes, depending on how much control you need for
  4562. specifying the Openembedded build artifacts that are
  4563. used for creating the image: Raw and Cooked:
  4564. <itemizedlist>
  4565. <listitem><para>
  4566. <emphasis>Raw Mode:</emphasis>
  4567. You explicitly specify build artifacts through
  4568. command-line arguments.
  4569. </para></listitem>
  4570. <listitem><para>
  4571. <emphasis>Cooked Mode:</emphasis>
  4572. The current
  4573. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4574. setting and image name are used to automatically
  4575. locate and provide the build artifacts.
  4576. </para></listitem>
  4577. </itemizedlist>
  4578. </para>
  4579. <para>
  4580. Regardless of the mode you use, you need to have the build
  4581. artifacts ready and available.
  4582. Additionally, the environment must be set up using the
  4583. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  4584. or
  4585. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>
  4586. script found in the
  4587. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4588. </para>
  4589. <section id='raw-mode'>
  4590. <title>Raw Mode</title>
  4591. <para>
  4592. The general form of the
  4593. <filename>wic</filename> command in raw mode is:
  4594. <literallayout class='monospaced'>
  4595. $ wic create <replaceable>image_name</replaceable>.wks [<replaceable>options</replaceable>] [...]
  4596. Where:
  4597. <replaceable>image_name</replaceable>.wks
  4598. An OpenEmbedded kickstart file. You can provide
  4599. your own custom file or use a file from a set of
  4600. existing files as described by further options.
  4601. -o <replaceable>OUTDIR</replaceable>, --outdir=<replaceable>OUTDIR</replaceable>
  4602. The name of a directory in which to create image.
  4603. -i <replaceable>PROPERTIES_FILE</replaceable>, --infile=<replaceable>PROPERTIES_FILE</replaceable>
  4604. The name of a file containing the values for image
  4605. properties as a JSON file.
  4606. -e <replaceable>IMAGE_NAME</replaceable>, --image-name=<replaceable>IMAGE_NAME</replaceable>
  4607. The name of the image from which to use the artifacts
  4608. (e.g. <filename>core-image-sato</filename>).
  4609. -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir=<replaceable>ROOTFS_DIR</replaceable>
  4610. The path to the <filename>/rootfs</filename> directory to use as the
  4611. <filename>.wks</filename> rootfs source.
  4612. -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir=<replaceable>BOOTIMG_DIR</replaceable>
  4613. The path to the directory containing the boot artifacts
  4614. (e.g. <filename>/EFI</filename> or <filename>/syslinux</filename>) to use as the <filename>.wks</filename> bootimg
  4615. source.
  4616. -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir=<replaceable>KERNEL_DIR</replaceable>
  4617. The path to the directory containing the kernel to use
  4618. in the <filename>.wks</filename> boot image.
  4619. -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot=<replaceable>NATIVE_SYSROOT</replaceable>
  4620. The path to the native sysroot containing the tools to use
  4621. to build the image.
  4622. -s, --skip-build-check
  4623. Skips the build check.
  4624. -D, --debug
  4625. Output debug information.
  4626. </literallayout>
  4627. <note>
  4628. You do not need root privileges to run
  4629. Wic.
  4630. In fact, you should not run as root when using the
  4631. utility.
  4632. </note>
  4633. </para>
  4634. </section>
  4635. <section id='cooked-mode'>
  4636. <title>Cooked Mode</title>
  4637. <para>
  4638. The general form of the <filename>wic</filename> command
  4639. using Cooked Mode is:
  4640. <literallayout class='monospaced'>
  4641. $ wic create <replaceable>kickstart_file</replaceable> -e <replaceable>image_name</replaceable>
  4642. Where:
  4643. <replaceable>kickstart_file</replaceable>
  4644. An OpenEmbedded kickstart file. You can provide your own
  4645. custom file or a supplied file.
  4646. <replaceable>image_name</replaceable>
  4647. Specifies the image built using the OpenEmbedded build
  4648. system.
  4649. </literallayout>
  4650. This form is the simplest and most user-friendly, as it
  4651. does not require specifying all individual parameters.
  4652. All you need to provide is your own
  4653. <filename>.wks</filename> file or one provided with the
  4654. release.
  4655. </para>
  4656. </section>
  4657. </section>
  4658. <section id='using-a-provided-kickstart-file'>
  4659. <title>Using an Existing Kickstart File</title>
  4660. <para>
  4661. If you do not want to create your own
  4662. <filename>.wks</filename> file, you can use an existing
  4663. file provided by the Wic installation.
  4664. Use the following command to list the available files:
  4665. <literallayout class='monospaced'>
  4666. $ wic list images
  4667. directdisk Create a 'pcbios' direct disk image
  4668. mkefidisk Create an EFI disk image
  4669. </literallayout>
  4670. When you use an existing file, you do not have to use the
  4671. <filename>.wks</filename> extension.
  4672. Here is an example in Raw Mode that uses the
  4673. <filename>directdisk</filename> file:
  4674. <literallayout class='monospaced'>
  4675. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  4676. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  4677. </literallayout>
  4678. </para>
  4679. <para>
  4680. Here are the actual partition language commands
  4681. used in the <filename>mkefidisk.wks</filename> file to
  4682. generate an image:
  4683. <literallayout class='monospaced'>
  4684. # short-description: Create an EFI disk image
  4685. # long-description: Creates a partitioned EFI disk image that the user
  4686. # can directly dd to boot media.
  4687. part /boot --source bootimg-efi --ondisk sda --label msdos --active --align 1024
  4688. part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024
  4689. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  4690. bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0"
  4691. </literallayout>
  4692. </para>
  4693. </section>
  4694. <section id='wic-usage-examples'>
  4695. <title>Examples</title>
  4696. <para>
  4697. This section provides several examples that show how to use
  4698. the <filename>wic</filename> utility.
  4699. All the examples assume the list of requirements in the
  4700. "<link linkend='wic-requirements'>Requirements</link>"
  4701. section have been met.
  4702. The examples assume the previously generated image is
  4703. <filename>core-image-minimal</filename>.
  4704. </para>
  4705. <section id='generate-an-image-using-a-provided-kickstart-file'>
  4706. <title>Generate an Image using an Existing Kickstart File</title>
  4707. <para>
  4708. This example runs in Cooked Mode and uses the
  4709. <filename>mkefidisk</filename> kickstart file:
  4710. <literallayout class='monospaced'>
  4711. $ wic create mkefidisk -e core-image-minimal
  4712. Checking basic build environment...
  4713. Done.
  4714. Creating image(s)...
  4715. Info: The new image(s) can be found here:
  4716. <replaceable>current_directory</replaceable>/build/mkefidisk-201310230946-sda.direct
  4717. The following build artifacts were used to create the image(s):
  4718. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/rootfs
  4719. 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
  4720. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/minnow/usr/src/kernel
  4721. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  4722. The image(s) were created using OE kickstart file:
  4723. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/mkefidisk.wks
  4724. </literallayout>
  4725. The previous example shows the easiest way to create
  4726. an image by running in Cooked Mode and using the
  4727. <filename>-e</filename> option with an existing
  4728. kickstart file.
  4729. All that is necessary is to specify the image used to
  4730. generate the artifacts.
  4731. Your <filename>local.conf</filename> needs to have the
  4732. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4733. variable set to the machine you are using, which is
  4734. "minnow" in this example.
  4735. </para>
  4736. <para>
  4737. The output specifies the exact image created as well as
  4738. where it was created, which is in the current
  4739. directory by default.
  4740. The output also names the artifacts used and the exact
  4741. <filename>.wks</filename> script that was used to
  4742. generate the image.
  4743. <note>
  4744. You should always verify the details provided in the
  4745. output to make sure that the image was indeed
  4746. created exactly as expected.
  4747. </note>
  4748. </para>
  4749. <para>
  4750. Continuing with the example, you can now write the
  4751. image to a USB stick, or whatever media for which you
  4752. built your image, and boot the resulting media.
  4753. You can write the image by using
  4754. <filename>bmaptool</filename> or
  4755. <filename>dd</filename>:
  4756. <literallayout class='monospaced'>
  4757. $ oe-run-native bmaptool copy build/mkefidisk-201310230946-sda.direct /dev/sd<replaceable>X</replaceable>
  4758. </literallayout>
  4759. or
  4760. <literallayout class='monospaced'>
  4761. $ sudo dd if=build/mkefidisk-201310230946-sda.direct of=/dev/sd<replaceable>X</replaceable>
  4762. </literallayout>
  4763. <note>
  4764. For more information on how to use the
  4765. <filename>bmaptool</filename> to flash a device
  4766. with an image, see the
  4767. "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>"
  4768. section.
  4769. </note>
  4770. </para>
  4771. </section>
  4772. <section id='using-a-modified-kickstart-file'>
  4773. <title>Using a Modified Kickstart File</title>
  4774. <para>
  4775. Because partitioned image creation is
  4776. driven by the kickstart file, it is easy to affect
  4777. image creation by changing the parameters in the file.
  4778. This next example demonstrates that through modification
  4779. of the <filename>directdisk</filename> kickstart file.
  4780. </para>
  4781. <para>
  4782. As mentioned earlier, you can use the command
  4783. <filename>wic list images</filename> to show the list
  4784. of existing kickstart files.
  4785. The directory in which these files reside is
  4786. <filename>scripts/lib/image/canned-wks/</filename>
  4787. located in the
  4788. <link linkend='source-directory'>Source Directory</link>.
  4789. Because the available files reside in this directory,
  4790. you can create and add your own custom files to the
  4791. directory.
  4792. Subsequent use of the
  4793. <filename>wic list images</filename> command would then
  4794. include your kickstart files.
  4795. </para>
  4796. <para>
  4797. In this example, the existing
  4798. <filename>directdisk</filename> file already does most
  4799. of what is needed.
  4800. However, for the hardware in this example, the image
  4801. will need to boot from <filename>sdb</filename> instead
  4802. of <filename>sda</filename>, which is what the
  4803. <filename>directdisk</filename> kickstart file uses.
  4804. </para>
  4805. <para>
  4806. The example begins by making a copy of the
  4807. <filename>directdisk.wks</filename> file in the
  4808. <filename>scripts/lib/image/canned-wks</filename>
  4809. directory and then by changing the lines that specify
  4810. the target disk from which to boot.
  4811. <literallayout class='monospaced'>
  4812. $ cp /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks \
  4813. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks
  4814. </literallayout>
  4815. Next, the example modifies the
  4816. <filename>directdisksdb.wks</filename> file and changes
  4817. all instances of "<filename>--ondisk sda</filename>"
  4818. to "<filename>--ondisk sdb</filename>".
  4819. The example changes the following two lines and leaves
  4820. the remaining lines untouched:
  4821. <literallayout class='monospaced'>
  4822. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  4823. part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024
  4824. </literallayout>
  4825. Once the lines are changed, the example generates the
  4826. <filename>directdisksdb</filename> image.
  4827. The command points the process at the
  4828. <filename>core-image-minimal</filename> artifacts for
  4829. the Next Unit of Computing (nuc)
  4830. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4831. the <filename>local.conf</filename>.
  4832. <literallayout class='monospaced'>
  4833. $ wic create directdisksdb -e core-image-minimal
  4834. Checking basic build environment...
  4835. Done.
  4836. Creating image(s)...
  4837. Info: The new image(s) can be found here:
  4838. <replaceable>current_directory</replaceable>/build/directdisksdb-201310231131-sdb.direct
  4839. The following build artifacts were used to create the image(s):
  4840. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/nuc-poky-linux/core-image-minimal/1.0-r0/rootfs
  4841. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/share
  4842. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/src/kernel
  4843. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  4844. The image(s) were created using OE kickstart file:
  4845. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks
  4846. </literallayout>
  4847. Continuing with the example, you can now directly
  4848. <filename>dd</filename> the image to a USB stick, or
  4849. whatever media for which you built your image,
  4850. and boot the resulting media:
  4851. <literallayout class='monospaced'>
  4852. $ sudo dd if=build/directdisksdb-201310231131-sdb.direct of=/dev/sdb
  4853. 86018+0 records in
  4854. 86018+0 records out
  4855. 44041216 bytes (44 MB) copied, 13.0734 s, 3.4 MB/s
  4856. [trz at empanada tmp]$ sudo eject /dev/sdb
  4857. </literallayout>
  4858. </para>
  4859. </section>
  4860. <section id='creating-an-image-based-on-core-image-minimal-and-crownbay-noemgd'>
  4861. <title>Creating an Image Based on <filename>core-image-minimal</filename> and <filename>crownbay-noemgd</filename></title>
  4862. <para>
  4863. This example creates an image based on
  4864. <filename>core-image-minimal</filename> and a
  4865. <filename>crownbay-noemgd</filename>
  4866. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4867. that works right out of the box.
  4868. <literallayout class='monospaced'>
  4869. $ wic create directdisk -e core-image-minimal
  4870. Checking basic build environment...
  4871. Done.
  4872. Creating image(s)...
  4873. Info: The new image(s) can be found here:
  4874. <replaceable>current_directory</replaceable>/build/directdisk-201309252350-sda.direct
  4875. The following build artifacts were used to create the image(s):
  4876. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs
  4877. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share
  4878. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4879. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4880. The image(s) were created using OE kickstart file:
  4881. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks
  4882. </literallayout>
  4883. </para>
  4884. </section>
  4885. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  4886. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  4887. <para>
  4888. This next example manually specifies each build artifact
  4889. (runs in Raw Mode) and uses a modified kickstart file.
  4890. The example also uses the <filename>-o</filename> option
  4891. to cause Wic to create the output
  4892. somewhere other than the default output directory,
  4893. which is the current directory:
  4894. <literallayout class='monospaced'>
  4895. $ wic create ~/test.wks -o /home/trz/testwic --rootfs-dir \
  4896. /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs \
  4897. --bootimg-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share \
  4898. --kernel-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel \
  4899. --native-sysroot /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  4900. Creating image(s)...
  4901. Info: The new image(s) can be found here:
  4902. /home/trz/testwic/build/test-201309260032-sda.direct
  4903. The following build artifacts were used to create the image(s):
  4904. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs
  4905. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share
  4906. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4907. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4908. The image(s) were created using OE kickstart file:
  4909. /home/trz/test.wks
  4910. </literallayout>
  4911. For this example,
  4912. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4913. did not have to be specified in the
  4914. <filename>local.conf</filename> file since the
  4915. artifact is manually specified.
  4916. </para>
  4917. </section>
  4918. </section>
  4919. <section id='openembedded-kickstart-plugins'>
  4920. <title>Plug-ins</title>
  4921. <para>
  4922. Plug-ins allow Wic functionality to
  4923. be extended and specialized by users.
  4924. This section documents the plug-in interface, which is
  4925. currently restricted to source plug-ins.
  4926. </para>
  4927. <para>
  4928. Source plug-ins provide a mechanism to customize
  4929. various aspects of the image generation process in
  4930. Wic, mainly the contents of
  4931. partitions.
  4932. The plug-ins provide a mechanism for mapping values
  4933. specified in <filename>.wks</filename> files using the
  4934. <filename>--source</filename> keyword to a
  4935. particular plug-in implementation that populates a
  4936. corresponding partition.
  4937. <note>
  4938. If you use plug-ins that have build-time dependencies
  4939. (e.g. native tools, bootloaders, and so forth)
  4940. when building a Wic image, you need to specify those
  4941. dependencies using the
  4942. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink>
  4943. variable.
  4944. </note>
  4945. </para>
  4946. <para>
  4947. A source plug-in is created as a subclass of
  4948. <filename>SourcePlugin</filename>.
  4949. The plug-in file containing it is added to
  4950. <filename>scripts/lib/wic/plugins/source/</filename> to
  4951. make the plug-in implementation available to the
  4952. Wic implementation.
  4953. For more information, see
  4954. <filename>scripts/lib/wic/pluginbase.py</filename>.
  4955. </para>
  4956. <para>
  4957. Source plug-ins can also be implemented and added by
  4958. external layers.
  4959. As such, any plug-ins found in a
  4960. <filename>scripts/lib/wic/plugins/source/</filename>
  4961. directory in an external layer are also made
  4962. available.
  4963. </para>
  4964. <para>
  4965. When the Wic implementation needs
  4966. to invoke a partition-specific implementation, it looks
  4967. for the plug-in that has the same name as the
  4968. <filename>--source</filename> parameter given to
  4969. that partition.
  4970. For example, if the partition is set up as follows:
  4971. <literallayout class='monospaced'>
  4972. part /boot --source bootimg-pcbios ...
  4973. </literallayout>
  4974. The methods defined as class members of the plug-in
  4975. having the matching <filename>bootimg-pcbios.name</filename>
  4976. class member are used.
  4977. </para>
  4978. <para>
  4979. To be more concrete, here is the plug-in definition that
  4980. matches a
  4981. <filename>--source bootimg-pcbios</filename> usage,
  4982. along with an example
  4983. method called by the Wic implementation
  4984. when it needs to invoke an implementation-specific
  4985. partition-preparation function:
  4986. <literallayout class='monospaced'>
  4987. class BootimgPcbiosPlugin(SourcePlugin):
  4988. name = 'bootimg-pcbios'
  4989. @classmethod
  4990. def do_prepare_partition(self, part, ...)
  4991. </literallayout>
  4992. If the subclass itself does not implement a function, a
  4993. default version in a superclass is located and
  4994. used, which is why all plug-ins must be derived from
  4995. <filename>SourcePlugin</filename>.
  4996. </para>
  4997. <para>
  4998. The <filename>SourcePlugin</filename> class defines the
  4999. following methods, which is the current set of methods
  5000. that can be implemented or overridden by
  5001. <filename>--source</filename> plug-ins.
  5002. Any methods not implemented by a
  5003. <filename>SourcePlugin</filename> subclass inherit the
  5004. implementations present in the
  5005. <filename>SourcePlugin</filename> class.
  5006. For more information, see the
  5007. <filename>SourcePlugin</filename> source for details:
  5008. </para>
  5009. <para>
  5010. <itemizedlist>
  5011. <listitem><para>
  5012. <emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  5013. Called to do the actual content population for a
  5014. partition.
  5015. In other words, the method prepares the final
  5016. partition image that is incorporated into the
  5017. disk image.
  5018. </para></listitem>
  5019. <listitem><para>
  5020. <emphasis><filename>do_configure_partition()</filename>:</emphasis>
  5021. Called before
  5022. <filename>do_prepare_partition()</filename>.
  5023. This method is typically used to create custom
  5024. configuration files for a partition (e.g. syslinux
  5025. or grub configuration files).
  5026. </para></listitem>
  5027. <listitem><para>
  5028. <emphasis><filename>do_install_disk()</filename>:</emphasis>
  5029. Called after all partitions have been prepared and
  5030. assembled into a disk image.
  5031. This method provides a hook to allow finalization
  5032. of a disk image, (e.g. writing an MBR).
  5033. </para></listitem>
  5034. <listitem><para>
  5035. <emphasis><filename>do_stage_partition()</filename>:</emphasis>
  5036. Special content-staging hook called before
  5037. <filename>do_prepare_partition()</filename>.
  5038. This method is normally empty.</para>
  5039. <para>Typically, a partition just uses the passed-in
  5040. parameters (e.g. the unmodified value of
  5041. <filename>bootimg_dir</filename>).
  5042. However, in some cases things might need to be
  5043. more tailored.
  5044. As an example, certain files might additionally
  5045. need to be taken from
  5046. <filename>bootimg_dir + /boot</filename>.
  5047. This hook allows those files to be staged in a
  5048. customized fashion.
  5049. <note>
  5050. <filename>get_bitbake_var()</filename>
  5051. allows you to access non-standard variables
  5052. that you might want to use for this.
  5053. </note>
  5054. </para></listitem>
  5055. </itemizedlist>
  5056. </para>
  5057. <para>
  5058. This scheme is extensible.
  5059. Adding more hooks is a simple matter of adding more
  5060. plug-in methods to <filename>SourcePlugin</filename> and
  5061. derived classes.
  5062. The code that then needs to call the plug-in methods uses
  5063. <filename>plugin.get_source_plugin_methods()</filename>
  5064. to find the method or methods needed by the call.
  5065. Retrieval of those methods is accomplished
  5066. by filling up a dict with keys
  5067. containing the method names of interest.
  5068. On success, these will be filled in with the actual
  5069. methods.
  5070. Please see the Wic
  5071. implementation for examples and details.
  5072. </para>
  5073. </section>
  5074. <section id='openembedded-kickstart-wks-reference'>
  5075. <title>OpenEmbedded Kickstart (<filename>.wks</filename>) Reference</title>
  5076. <para>
  5077. The current Wic implementation supports
  5078. only the basic kickstart partitioning commands:
  5079. <filename>partition</filename> (or <filename>part</filename>
  5080. for short) and <filename>bootloader</filename>.
  5081. <note>
  5082. Future updates will implement more commands and options.
  5083. If you use anything that is not specifically
  5084. supported, results can be unpredictable.
  5085. </note>
  5086. </para>
  5087. <para>
  5088. The following is a list of the commands, their syntax,
  5089. and meanings.
  5090. The commands are based on the Fedora
  5091. kickstart versions but with modifications to
  5092. reflect Wic capabilities.
  5093. You can see the original documentation for those commands
  5094. at the following links:
  5095. <itemizedlist>
  5096. <listitem><para>
  5097. <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition'>http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition</ulink>
  5098. </para></listitem>
  5099. <listitem><para>
  5100. <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader'>http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader</ulink>
  5101. </para></listitem>
  5102. </itemizedlist>
  5103. </para>
  5104. <section id='command-part-or-partition'>
  5105. <title>Command: part or partition</title>
  5106. <para>
  5107. Either of these commands create a partition on the system
  5108. and use the following syntax:
  5109. <literallayout class='monospaced'>
  5110. part [<replaceable>mntpoint</replaceable>]
  5111. partition [<replaceable>mntpoint</replaceable>]
  5112. </literallayout>
  5113. If you do not provide
  5114. <replaceable>mntpoint</replaceable>, Wic creates a
  5115. partition but does not mount it.
  5116. </para>
  5117. <para>
  5118. The
  5119. <filename><replaceable>mntpoint</replaceable></filename>
  5120. is where the partition will be mounted and must be of
  5121. one of the following forms:
  5122. <itemizedlist>
  5123. <listitem><para>
  5124. <filename>/<replaceable>path</replaceable></filename>:
  5125. For example, "/", "/usr", or "/home"
  5126. </para></listitem>
  5127. <listitem><para>
  5128. <filename>swap</filename>:
  5129. The created partition is used as swap space.
  5130. </para></listitem>
  5131. </itemizedlist>
  5132. </para>
  5133. <para>
  5134. Specifying a <replaceable>mntpoint</replaceable> causes
  5135. the partition to automatically be mounted.
  5136. Wic achieves this by adding entries to the filesystem
  5137. table (fstab) during image generation.
  5138. In order for wic to generate a valid fstab, you must
  5139. also provide one of the <filename>--ondrive</filename>,
  5140. <filename>--ondisk</filename>, or
  5141. <filename>--use-uuid</filename> partition options as
  5142. part of the command.
  5143. Here is an example using "/" as the mountpoint.
  5144. The command uses "--ondisk" to force the partition onto
  5145. the <filename>sdb</filename> disk:
  5146. <literallayout class='monospaced'>
  5147. part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024
  5148. </literallayout>
  5149. </para>
  5150. <para>
  5151. Here is a list that describes other supported options
  5152. you can use with the <filename>part</filename> and
  5153. <filename>partition</filename> commands:
  5154. <itemizedlist>
  5155. <listitem><para>
  5156. <emphasis><filename>--size</filename>:</emphasis>
  5157. The minimum partition size in MBytes.
  5158. Specify an integer value such as 500.
  5159. Do not append the number with "MB".
  5160. You do not need this option if you use
  5161. <filename>--source</filename>.
  5162. </para></listitem>
  5163. <listitem><para>
  5164. <emphasis><filename>--source</filename>:</emphasis>
  5165. This option is a
  5166. Wic-specific option that
  5167. names the source of the data that populates
  5168. the partition.
  5169. The most common value for this option is
  5170. "rootfs", but you can use any value that maps to
  5171. a valid source plug-in.
  5172. For information on the source plug-ins, see the
  5173. "<link linkend='openembedded-kickstart-plugins'>Plug-ins</link>"
  5174. section.</para>
  5175. <para>If you use
  5176. <filename>--source rootfs</filename>,
  5177. Wic creates a partition as
  5178. large as needed and to fill it with the contents
  5179. of the root filesystem pointed to by the
  5180. <filename>-r</filename> command-line option
  5181. or the equivalent rootfs derived from the
  5182. <filename>-e</filename> command-line
  5183. option.
  5184. The filesystem type used to create the
  5185. partition is driven by the value of the
  5186. <filename>--fstype</filename> option
  5187. specified for the partition.
  5188. See the entry on
  5189. <filename>--fstype</filename> that
  5190. follows for more information.
  5191. </para>
  5192. <para>If you use
  5193. <filename>--source <replaceable>plugin-name</replaceable></filename>,
  5194. Wic creates a partition as
  5195. large as needed and fills it with the contents
  5196. of the partition that is generated by the
  5197. specified plug-in name using the data pointed
  5198. to by the <filename>-r</filename> command-line
  5199. option or the equivalent rootfs derived from the
  5200. <filename>-e</filename> command-line
  5201. option.
  5202. Exactly what those contents and filesystem type
  5203. end up being are dependent on the given plug-in
  5204. implementation.
  5205. </para>
  5206. <para>If you do not use the
  5207. <filename>--source</filename> option, the
  5208. <filename>wic</filename> command creates an
  5209. empty partition.
  5210. Consequently, you must use the
  5211. <filename>--size</filename> option to specify
  5212. the size of the empty partition.
  5213. </para></listitem>
  5214. <listitem><para>
  5215. <emphasis><filename>--ondisk</filename> or <filename>--ondrive</filename>:</emphasis>
  5216. Forces the partition to be created on a
  5217. particular disk.
  5218. </para></listitem>
  5219. <listitem><para>
  5220. <emphasis><filename>--fstype</filename>:</emphasis>
  5221. Sets the file system type for the partition.
  5222. Valid values are:
  5223. <itemizedlist>
  5224. <listitem><para><filename>ext4</filename>
  5225. </para></listitem>
  5226. <listitem><para><filename>ext3</filename>
  5227. </para></listitem>
  5228. <listitem><para><filename>ext2</filename>
  5229. </para></listitem>
  5230. <listitem><para><filename>btrfs</filename>
  5231. </para></listitem>
  5232. <listitem><para><filename>squashfs</filename>
  5233. </para></listitem>
  5234. <listitem><para><filename>swap</filename>
  5235. </para></listitem>
  5236. </itemizedlist>
  5237. </para></listitem>
  5238. <listitem><para>
  5239. <emphasis><filename>--fsoptions</filename>:</emphasis>
  5240. Specifies a free-form string of options to be
  5241. used when mounting the filesystem.
  5242. This string will be copied into the
  5243. <filename>/etc/fstab</filename> file of the
  5244. installed system and should be enclosed in
  5245. quotes.
  5246. If not specified, the default string
  5247. is "defaults".
  5248. </para></listitem>
  5249. <listitem><para>
  5250. <emphasis><filename>--label label</filename>:</emphasis>
  5251. Specifies the label to give to the filesystem to
  5252. be made on the partition.
  5253. If the given label is already in use by another
  5254. filesystem, a new label is created for the
  5255. partition.
  5256. </para></listitem>
  5257. <listitem><para>
  5258. <emphasis><filename>--active</filename>:</emphasis>
  5259. Marks the partition as active.
  5260. </para></listitem>
  5261. <listitem><para>
  5262. <emphasis><filename>--align (in KBytes)</filename>:</emphasis>
  5263. This option is a
  5264. Wic-specific option that
  5265. says to start a partition on an
  5266. <replaceable>x</replaceable> KBytes
  5267. boundary.</para></listitem>
  5268. <listitem><para>
  5269. <emphasis><filename>--no-table</filename>:</emphasis>
  5270. This option is a
  5271. Wic-specific option.
  5272. Using the option reserves space for the
  5273. partition and causes it to become populated.
  5274. However, the partition is not added to the
  5275. partition table.
  5276. </para></listitem>
  5277. <listitem><para>
  5278. <emphasis><filename>--extra-space</filename>:</emphasis>
  5279. This option is a
  5280. Wic-specific option that
  5281. adds extra space after the space filled by the
  5282. content of the partition.
  5283. The final size can go beyond the size specified
  5284. by the <filename>--size</filename> option.
  5285. The default value is 10 Mbytes.
  5286. </para></listitem>
  5287. <listitem><para>
  5288. <emphasis><filename>--overhead-factor</filename>:</emphasis>
  5289. This option is a
  5290. Wic-specific option that
  5291. multiplies the size of the partition by the
  5292. option's value.
  5293. You must supply a value greater than or equal to
  5294. "1".
  5295. The default value is "1.3".
  5296. </para></listitem>
  5297. <listitem><para>
  5298. <emphasis><filename>--part-type</filename>:</emphasis>
  5299. This option is a
  5300. Wic-specific option that
  5301. specifies the partition type globally
  5302. unique identifier (GUID) for GPT partitions.
  5303. You can find the list of partition type GUIDs
  5304. at
  5305. <ulink url='http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs'></ulink>.
  5306. </para></listitem>
  5307. <listitem><para>
  5308. <emphasis><filename>--use-uuid</filename>:</emphasis>
  5309. This option is a
  5310. Wic-specific option that
  5311. causes Wic to generate a
  5312. random GUID for the partition.
  5313. The generated identifier is used in the
  5314. bootloader configuration to specify the root
  5315. partition.
  5316. </para></listitem>
  5317. <listitem><para>
  5318. <emphasis><filename>--uuid</filename>:</emphasis>
  5319. This option is a
  5320. Wic-specific
  5321. option that specifies the partition UUID.
  5322. </para></listitem>
  5323. </itemizedlist>
  5324. </para>
  5325. </section>
  5326. <section id='command-bootloader'>
  5327. <title>Command: bootloader</title>
  5328. <para>
  5329. This command specifies how the bootloader should be
  5330. configured and supports the following options:
  5331. <note>
  5332. Bootloader functionality and boot partitions are
  5333. implemented by the various
  5334. <filename>--source</filename>
  5335. plug-ins that implement bootloader functionality.
  5336. The bootloader command essentially provides a
  5337. means of modifying bootloader configuration.
  5338. </note>
  5339. <itemizedlist>
  5340. <listitem><para>
  5341. <emphasis><filename>--timeout</filename>:</emphasis>
  5342. Specifies the number of seconds before the
  5343. bootloader times out and boots the default
  5344. option.
  5345. </para></listitem>
  5346. <listitem><para>
  5347. <emphasis><filename>--append</filename>:</emphasis>
  5348. Specifies kernel parameters.
  5349. These parameters will be added to the syslinux
  5350. <filename>APPEND</filename> or
  5351. <filename>grub</filename> kernel command line.
  5352. </para></listitem>
  5353. <listitem><para>
  5354. <emphasis><filename>--configfile</filename>:</emphasis>
  5355. Specifies a user-defined configuration file for
  5356. the bootloader.
  5357. You can provide a full pathname for the file or
  5358. a file that exists in the
  5359. <filename>canned-wks</filename> folder.
  5360. This option overrides all other bootloader
  5361. options.
  5362. </para></listitem>
  5363. </itemizedlist>
  5364. </para>
  5365. </section>
  5366. </section>
  5367. </section>
  5368. </section>
  5369. <section id='building-an-initramfs-image'>
  5370. <title>Building an Initial RAM Filesystem (initramfs) Image</title>
  5371. <para>
  5372. initramfs is the successor of Initial RAM Disk (initrd).
  5373. It is a "copy in and out" (cpio) archive of the initial file system
  5374. that gets loaded into memory during the Linux startup process.
  5375. Because Linux uses the contents of the archive during
  5376. initialization, the initramfs needs to contain all of the device
  5377. drivers and tools needed to mount the final root filesystem.
  5378. </para>
  5379. <para>
  5380. To build an initramfs image and bundle it into the kernel, set the
  5381. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  5382. variable in your <filename>local.conf</filename> file, and set the
  5383. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink>
  5384. variable in your <filename>machine.conf</filename> file:
  5385. <literallayout class='monospaced'>
  5386. INITRAMFS_IMAGE_BUNDLE = "1"
  5387. INITRAMFS_IMAGE = "<replaceable>image_recipe_name</replaceable>"
  5388. </literallayout>
  5389. Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename>
  5390. flag causes the initramfs created by the recipe and defined by
  5391. <filename>INITRAMFS_IMAGE</filename> to be unpacked into the
  5392. <filename>${B}/usr/</filename> directory.
  5393. The unpacked initramfs is then passed to the kernel's
  5394. <filename>Makefile</filename> using the
  5395. <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink>
  5396. variable, allowing initramfs to be built in to the kernel
  5397. normally.
  5398. <note>
  5399. The preferred method is to use the
  5400. <filename>INITRAMFS_IMAGE</filename> variable rather than the
  5401. <filename>INITRAMFS_TASK</filename> variable.
  5402. Setting <filename>INITRAMFS_TASK</filename> is supported for
  5403. backward compatibility.
  5404. However, use of this variable has circular dependency
  5405. problems.
  5406. See the
  5407. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  5408. variable for additional information on these dependency
  5409. problems.
  5410. </note>
  5411. </para>
  5412. <para>
  5413. The recipe that <filename>INITRAMFS_IMAGE</filename>
  5414. points to must produce a <filename>.cpio.gz</filename>,
  5415. <filename>.cpio.tar</filename>, <filename>.cpio.lz4</filename>,
  5416. <filename>.cpio.lzma</filename>, or
  5417. <filename>.cpio.xz</filename> file.
  5418. You can ensure you produce one of these <filename>.cpio.*</filename>
  5419. files by setting the
  5420. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_FSTYPES'><filename>INITRAMFS_FSTYPES</filename></ulink>
  5421. variable in your configuration file to one or more of the above
  5422. file types.
  5423. <note>
  5424. If you add items to the initramfs image by way of its recipe,
  5425. you should use
  5426. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>
  5427. rather than
  5428. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>.
  5429. <filename>PACKAGE_INSTALL</filename> gives more direct control
  5430. of what is added to the image as compared to the defaults you
  5431. might not necessarily want that are set by the
  5432. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink>
  5433. or
  5434. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink>
  5435. classes.
  5436. </note>
  5437. </para>
  5438. </section>
  5439. <section id='configuring-the-kernel'>
  5440. <title>Configuring the Kernel</title>
  5441. <para>
  5442. Configuring the Yocto Project kernel consists of making sure the
  5443. <filename>.config</filename> file has all the right information
  5444. in it for the image you are building.
  5445. You can use the <filename>menuconfig</filename> tool and
  5446. configuration fragments to make sure your
  5447. <filename>.config</filename> file is just how you need it.
  5448. You can also save known configurations in a
  5449. <filename>defconfig</filename> file that the build system can use
  5450. for kernel configuration.
  5451. </para>
  5452. <para>
  5453. This section describes how to use <filename>menuconfig</filename>,
  5454. create and use configuration fragments, and how to interactively
  5455. modify your <filename>.config</filename> file to create the
  5456. leanest kernel configuration file possible.
  5457. </para>
  5458. <para>
  5459. For more information on kernel configuration, see the
  5460. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  5461. section in the Yocto Project Linux Kernel Development Manual.
  5462. </para>
  5463. <section id='using-menuconfig'>
  5464. <title>Using&nbsp;&nbsp;<filename>menuconfig</filename></title>
  5465. <para>
  5466. The easiest way to define kernel configurations is to set them through the
  5467. <filename>menuconfig</filename> tool.
  5468. This tool provides an interactive method with which
  5469. to set kernel configurations.
  5470. For general information on <filename>menuconfig</filename>, see
  5471. <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>.
  5472. </para>
  5473. <para>
  5474. To use the <filename>menuconfig</filename> tool in the Yocto Project development
  5475. environment, you must launch it using BitBake.
  5476. Thus, the environment must be set up using the
  5477. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  5478. or
  5479. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>
  5480. script found in the
  5481. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  5482. You must also be sure of the state of your build in the
  5483. <link linkend='source-directory'>Source Directory</link>.
  5484. The following commands run <filename>menuconfig</filename>
  5485. assuming the Source Directory's top-level folder is
  5486. <filename>~/poky</filename>:
  5487. <literallayout class='monospaced'>
  5488. $ cd poky
  5489. $ source oe-init-build-env
  5490. $ bitbake linux-yocto -c kernel_configme -f
  5491. $ bitbake linux-yocto -c menuconfig
  5492. </literallayout>
  5493. Once <filename>menuconfig</filename> comes up, its standard
  5494. interface allows you to interactively examine and configure
  5495. all the kernel configuration parameters.
  5496. After making your changes, simply exit the tool and save your
  5497. changes to create an updated version of the
  5498. <filename>.config</filename> configuration file.
  5499. </para>
  5500. <para>
  5501. Consider an example that configures the <filename>linux-yocto-3.14</filename>
  5502. kernel.
  5503. The OpenEmbedded build system recognizes this kernel as
  5504. <filename>linux-yocto</filename>.
  5505. Thus, the following commands from the shell in which you previously sourced the
  5506. environment initialization script cleans the shared state cache and the
  5507. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  5508. directory and then runs <filename>menuconfig</filename>:
  5509. <literallayout class='monospaced'>
  5510. $ bitbake linux-yocto -c menuconfig
  5511. </literallayout>
  5512. </para>
  5513. <para>
  5514. Once <filename>menuconfig</filename> launches, use the interface
  5515. to navigate through the selections to find the configuration settings in
  5516. which you are interested.
  5517. For example, consider the <filename>CONFIG_SMP</filename> configuration setting.
  5518. You can find it at <filename>Processor Type and Features</filename> under
  5519. the configuration selection <filename>Symmetric Multi-processing Support</filename>.
  5520. After highlighting the selection, use the arrow keys to select or deselect
  5521. the setting.
  5522. When you are finished with all your selections, exit out and save them.
  5523. </para>
  5524. <para>
  5525. Saving the selections updates the <filename>.config</filename> configuration file.
  5526. This is the file that the OpenEmbedded build system uses to configure the
  5527. kernel during the build.
  5528. You can find and examine this file in the Build Directory in
  5529. <filename>tmp/work/</filename>.
  5530. The actual <filename>.config</filename> is located in the area where the
  5531. specific kernel is built.
  5532. For example, if you were building a Linux Yocto kernel based on the
  5533. Linux 3.14 kernel and you were building a QEMU image targeted for
  5534. <filename>x86</filename> architecture, the
  5535. <filename>.config</filename> file would be located here:
  5536. <literallayout class='monospaced'>
  5537. poky/build/tmp/work/qemux86-poky-linux/linux-yocto-3.14.11+git1+84f...
  5538. ...656ed30-r1/linux-qemux86-standard-build
  5539. </literallayout>
  5540. <note>
  5541. The previous example directory is artificially split and many of the characters
  5542. in the actual filename are omitted in order to make it more readable.
  5543. Also, depending on the kernel you are using, the exact pathname
  5544. for <filename>linux-yocto-3.14...</filename> might differ.
  5545. </note>
  5546. </para>
  5547. <para>
  5548. Within the <filename>.config</filename> file, you can see the kernel settings.
  5549. For example, the following entry shows that symmetric multi-processor support
  5550. is not set:
  5551. <literallayout class='monospaced'>
  5552. # CONFIG_SMP is not set
  5553. </literallayout>
  5554. </para>
  5555. <para>
  5556. A good method to isolate changed configurations is to use a combination of the
  5557. <filename>menuconfig</filename> tool and simple shell commands.
  5558. Before changing configurations with <filename>menuconfig</filename>, copy the
  5559. existing <filename>.config</filename> and rename it to something else,
  5560. use <filename>menuconfig</filename> to make
  5561. as many changes as you want and save them, then compare the renamed configuration
  5562. file against the newly created file.
  5563. You can use the resulting differences as your base to create configuration fragments
  5564. to permanently save in your kernel layer.
  5565. <note>
  5566. Be sure to make a copy of the <filename>.config</filename> and don't just
  5567. rename it.
  5568. The build system needs an existing <filename>.config</filename>
  5569. from which to work.
  5570. </note>
  5571. </para>
  5572. </section>
  5573. <section id='creating-a-defconfig-file'>
  5574. <title>Creating a&nbsp;&nbsp;<filename>defconfig</filename> File</title>
  5575. <para>
  5576. A <filename>defconfig</filename> file is simply a
  5577. <filename>.config</filename> renamed to "defconfig".
  5578. You can use a <filename>defconfig</filename> file
  5579. to retain a known set of kernel configurations from which the
  5580. OpenEmbedded build system can draw to create the final
  5581. <filename>.config</filename> file.
  5582. <note>
  5583. Out-of-the-box, the Yocto Project never ships a
  5584. <filename>defconfig</filename> or
  5585. <filename>.config</filename> file.
  5586. The OpenEmbedded build system creates the final
  5587. <filename>.config</filename> file used to configure the
  5588. kernel.
  5589. </note>
  5590. </para>
  5591. <para>
  5592. To create a <filename>defconfig</filename>, start with a
  5593. complete, working Linux kernel <filename>.config</filename>
  5594. file.
  5595. Copy that file to the appropriate
  5596. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  5597. directory in your layer's
  5598. <filename>recipes-kernel/linux</filename> directory, and rename
  5599. the copied file to "defconfig".
  5600. Then, add the following lines to the linux-yocto
  5601. <filename>.bbappend</filename> file in your layer:
  5602. <literallayout class='monospaced'>
  5603. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  5604. SRC_URI += "file://defconfig"
  5605. </literallayout>
  5606. The
  5607. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  5608. tells the build system how to search for the file, while the
  5609. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  5610. extends the
  5611. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  5612. variable (search directories) to include the
  5613. <filename>${PN}</filename> directory you created to hold the
  5614. configuration changes.
  5615. <note>
  5616. The build system applies the configurations from the
  5617. <filename>defconfig</filename> file before applying any
  5618. subsequent configuration fragments.
  5619. The final kernel configuration is a combination of the
  5620. configurations in the <filename>defconfig</filename>
  5621. file and any configuration fragments you provide.
  5622. You need to realize that if you have any configuration
  5623. fragments, the build system applies these on top of and
  5624. after applying the existing defconfig file configurations.
  5625. </note>
  5626. For more information on configuring the kernel, see the
  5627. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  5628. and
  5629. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>"
  5630. sections, both in the Yocto Project Linux Kernel Development
  5631. Manual.
  5632. </para>
  5633. </section>
  5634. <section id='creating-config-fragments'>
  5635. <title>Creating Configuration Fragments</title>
  5636. <para>
  5637. Configuration fragments are simply kernel options that appear in a file
  5638. placed where the OpenEmbedded build system can find and apply them.
  5639. Syntactically, the configuration statement is identical to what would appear
  5640. in the <filename>.config</filename> file, which is in the
  5641. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  5642. <literallayout class='monospaced'>
  5643. tmp/work/<replaceable>arch</replaceable>-poky-linux/linux-yocto-<replaceable>release_specific_string</replaceable>/linux-<replaceable>arch</replaceable>-<replaceable>build_type</replaceable>
  5644. </literallayout>
  5645. </para>
  5646. <para>
  5647. It is simple to create a configuration fragment.
  5648. For example, issuing the following from the shell creates a configuration fragment
  5649. file named <filename>my_smp.cfg</filename> that enables multi-processor support
  5650. within the kernel:
  5651. <literallayout class='monospaced'>
  5652. $ echo "CONFIG_SMP=y" >> my_smp.cfg
  5653. </literallayout>
  5654. <note>
  5655. All configuration fragment files must use the
  5656. <filename>.cfg</filename> extension in order for the
  5657. OpenEmbedded build system to recognize them as a
  5658. configuration fragment.
  5659. </note>
  5660. </para>
  5661. <para>
  5662. Where do you put your configuration fragment files?
  5663. You can place these files in the same area pointed to by
  5664. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  5665. The OpenEmbedded build system picks up the configuration and
  5666. adds it to the kernel's configuration.
  5667. For example, suppose you had a set of configuration options
  5668. in a file called <filename>myconfig.cfg</filename>.
  5669. If you put that file inside a directory named
  5670. <filename>linux-yocto</filename> that resides in the same
  5671. directory as the kernel's append file and then add a
  5672. <filename>SRC_URI</filename> statement such as the following
  5673. to the kernel's append file, those configuration options
  5674. will be picked up and applied when the kernel is built.
  5675. <literallayout class='monospaced'>
  5676. SRC_URI += "file://myconfig.cfg"
  5677. </literallayout>
  5678. </para>
  5679. <para>
  5680. As mentioned earlier, you can group related configurations into multiple files and
  5681. name them all in the <filename>SRC_URI</filename> statement as well.
  5682. For example, you could group separate configurations specifically for Ethernet and graphics
  5683. into their own files and add those by using a <filename>SRC_URI</filename> statement like the
  5684. following in your append file:
  5685. <literallayout class='monospaced'>
  5686. SRC_URI += "file://myconfig.cfg \
  5687. file://eth.cfg \
  5688. file://gfx.cfg"
  5689. </literallayout>
  5690. </para>
  5691. </section>
  5692. <section id='fine-tuning-the-kernel-configuration-file'>
  5693. <title>Fine-Tuning the Kernel Configuration File</title>
  5694. <para>
  5695. You can make sure the <filename>.config</filename> file is as lean or efficient as
  5696. possible by reading the output of the kernel configuration fragment audit,
  5697. noting any issues, making changes to correct the issues, and then repeating.
  5698. </para>
  5699. <para>
  5700. As part of the kernel build process, the
  5701. <filename>do_kernel_configcheck</filename> task runs.
  5702. This task validates the kernel configuration by checking the final
  5703. <filename>.config</filename> file against the input files.
  5704. During the check, the task produces warning messages for the following
  5705. issues:
  5706. <itemizedlist>
  5707. <listitem><para>Requested options that did not make the final
  5708. <filename>.config</filename> file.</para></listitem>
  5709. <listitem><para>Configuration items that appear twice in the same
  5710. configuration fragment.</para></listitem>
  5711. <listitem><para>Configuration items tagged as "required" that were overridden.
  5712. </para></listitem>
  5713. <listitem><para>A board overrides a non-board specific option.</para></listitem>
  5714. <listitem><para>Listed options not valid for the kernel being processed.
  5715. In other words, the option does not appear anywhere.</para></listitem>
  5716. </itemizedlist>
  5717. <note>
  5718. The <filename>do_kernel_configcheck</filename> task can
  5719. also optionally report if an option is overridden during
  5720. processing.
  5721. </note>
  5722. </para>
  5723. <para>
  5724. For each output warning, a message points to the file
  5725. that contains a list of the options and a pointer to the
  5726. configuration fragment that defines them.
  5727. Collectively, the files are the key to streamlining the
  5728. configuration.
  5729. </para>
  5730. <para>
  5731. To streamline the configuration, do the following:
  5732. <orderedlist>
  5733. <listitem><para>Start with a full configuration that you
  5734. know works - it builds and boots successfully.
  5735. This configuration file will be your baseline.
  5736. </para></listitem>
  5737. <listitem><para>Separately run the
  5738. <filename>do_kernel_configme</filename> and
  5739. <filename>do_kernel_configcheck</filename> tasks.
  5740. </para></listitem>
  5741. <listitem><para>Take the resulting list of files from the
  5742. <filename>do_kernel_configcheck</filename> task
  5743. warnings and do the following:
  5744. <itemizedlist>
  5745. <listitem><para>
  5746. Drop values that are redefined in the fragment
  5747. but do not change the final
  5748. <filename>.config</filename> file.
  5749. </para></listitem>
  5750. <listitem><para>
  5751. Analyze and potentially drop values from the
  5752. <filename>.config</filename> file that override
  5753. required configurations.
  5754. </para></listitem>
  5755. <listitem><para>
  5756. Analyze and potentially remove non-board
  5757. specific options.
  5758. </para></listitem>
  5759. <listitem><para>
  5760. Remove repeated and invalid options.
  5761. </para></listitem>
  5762. </itemizedlist></para></listitem>
  5763. <listitem><para>
  5764. After you have worked through the output of the kernel
  5765. configuration audit, you can re-run the
  5766. <filename>do_kernel_configme</filename> and
  5767. <filename>do_kernel_configcheck</filename> tasks to
  5768. see the results of your changes.
  5769. If you have more issues, you can deal with them as
  5770. described in the previous step.
  5771. </para></listitem>
  5772. </orderedlist>
  5773. </para>
  5774. <para>
  5775. Iteratively working through steps two through four eventually yields
  5776. a minimal, streamlined configuration file.
  5777. Once you have the best <filename>.config</filename>, you can build the Linux
  5778. Yocto kernel.
  5779. </para>
  5780. </section>
  5781. <section id='determining-hardware-and-non-hardware-features-for-the-kernel-configuration-audit-phase'>
  5782. <title>Determining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase</title>
  5783. <para>
  5784. This section describes part of the kernel configuration audit
  5785. phase that most developers can ignore.
  5786. During this part of the audit phase, the contents of the final
  5787. <filename>.config</filename> file are compared against the
  5788. fragments specified by the system.
  5789. These fragments can be system fragments, distro fragments,
  5790. or user specified configuration elements.
  5791. Regardless of their origin, the OpenEmbedded build system
  5792. warns the user if a specific option is not included in the
  5793. final kernel configuration.
  5794. </para>
  5795. <para>
  5796. In order to not overwhelm the user with configuration warnings,
  5797. by default the system only reports on missing "hardware"
  5798. options because a missing hardware option could mean a boot
  5799. failure or that important hardware is not available.
  5800. </para>
  5801. <para>
  5802. To determine whether or not a given option is "hardware" or
  5803. "non-hardware", the kernel Metadata contains files that
  5804. classify individual or groups of options as either hardware
  5805. or non-hardware.
  5806. To better show this, consider a situation where the
  5807. Yocto Project kernel cache contains the following files:
  5808. <literallayout class='monospaced'>
  5809. kernel-cache/features/drm-psb/hardware.cfg
  5810. kernel-cache/features/kgdb/hardware.cfg
  5811. kernel-cache/ktypes/base/hardware.cfg
  5812. kernel-cache/bsp/mti-malta32/hardware.cfg
  5813. kernel-cache/bsp/fsl-mpc8315e-rdb/hardware.cfg
  5814. kernel-cache/bsp/qemu-ppc32/hardware.cfg
  5815. kernel-cache/bsp/qemuarma9/hardware.cfg
  5816. kernel-cache/bsp/mti-malta64/hardware.cfg
  5817. kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg
  5818. kernel-cache/bsp/common-pc/hardware.cfg
  5819. kernel-cache/bsp/common-pc-64/hardware.cfg
  5820. kernel-cache/features/rfkill/non-hardware.cfg
  5821. kernel-cache/ktypes/base/non-hardware.cfg
  5822. kernel-cache/features/aufs/non-hardware.kcf
  5823. kernel-cache/features/ocf/non-hardware.kcf
  5824. kernel-cache/ktypes/base/non-hardware.kcf
  5825. kernel-cache/ktypes/base/hardware.kcf
  5826. kernel-cache/bsp/qemu-ppc32/hardware.kcf
  5827. </literallayout>
  5828. The following list provides explanations for the various
  5829. files:
  5830. <itemizedlist>
  5831. <listitem><para><filename>hardware.kcf</filename>:
  5832. Specifies a list of kernel Kconfig files that contain
  5833. hardware options only.
  5834. </para></listitem>
  5835. <listitem><para><filename>non-hardware.kcf</filename>:
  5836. Specifies a list of kernel Kconfig files that contain
  5837. non-hardware options only.
  5838. </para></listitem>
  5839. <listitem><para><filename>hardware.cfg</filename>:
  5840. Specifies a list of kernel
  5841. <filename>CONFIG_</filename> options that are hardware,
  5842. regardless of whether or not they are within a Kconfig
  5843. file specified by a hardware or non-hardware
  5844. Kconfig file (i.e. <filename>hardware.kcf</filename> or
  5845. <filename>non-hardware.kcf</filename>).
  5846. </para></listitem>
  5847. <listitem><para><filename>non-hardware.cfg</filename>:
  5848. Specifies a list of kernel
  5849. <filename>CONFIG_</filename> options that are
  5850. not hardware, regardless of whether or not they are
  5851. within a Kconfig file specified by a hardware or
  5852. non-hardware Kconfig file (i.e.
  5853. <filename>hardware.kcf</filename> or
  5854. <filename>non-hardware.kcf</filename>).
  5855. </para></listitem>
  5856. </itemizedlist>
  5857. Here is a specific example using the
  5858. <filename>kernel-cache/bsp/mti-malta32/hardware.cfg</filename>:
  5859. <literallayout class='monospaced'>
  5860. CONFIG_SERIAL_8250
  5861. CONFIG_SERIAL_8250_CONSOLE
  5862. CONFIG_SERIAL_8250_NR_UARTS
  5863. CONFIG_SERIAL_8250_PCI
  5864. CONFIG_SERIAL_CORE
  5865. CONFIG_SERIAL_CORE_CONSOLE
  5866. CONFIG_VGA_ARB
  5867. </literallayout>
  5868. The kernel configuration audit automatically detects these
  5869. files (hence the names must be exactly the ones discussed here),
  5870. and uses them as inputs when generating warnings about the
  5871. final <filename>.config</filename> file.
  5872. </para>
  5873. <para>
  5874. A user-specified kernel Metadata repository, or recipe space
  5875. feature, can use these same files to classify options that are
  5876. found within its <filename>.cfg</filename> files as hardware
  5877. or non-hardware, to prevent the OpenEmbedded build system from
  5878. producing an error or warning when an option is not in the
  5879. final <filename>.config</filename> file.
  5880. </para>
  5881. </section>
  5882. </section>
  5883. <section id="patching-the-kernel">
  5884. <title>Patching the Kernel</title>
  5885. <para>
  5886. Patching the kernel involves changing or adding configurations to an existing kernel,
  5887. changing or adding recipes to the kernel that are needed to support specific hardware features,
  5888. or even altering the source code itself.
  5889. <note>
  5890. You can use the <filename>yocto-kernel</filename> script
  5891. found in the <link linkend='source-directory'>Source Directory</link>
  5892. under <filename>scripts</filename> to manage kernel patches and configuration.
  5893. 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>"
  5894. section in the Yocto Project Board Support Packages (BSP) Developer's Guide for
  5895. more information.</note>
  5896. </para>
  5897. <para>
  5898. This example creates a simple patch by adding some QEMU emulator console
  5899. output at boot time through <filename>printk</filename> statements in the kernel's
  5900. <filename>calibrate.c</filename> source code file.
  5901. Applying the patch and booting the modified image causes the added
  5902. messages to appear on the emulator's console.
  5903. </para>
  5904. <para>
  5905. The example assumes a clean build exists for the <filename>qemux86</filename>
  5906. machine in a
  5907. <link linkend='source-directory'>Source Directory</link>
  5908. named <filename>poky</filename>.
  5909. Furthermore, the
  5910. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  5911. is <filename>build</filename> and is located in
  5912. <filename>poky</filename> and the kernel is based on the
  5913. Linux 3.4 kernel.
  5914. </para>
  5915. <para>
  5916. Also, for more information on patching the kernel, see the
  5917. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#applying-patches'>Applying Patches</ulink>"
  5918. section in the Yocto Project Linux Kernel Development Manual.
  5919. </para>
  5920. <section id='create-a-layer-for-your-changes'>
  5921. <title>Create a Layer for your Changes</title>
  5922. <para>
  5923. The first step is to create a layer so you can isolate your
  5924. changes.
  5925. Rather than use the <filename>yocto-layer</filename> script
  5926. to create the layer, this example steps through the process
  5927. by hand.
  5928. If you want information on the script that creates a general
  5929. layer, see the
  5930. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  5931. section.
  5932. </para>
  5933. <para>
  5934. These two commands create a directory you can use for your
  5935. layer:
  5936. <literallayout class='monospaced'>
  5937. $ cd ~/poky
  5938. $ mkdir meta-mylayer
  5939. </literallayout>
  5940. Creating a directory that follows the Yocto Project layer naming
  5941. conventions sets up the layer for your changes.
  5942. The layer is where you place your configuration files, append
  5943. files, and patch files.
  5944. To learn more about creating a layer and filling it with the
  5945. files you need, see the "<link linkend='understanding-and-creating-layers'>Understanding
  5946. and Creating Layers</link>" section.
  5947. </para>
  5948. </section>
  5949. <section id='finding-the-kernel-source-code'>
  5950. <title>Finding the Kernel Source Code</title>
  5951. <para>
  5952. Each time you build a kernel image, the kernel source code is fetched
  5953. and unpacked into the following directory:
  5954. <literallayout class='monospaced'>
  5955. ${S}/linux
  5956. </literallayout>
  5957. See the "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
  5958. section and the
  5959. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> variable
  5960. for more information about where source is kept during a build.
  5961. </para>
  5962. <para>
  5963. For this example, we are going to patch the
  5964. <filename>init/calibrate.c</filename> file
  5965. by adding some simple console <filename>printk</filename> statements that we can
  5966. see when we boot the image using QEMU.
  5967. </para>
  5968. </section>
  5969. <section id='creating-the-patch'>
  5970. <title>Creating the Patch</title>
  5971. <para>
  5972. Two methods exist by which you can create the patch:
  5973. <link linkend='using-devtool-in-your-workflow'><filename>devtool</filename></link> and
  5974. <link linkend='using-a-quilt-workflow'>Quilt</link>.
  5975. For kernel patches, the Git workflow is more appropriate.
  5976. This section assumes the Git workflow and shows the steps specific to
  5977. this example.
  5978. <orderedlist>
  5979. <listitem><para><emphasis>Change the working directory</emphasis>:
  5980. Change to where the kernel source code is before making
  5981. your edits to the <filename>calibrate.c</filename> file:
  5982. <literallayout class='monospaced'>
  5983. $ cd ~/poky/build/tmp/work/qemux86-poky-linux/linux-yocto-${PV}-${PR}/linux
  5984. </literallayout>
  5985. Because you are working in an established Git repository,
  5986. you must be in this directory in order to commit your changes
  5987. and create the patch file.
  5988. <note>The <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> and
  5989. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> variables
  5990. represent the version and revision for the
  5991. <filename>linux-yocto</filename> recipe.
  5992. The <filename>PV</filename> variable includes the Git meta and machine
  5993. hashes, which make the directory name longer than you might
  5994. expect.
  5995. </note></para></listitem>
  5996. <listitem><para><emphasis>Edit the source file</emphasis>:
  5997. Edit the <filename>init/calibrate.c</filename> file to have the
  5998. following changes:
  5999. <literallayout class='monospaced'>
  6000. void calibrate_delay(void)
  6001. {
  6002. unsigned long lpj;
  6003. static bool printed;
  6004. int this_cpu = smp_processor_id();
  6005. printk("*************************************\n");
  6006. printk("* *\n");
  6007. printk("* HELLO YOCTO KERNEL *\n");
  6008. printk("* *\n");
  6009. printk("*************************************\n");
  6010. if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
  6011. .
  6012. .
  6013. .
  6014. </literallayout></para></listitem>
  6015. <listitem><para><emphasis>Stage and commit your changes</emphasis>:
  6016. These Git commands display the modified file, stage it, and then
  6017. commit the file:
  6018. <literallayout class='monospaced'>
  6019. $ git status
  6020. $ git add init/calibrate.c
  6021. $ git commit -m "calibrate: Add printk example"
  6022. </literallayout></para></listitem>
  6023. <listitem><para><emphasis>Generate the patch file</emphasis>:
  6024. This Git command creates the a patch file named
  6025. <filename>0001-calibrate-Add-printk-example.patch</filename>
  6026. in the current directory.
  6027. <literallayout class='monospaced'>
  6028. $ git format-patch -1
  6029. </literallayout>
  6030. </para></listitem>
  6031. </orderedlist>
  6032. </para>
  6033. </section>
  6034. <section id='set-up-your-layer-for-the-build'>
  6035. <title>Set Up Your Layer for the Build</title>
  6036. <para>These steps get your layer set up for the build:
  6037. <orderedlist>
  6038. <listitem><para><emphasis>Create additional structure</emphasis>:
  6039. Create the additional layer structure:
  6040. <literallayout class='monospaced'>
  6041. $ cd ~/poky/meta-mylayer
  6042. $ mkdir conf
  6043. $ mkdir recipes-kernel
  6044. $ mkdir recipes-kernel/linux
  6045. $ mkdir recipes-kernel/linux/linux-yocto
  6046. </literallayout>
  6047. The <filename>conf</filename> directory holds your configuration files, while the
  6048. <filename>recipes-kernel</filename> directory holds your append file and
  6049. your patch file.</para></listitem>
  6050. <listitem><para><emphasis>Create the layer configuration file</emphasis>:
  6051. Move to the <filename>meta-mylayer/conf</filename> directory and create
  6052. the <filename>layer.conf</filename> file as follows:
  6053. <literallayout class='monospaced'>
  6054. # We have a conf and classes directory, add to BBPATH
  6055. BBPATH .= ":${LAYERDIR}"
  6056. # We have recipes-* directories, add to BBFILES
  6057. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  6058. ${LAYERDIR}/recipes-*/*/*.bbappend"
  6059. BBFILE_COLLECTIONS += "mylayer"
  6060. BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"
  6061. BBFILE_PRIORITY_mylayer = "5"
  6062. </literallayout>
  6063. Notice <filename>mylayer</filename> as part of the last three
  6064. statements.</para></listitem>
  6065. <listitem><para><emphasis>Create the kernel recipe append file</emphasis>:
  6066. Move to the <filename>meta-mylayer/recipes-kernel/linux</filename> directory and create
  6067. the <filename>linux-yocto_3.4.bbappend</filename> file as follows:
  6068. <literallayout class='monospaced'>
  6069. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  6070. SRC_URI += "file://0001-calibrate-Add-printk-example.patch"
  6071. </literallayout>
  6072. The <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  6073. and <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  6074. statements enable the OpenEmbedded build system to find the patch file.
  6075. For more information on using append files, see the
  6076. "<link linkend='using-bbappend-files'>Using .bbappend Files</link>"
  6077. section.
  6078. </para></listitem>
  6079. <listitem><para><emphasis>Put the patch file in your layer</emphasis>:
  6080. Move the <filename>0001-calibrate-Add-printk-example.patch</filename> file to
  6081. the <filename>meta-mylayer/recipes-kernel/linux/linux-yocto</filename>
  6082. directory.</para></listitem>
  6083. </orderedlist>
  6084. </para>
  6085. </section>
  6086. <section id='set-up-for-the-build'>
  6087. <title>Set Up for the Build</title>
  6088. <para>
  6089. Do the following to make sure the build parameters are set up for the example.
  6090. Once you set up these build parameters, they do not have to change unless you
  6091. change the target architecture of the machine you are building:
  6092. <itemizedlist>
  6093. <listitem><para><emphasis>Build for the correct target architecture:</emphasis> Your
  6094. selected <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6095. definition within the <filename>local.conf</filename> file in the
  6096. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  6097. specifies the target architecture used when building the Linux kernel.
  6098. By default, <filename>MACHINE</filename> is set to
  6099. <filename>qemux86</filename>, which specifies a 32-bit
  6100. <trademark class='registered'>Intel</trademark> Architecture
  6101. target machine suitable for the QEMU emulator.</para></listitem>
  6102. <listitem><para><emphasis>Identify your <filename>meta-mylayer</filename>
  6103. layer:</emphasis> The
  6104. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  6105. variable in the
  6106. <filename>bblayers.conf</filename> file found in the
  6107. <filename>poky/build/conf</filename> directory needs to have the path to your local
  6108. <filename>meta-mylayer</filename> layer.
  6109. By default, the <filename>BBLAYERS</filename> variable contains paths to
  6110. <filename>meta</filename>, <filename>meta-poky</filename>, and
  6111. <filename>meta-yocto-bsp</filename> in the
  6112. <filename>poky</filename> Git repository.
  6113. Add the path to your <filename>meta-mylayer</filename> location:
  6114. <literallayout class='monospaced'>
  6115. BBLAYERS ?= " \
  6116. $HOME/poky/meta \
  6117. $HOME/poky/meta-poky \
  6118. $HOME/poky/meta-yocto-bsp \
  6119. $HOME/poky/meta-mylayer \
  6120. "
  6121. </literallayout></para></listitem>
  6122. </itemizedlist>
  6123. </para>
  6124. </section>
  6125. <section id='build-the-modified-qemu-kernel-image'>
  6126. <title>Build the Modified QEMU Kernel Image</title>
  6127. <para>
  6128. The following steps build your modified kernel image:
  6129. <orderedlist>
  6130. <listitem><para><emphasis>Be sure your build environment is initialized</emphasis>:
  6131. Your environment should be set up since you previously sourced
  6132. the
  6133. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  6134. script.
  6135. If it is not, source the script again from <filename>poky</filename>.
  6136. <literallayout class='monospaced'>
  6137. $ cd ~/poky
  6138. $ source &OE_INIT_FILE;
  6139. </literallayout>
  6140. </para></listitem>
  6141. <listitem><para><emphasis>Clean up</emphasis>:
  6142. Be sure to clean the shared state out by using BitBake
  6143. to run from within the Build Directory the
  6144. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>
  6145. task as follows:
  6146. <literallayout class='monospaced'>
  6147. $ bitbake -c cleansstate linux-yocto
  6148. </literallayout></para>
  6149. <para>
  6150. <note>
  6151. Never remove any files by hand from the
  6152. <filename>tmp/deploy</filename>
  6153. directory inside the
  6154. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6155. Always use the various BitBake clean tasks to
  6156. clear out previous build artifacts.
  6157. For information on the clean tasks, see the
  6158. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>",
  6159. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>",
  6160. and
  6161. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>"
  6162. sections all in the Yocto Project Reference
  6163. Manual.
  6164. </note>
  6165. </para></listitem>
  6166. <listitem><para><emphasis>Build the image</emphasis>:
  6167. Next, build the kernel image using this command:
  6168. <literallayout class='monospaced'>
  6169. $ bitbake -k linux-yocto
  6170. </literallayout></para></listitem>
  6171. </orderedlist>
  6172. </para>
  6173. </section>
  6174. <section id='boot-the-image-and-verify-your-changes'>
  6175. <title>Boot the Image and Verify Your Changes</title>
  6176. <para>
  6177. These steps boot the image and allow you to see the changes
  6178. <orderedlist>
  6179. <listitem><para><emphasis>Boot the image</emphasis>:
  6180. Boot the modified image in the QEMU emulator
  6181. using this command:
  6182. <literallayout class='monospaced'>
  6183. $ runqemu qemux86
  6184. </literallayout></para></listitem>
  6185. <listitem><para><emphasis>Verify the changes</emphasis>:
  6186. Log into the machine using <filename>root</filename> with no password and then
  6187. use the following shell command to scroll through the console's boot output.
  6188. <literallayout class='monospaced'>
  6189. # dmesg | less
  6190. </literallayout>
  6191. You should see the results of your <filename>printk</filename> statements
  6192. as part of the output.</para></listitem>
  6193. </orderedlist>
  6194. </para>
  6195. </section>
  6196. </section>
  6197. <section id='making-images-more-secure'>
  6198. <title>Making Images More Secure</title>
  6199. <para>
  6200. Security is of increasing concern for embedded devices.
  6201. Consider the issues and problems discussed in just this
  6202. sampling of work found across the Internet:
  6203. <itemizedlist>
  6204. <listitem><para><emphasis>
  6205. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  6206. by Bruce Schneier
  6207. </para></listitem>
  6208. <listitem><para><emphasis>
  6209. "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis>
  6210. by Carna Botnet</para></listitem>
  6211. <listitem><para><emphasis>
  6212. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  6213. by Jake Edge
  6214. </para></listitem>
  6215. </itemizedlist>
  6216. </para>
  6217. <para>
  6218. When securing your image is of concern, there are steps, tools,
  6219. and variables that you can consider to help you reach the
  6220. security goals you need for your particular device.
  6221. Not all situations are identical when it comes to making an
  6222. image secure.
  6223. Consequently, this section provides some guidance and suggestions
  6224. for consideration when you want to make your image more secure.
  6225. <note>
  6226. Because the security requirements and risks are
  6227. different for every type of device, this section cannot
  6228. provide a complete reference on securing your custom OS.
  6229. It is strongly recommended that you also consult other sources
  6230. of information on embedded Linux system hardening and on
  6231. security.
  6232. </note>
  6233. </para>
  6234. <section id='general-considerations'>
  6235. <title>General Considerations</title>
  6236. <para>
  6237. General considerations exist that help you create more
  6238. secure images.
  6239. You should consider the following suggestions to help
  6240. make your device more secure:
  6241. <itemizedlist>
  6242. <listitem><para>
  6243. Scan additional code you are adding to the system
  6244. (e.g. application code) by using static analysis
  6245. tools.
  6246. Look for buffer overflows and other potential
  6247. security problems.
  6248. </para></listitem>
  6249. <listitem><para>
  6250. Pay particular attention to the security for
  6251. any web-based administration interface.
  6252. </para>
  6253. <para>Web interfaces typically need to perform
  6254. administrative functions and tend to need to run with
  6255. elevated privileges.
  6256. Thus, the consequences resulting from the interface's
  6257. security becoming compromised can be serious.
  6258. Look for common web vulnerabilities such as
  6259. cross-site-scripting (XSS), unvalidated inputs,
  6260. and so forth.</para>
  6261. <para>As with system passwords, the default credentials
  6262. for accessing a web-based interface should not be the
  6263. same across all devices.
  6264. This is particularly true if the interface is enabled
  6265. by default as it can be assumed that many end-users
  6266. will not change the credentials.
  6267. </para></listitem>
  6268. <listitem><para>
  6269. Ensure you can update the software on the device to
  6270. mitigate vulnerabilities discovered in the future.
  6271. This consideration especially applies when your
  6272. device is network-enabled.
  6273. </para></listitem>
  6274. <listitem><para>
  6275. Ensure you remove or disable debugging functionality
  6276. before producing the final image.
  6277. For information on how to do this, see the
  6278. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  6279. section.
  6280. </para></listitem>
  6281. <listitem><para>
  6282. Ensure you have no network services listening that
  6283. are not needed.
  6284. </para></listitem>
  6285. <listitem><para>
  6286. Remove any software from the image that is not needed.
  6287. </para></listitem>
  6288. <listitem><para>
  6289. Enable hardware support for secure boot functionality
  6290. when your device supports this functionality.
  6291. </para></listitem>
  6292. </itemizedlist>
  6293. </para>
  6294. </section>
  6295. <section id='security-flags'>
  6296. <title>Security Flags</title>
  6297. <para>
  6298. The Yocto Project has security flags that you can enable that
  6299. help make your build output more secure.
  6300. The security flags are in the
  6301. <filename>meta/conf/distro/include/security_flags.inc</filename>
  6302. file in your
  6303. <link linkend='source-directory'>Source Directory</link>
  6304. (e.g. <filename>poky</filename>).
  6305. <note>
  6306. Depending on the recipe, certain security flags are enabled
  6307. and disabled by default.
  6308. </note>
  6309. </para>
  6310. <para>
  6311. <!--
  6312. The GCC/LD flags in <filename>security_flags.inc</filename>
  6313. enable more secure code generation.
  6314. By including the <filename>security_flags.inc</filename>
  6315. file, you enable flags to the compiler and linker that cause
  6316. them to generate more secure code.
  6317. <note>
  6318. The GCC/LD flags are enabled by default in the
  6319. <filename>poky-lsb</filename> distribution.
  6320. </note>
  6321. -->
  6322. Use the following line in your
  6323. <filename>local.conf</filename> file or in your custom
  6324. distribution configuration file to enable the security
  6325. compiler and linker flags for your build:
  6326. <literallayout class='monospaced'>
  6327. require conf/distro/include/security_flags.inc
  6328. </literallayout>
  6329. </para>
  6330. </section>
  6331. <section id='considerations-specific-to-the-openembedded-build-system'>
  6332. <title>Considerations Specific to the OpenEmbedded Build System</title>
  6333. <para>
  6334. You can take some steps that are specific to the
  6335. OpenEmbedded build system to make your images more secure:
  6336. <itemizedlist>
  6337. <listitem><para>
  6338. Ensure "debug-tweaks" is not one of your selected
  6339. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  6340. When creating a new project, the default is to provide you
  6341. with an initial <filename>local.conf</filename> file that
  6342. enables this feature using the
  6343. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  6344. <literallayout class='monospaced'>
  6345. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  6346. </literallayout>
  6347. To disable that feature, simply comment out that line in your
  6348. <filename>local.conf</filename> file, or
  6349. make sure <filename>IMAGE_FEATURES</filename> does not contain
  6350. "debug-tweaks" before producing your final image.
  6351. Among other things, leaving this in place sets the
  6352. root password as blank, which makes logging in for
  6353. debugging or inspection easy during
  6354. development but also means anyone can easily log in
  6355. during production.
  6356. </para></listitem>
  6357. <listitem><para>
  6358. It is possible to set a root password for the image
  6359. and also to set passwords for any extra users you might
  6360. add (e.g. administrative or service type users).
  6361. When you set up passwords for multiple images or
  6362. users, you should not duplicate passwords.
  6363. </para>
  6364. <para>
  6365. To set up passwords, use the
  6366. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  6367. class, which is the preferred method.
  6368. For an example on how to set up both root and user
  6369. passwords, see the
  6370. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  6371. section.
  6372. <note>
  6373. When adding extra user accounts or setting a
  6374. root password, be cautious about setting the
  6375. same password on every device.
  6376. If you do this, and the password you have set
  6377. is exposed, then every device is now potentially
  6378. compromised.
  6379. If you need this access but want to ensure
  6380. security, consider setting a different,
  6381. random password for each device.
  6382. Typically, you do this as a separate step after
  6383. you deploy the image onto the device.
  6384. </note>
  6385. </para></listitem>
  6386. <listitem><para>
  6387. Consider enabling a Mandatory Access Control (MAC)
  6388. framework such as SMACK or SELinux and tuning it
  6389. appropriately for your device's usage.
  6390. You can find more information in the
  6391. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink>
  6392. layer.
  6393. </para></listitem>
  6394. </itemizedlist>
  6395. </para>
  6396. <para>
  6397. </para>
  6398. </section>
  6399. <section id='tools-for-hardening-your-image'>
  6400. <title>Tools for Hardening Your Image</title>
  6401. <para>
  6402. The Yocto Project provides tools for making your image
  6403. more secure.
  6404. You can find these tools in the
  6405. <filename>meta-security</filename> layer of the
  6406. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
  6407. </para>
  6408. </section>
  6409. </section>
  6410. <section id='creating-your-own-distribution'>
  6411. <title>Creating Your Own Distribution</title>
  6412. <para>
  6413. When you build an image using the Yocto Project and
  6414. do not alter any distribution
  6415. <link linkend='metadata'>Metadata</link>, you are creating a
  6416. Poky distribution.
  6417. If you wish to gain more control over package alternative
  6418. selections, compile-time options, and other low-level
  6419. configurations, you can create your own distribution.
  6420. </para>
  6421. <para>
  6422. To create your own distribution, the basic steps consist of
  6423. creating your own distribution layer, creating your own
  6424. distribution configuration file, and then adding any needed
  6425. code and Metadata to the layer.
  6426. The following steps provide some more detail:
  6427. <itemizedlist>
  6428. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  6429. Create your distribution layer so that you can keep your
  6430. Metadata and code for the distribution separate.
  6431. It is strongly recommended that you create and use your own
  6432. layer for configuration and code.
  6433. Using your own layer as compared to just placing
  6434. configurations in a <filename>local.conf</filename>
  6435. configuration file makes it easier to reproduce the same
  6436. build configuration when using multiple build machines.
  6437. See the
  6438. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  6439. section for information on how to quickly set up a layer.
  6440. </para></listitem>
  6441. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  6442. The distribution configuration file needs to be created in
  6443. the <filename>conf/distro</filename> directory of your
  6444. layer.
  6445. You need to name it using your distribution name
  6446. (e.g. <filename>mydistro.conf</filename>).
  6447. <note>
  6448. The
  6449. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6450. variable in your
  6451. <filename>local.conf</filename> file determines the
  6452. name of your distribution.
  6453. </note></para>
  6454. <para>You can split out parts of your configuration file
  6455. into include files and then "require" them from within
  6456. your distribution configuration file.
  6457. Be sure to place the include files in the
  6458. <filename>conf/distro/include</filename> directory of
  6459. your layer.
  6460. A common example usage of include files would be to
  6461. separate out the selection of desired version and revisions
  6462. for individual recipes.
  6463. </para>
  6464. <para>Your configuration file needs to set the following
  6465. required variables:
  6466. <literallayout class='monospaced'>
  6467. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  6468. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  6469. </literallayout>
  6470. These following variables are optional and you typically
  6471. set them from the distribution configuration file:
  6472. <literallayout class='monospaced'>
  6473. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6474. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  6475. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  6476. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  6477. </literallayout>
  6478. <tip>
  6479. If you want to base your distribution configuration file
  6480. on the very basic configuration from OE-Core, you
  6481. can use
  6482. <filename>conf/distro/defaultsetup.conf</filename> as
  6483. a reference and just include variables that differ
  6484. as compared to <filename>defaultsetup.conf</filename>.
  6485. Alternatively, you can create a distribution
  6486. configuration file from scratch using the
  6487. <filename>defaultsetup.conf</filename> file
  6488. or configuration files from other distributions
  6489. such as Poky or Angstrom as references.
  6490. </tip></para></listitem>
  6491. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  6492. Be sure to define any other variables for which you want to
  6493. create a default or enforce as part of the distribution
  6494. configuration.
  6495. You can include nearly any variable from the
  6496. <filename>local.conf</filename> file.
  6497. The variables you use are not limited to the list in the
  6498. previous bulleted item.</para></listitem>
  6499. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  6500. In your <filename>local.conf</filename> file in the
  6501. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  6502. set your
  6503. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6504. variable to point to your distribution's configuration file.
  6505. For example, if your distribution's configuration file is
  6506. named <filename>mydistro.conf</filename>, then you point
  6507. to it as follows:
  6508. <literallayout class='monospaced'>
  6509. DISTRO = "mydistro"
  6510. </literallayout></para></listitem>
  6511. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  6512. Use your layer to hold other information needed for the
  6513. distribution:
  6514. <itemizedlist>
  6515. <listitem><para>Add recipes for installing
  6516. distro-specific configuration files that are not
  6517. already installed by another recipe.
  6518. If you have distro-specific configuration files
  6519. that are included by an existing recipe, you should
  6520. add an append file (<filename>.bbappend</filename>)
  6521. for those.
  6522. For general information and recommendations
  6523. on how to add recipes to your layer, see the
  6524. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  6525. and
  6526. "<link linkend='best-practices-to-follow-when-creating-layers'>Best Practices to Follow When Creating Layers</link>"
  6527. sections.</para></listitem>
  6528. <listitem><para>Add any image recipes that are specific
  6529. to your distribution.</para></listitem>
  6530. <listitem><para>Add a <filename>psplash</filename>
  6531. append file for a branded splash screen.
  6532. For information on append files, see the
  6533. "<link linkend='using-bbappend-files'>Using .bbappend Files</link>"
  6534. section.</para></listitem>
  6535. <listitem><para>Add any other append files to make
  6536. custom changes that are specific to individual
  6537. recipes.</para></listitem>
  6538. </itemizedlist></para></listitem>
  6539. </itemizedlist>
  6540. </para>
  6541. </section>
  6542. <section id='creating-a-custom-template-configuration-directory'>
  6543. <title>Creating a Custom Template Configuration Directory</title>
  6544. <para>
  6545. If you are producing your own customized version
  6546. of the build system for use by other users, you might
  6547. want to customize the message shown by the setup script or
  6548. you might want to change the template configuration files (i.e.
  6549. <filename>local.conf</filename> and
  6550. <filename>bblayers.conf</filename>) that are created in
  6551. a new build directory.
  6552. </para>
  6553. <para>
  6554. The OpenEmbedded build system uses the environment variable
  6555. <filename>TEMPLATECONF</filename> to locate the directory
  6556. from which it gathers configuration information that ultimately
  6557. ends up in the
  6558. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  6559. <filename>conf</filename> directory.
  6560. By default, <filename>TEMPLATECONF</filename> is set as
  6561. follows in the <filename>poky</filename> repository:
  6562. <literallayout class='monospaced'>
  6563. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  6564. </literallayout>
  6565. This is the directory used by the build system to find templates
  6566. from which to build some key configuration files.
  6567. If you look at this directory, you will see the
  6568. <filename>bblayers.conf.sample</filename>,
  6569. <filename>local.conf.sample</filename>, and
  6570. <filename>conf-notes.txt</filename> files.
  6571. The build system uses these files to form the respective
  6572. <filename>bblayers.conf</filename> file,
  6573. <filename>local.conf</filename> file, and display the list of
  6574. BitBake targets when running the setup script.
  6575. </para>
  6576. <para>
  6577. To override these default configuration files with
  6578. configurations you want used within every new
  6579. Build Directory, simply set the
  6580. <filename>TEMPLATECONF</filename> variable to your directory.
  6581. The <filename>TEMPLATECONF</filename> variable is set in the
  6582. <filename>.templateconf</filename> file, which is in the
  6583. top-level
  6584. <link linkend='source-directory'>Source Directory</link>
  6585. folder (e.g. <filename>poky</filename>).
  6586. Edit the <filename>.templateconf</filename> so that it can locate
  6587. your directory.
  6588. </para>
  6589. <para>
  6590. Best practices dictate that you should keep your
  6591. template configuration directory in your custom distribution layer.
  6592. For example, suppose you have a layer named
  6593. <filename>meta-mylayer</filename> located in your home directory
  6594. and you want your template configuration directory named
  6595. <filename>myconf</filename>.
  6596. Changing the <filename>.templateconf</filename> as follows
  6597. causes the OpenEmbedded build system to look in your directory
  6598. and base its configuration files on the
  6599. <filename>*.sample</filename> configuration files it finds.
  6600. The final configuration files (i.e.
  6601. <filename>local.conf</filename> and
  6602. <filename>bblayers.conf</filename> ultimately still end up in
  6603. your Build Directory, but they are based on your
  6604. <filename>*.sample</filename> files.
  6605. <literallayout class='monospaced'>
  6606. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  6607. </literallayout>
  6608. </para>
  6609. <para>
  6610. Aside from the <filename>*.sample</filename> configuration files,
  6611. the <filename>conf-notes.txt</filename> also resides in the
  6612. default <filename>meta-poky/conf</filename> directory.
  6613. The scripts that set up the build environment
  6614. (i.e.
  6615. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>
  6616. and
  6617. <ulink url="&YOCTO_DOCS_REF_URL;#structure-memres-core-script"><filename>oe-init-build-env-memres</filename></ulink>)
  6618. use this file to display BitBake targets as part of the script
  6619. output.
  6620. Customizing this <filename>conf-notes.txt</filename> file is a
  6621. good way to make sure your list of custom targets appears
  6622. as part of the script's output.
  6623. </para>
  6624. <para>
  6625. Here is the default list of targets displayed as a result of
  6626. running either of the setup scripts:
  6627. <literallayout class='monospaced'>
  6628. You can now run 'bitbake &lt;target&gt;'
  6629. Common targets are:
  6630. core-image-minimal
  6631. core-image-sato
  6632. meta-toolchain
  6633. meta-ide-support
  6634. </literallayout>
  6635. </para>
  6636. <para>
  6637. Changing the listed common targets is as easy as editing your
  6638. version of <filename>conf-notes.txt</filename> in your
  6639. custom template configuration directory and making sure you
  6640. have <filename>TEMPLATECONF</filename> set to your directory.
  6641. </para>
  6642. </section>
  6643. <section id='building-a-tiny-system'>
  6644. <title>Building a Tiny System</title>
  6645. <para>
  6646. Very small distributions have some significant advantages such
  6647. as requiring less on-die or in-package memory (cheaper), better
  6648. performance through efficient cache usage, lower power requirements
  6649. due to less memory, faster boot times, and reduced development
  6650. overhead.
  6651. Some real-world examples where a very small distribution gives
  6652. you distinct advantages are digital cameras, medical devices,
  6653. and small headless systems.
  6654. </para>
  6655. <para>
  6656. This section presents information that shows you how you can
  6657. trim your distribution to even smaller sizes than the
  6658. <filename>poky-tiny</filename> distribution, which is around
  6659. 5 Mbytes, that can be built out-of-the-box using the Yocto Project.
  6660. </para>
  6661. <section id='tiny-system-overview'>
  6662. <title>Overview</title>
  6663. <para>
  6664. The following list presents the overall steps you need to
  6665. consider and perform to create distributions with smaller
  6666. root filesystems, achieve faster boot times, maintain your critical
  6667. functionality, and avoid initial RAM disks:
  6668. <itemizedlist>
  6669. <listitem><para>
  6670. <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link>
  6671. </para></listitem>
  6672. <listitem><para>
  6673. <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link>
  6674. </para></listitem>
  6675. <listitem><para>
  6676. <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link>
  6677. </para></listitem>
  6678. <listitem><para>
  6679. <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link>
  6680. </para></listitem>
  6681. <listitem><para>
  6682. <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link>
  6683. </para></listitem>
  6684. <listitem><para>
  6685. <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link>
  6686. </para></listitem>
  6687. <listitem><para>
  6688. <link linkend='iterate-on-the-process'>Iterate on the process.</link>
  6689. </para></listitem>
  6690. </itemizedlist>
  6691. </para>
  6692. </section>
  6693. <section id='goals-and-guiding-principles'>
  6694. <title>Goals and Guiding Principles</title>
  6695. <para>
  6696. Before you can reach your destination, you need to know
  6697. where you are going.
  6698. Here is an example list that you can use as a guide when
  6699. creating very small distributions:
  6700. <itemizedlist>
  6701. <listitem><para>Determine how much space you need
  6702. (e.g. a kernel that is 1 Mbyte or less and
  6703. a root filesystem that is 3 Mbytes or less).
  6704. </para></listitem>
  6705. <listitem><para>Find the areas that are currently
  6706. taking 90% of the space and concentrate on reducing
  6707. those areas.
  6708. </para></listitem>
  6709. <listitem><para>Do not create any difficult "hacks"
  6710. to achieve your goals.</para></listitem>
  6711. <listitem><para>Leverage the device-specific
  6712. options.</para></listitem>
  6713. <listitem><para>Work in a separate layer so that you
  6714. keep changes isolated.
  6715. For information on how to create layers, see
  6716. the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section.
  6717. </para></listitem>
  6718. </itemizedlist>
  6719. </para>
  6720. </section>
  6721. <section id='understand-what-gives-your-image-size'>
  6722. <title>Understand What Contributes to Your Image Size</title>
  6723. <para>
  6724. It is easiest to have something to start with when creating
  6725. your own distribution.
  6726. You can use the Yocto Project out-of-the-box to create the
  6727. <filename>poky-tiny</filename> distribution.
  6728. Ultimately, you will want to make changes in your own
  6729. distribution that are likely modeled after
  6730. <filename>poky-tiny</filename>.
  6731. <note>
  6732. To use <filename>poky-tiny</filename> in your build,
  6733. set the
  6734. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6735. variable in your
  6736. <filename>local.conf</filename> file to "poky-tiny"
  6737. as described in the
  6738. "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  6739. section.
  6740. </note>
  6741. </para>
  6742. <para>
  6743. Understanding some memory concepts will help you reduce the
  6744. system size.
  6745. Memory consists of static, dynamic, and temporary memory.
  6746. Static memory is the TEXT (code), DATA (initialized data
  6747. in the code), and BSS (uninitialized data) sections.
  6748. Dynamic memory represents memory that is allocated at runtime:
  6749. stacks, hash tables, and so forth.
  6750. Temporary memory is recovered after the boot process.
  6751. This memory consists of memory used for decompressing
  6752. the kernel and for the <filename>__init__</filename>
  6753. functions.
  6754. </para>
  6755. <para>
  6756. To help you see where you currently are with kernel and root
  6757. filesystem sizes, you can use two tools found in the
  6758. <link linkend='source-directory'>Source Directory</link> in
  6759. the <filename>scripts/tiny/</filename> directory:
  6760. <itemizedlist>
  6761. <listitem><para><filename>ksize.py</filename>: Reports
  6762. component sizes for the kernel build objects.
  6763. </para></listitem>
  6764. <listitem><para><filename>dirsize.py</filename>: Reports
  6765. component sizes for the root filesystem.</para></listitem>
  6766. </itemizedlist>
  6767. This next tool and command help you organize configuration
  6768. fragments and view file dependencies in a human-readable form:
  6769. <itemizedlist>
  6770. <listitem><para><filename>merge_config.sh</filename>:
  6771. Helps you manage configuration files and fragments
  6772. within the kernel.
  6773. With this tool, you can merge individual configuration
  6774. fragments together.
  6775. The tool allows you to make overrides and warns you
  6776. of any missing configuration options.
  6777. The tool is ideal for allowing you to iterate on
  6778. configurations, create minimal configurations, and
  6779. create configuration files for different machines
  6780. without having to duplicate your process.</para>
  6781. <para>The <filename>merge_config.sh</filename> script is
  6782. part of the Linux Yocto kernel Git repositories
  6783. (i.e. <filename>linux-yocto-3.14</filename>,
  6784. <filename>linux-yocto-3.10</filename>,
  6785. <filename>linux-yocto-3.8</filename>, and so forth)
  6786. in the
  6787. <filename>scripts/kconfig</filename> directory.</para>
  6788. <para>For more information on configuration fragments,
  6789. see the
  6790. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>"
  6791. section of the Yocto Project Linux Kernel Development
  6792. Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>"
  6793. section, which is in this manual.</para></listitem>
  6794. <listitem><para><filename>bitbake -u taskexp -g <replaceable>bitbake_target</replaceable></filename>:
  6795. Using the BitBake command with these options brings up
  6796. a Dependency Explorer from which you can view file
  6797. dependencies.
  6798. Understanding these dependencies allows you to make
  6799. informed decisions when cutting out various pieces of the
  6800. kernel and root filesystem.</para></listitem>
  6801. </itemizedlist>
  6802. </para>
  6803. </section>
  6804. <section id='trim-the-root-filesystem'>
  6805. <title>Trim the Root Filesystem</title>
  6806. <para>
  6807. The root filesystem is made up of packages for booting,
  6808. libraries, and applications.
  6809. To change things, you can configure how the packaging happens,
  6810. which changes the way you build them.
  6811. You can also modify the filesystem itself or select a different
  6812. filesystem.
  6813. </para>
  6814. <para>
  6815. First, find out what is hogging your root filesystem by running the
  6816. <filename>dirsize.py</filename> script from your root directory:
  6817. <literallayout class='monospaced'>
  6818. $ cd <replaceable>root-directory-of-image</replaceable>
  6819. $ dirsize.py 100000 > dirsize-100k.log
  6820. $ cat dirsize-100k.log
  6821. </literallayout>
  6822. You can apply a filter to the script to ignore files under
  6823. a certain size.
  6824. The previous example filters out any files below 100 Kbytes.
  6825. The sizes reported by the tool are uncompressed, and thus
  6826. will be smaller by a relatively constant factor in a
  6827. compressed root filesystem.
  6828. When you examine your log file, you can focus on areas of the
  6829. root filesystem that take up large amounts of memory.
  6830. </para>
  6831. <para>
  6832. You need to be sure that what you eliminate does not cripple
  6833. the functionality you need.
  6834. One way to see how packages relate to each other is by using
  6835. the Dependency Explorer UI with the BitBake command:
  6836. <literallayout class='monospaced'>
  6837. $ cd <replaceable>image-directory</replaceable>
  6838. $ bitbake -u taskexp -g <replaceable>image</replaceable>
  6839. </literallayout>
  6840. Use the interface to select potential packages you wish to
  6841. eliminate and see their dependency relationships.
  6842. </para>
  6843. <para>
  6844. When deciding how to reduce the size, get rid of packages that
  6845. result in minimal impact on the feature set.
  6846. For example, you might not need a VGA display.
  6847. Or, you might be able to get by with <filename>devtmpfs</filename>
  6848. and <filename>mdev</filename> instead of
  6849. <filename>udev</filename>.
  6850. </para>
  6851. <para>
  6852. Use your <filename>local.conf</filename> file to make changes.
  6853. For example, to eliminate <filename>udev</filename> and
  6854. <filename>glib</filename>, set the following in the
  6855. local configuration file:
  6856. <literallayout class='monospaced'>
  6857. VIRTUAL-RUNTIME_dev_manager = ""
  6858. </literallayout>
  6859. </para>
  6860. <para>
  6861. Finally, you should consider exactly the type of root
  6862. filesystem you need to meet your needs while also reducing
  6863. its size.
  6864. For example, consider <filename>cramfs</filename>,
  6865. <filename>squashfs</filename>, <filename>ubifs</filename>,
  6866. <filename>ext2</filename>, or an <filename>initramfs</filename>
  6867. using <filename>initramfs</filename>.
  6868. Be aware that <filename>ext3</filename> requires a 1 Mbyte
  6869. journal.
  6870. If you are okay with running read-only, you do not need this
  6871. journal.
  6872. </para>
  6873. <note>
  6874. After each round of elimination, you need to rebuild your
  6875. system and then use the tools to see the effects of your
  6876. reductions.
  6877. </note>
  6878. </section>
  6879. <section id='trim-the-kernel'>
  6880. <title>Trim the Kernel</title>
  6881. <para>
  6882. The kernel is built by including policies for hardware-independent
  6883. aspects.
  6884. What subsystems do you enable?
  6885. For what architecture are you building?
  6886. Which drivers do you build by default?
  6887. <note>You can modify the kernel source if you want to help
  6888. with boot time.
  6889. </note>
  6890. </para>
  6891. <para>
  6892. Run the <filename>ksize.py</filename> script from the top-level
  6893. Linux build directory to get an idea of what is making up
  6894. the kernel:
  6895. <literallayout class='monospaced'>
  6896. $ cd <replaceable>top-level-linux-build-directory</replaceable>
  6897. $ ksize.py > ksize.log
  6898. $ cat ksize.log
  6899. </literallayout>
  6900. When you examine the log, you will see how much space is
  6901. taken up with the built-in <filename>.o</filename> files for
  6902. drivers, networking, core kernel files, filesystem, sound,
  6903. and so forth.
  6904. The sizes reported by the tool are uncompressed, and thus
  6905. will be smaller by a relatively constant factor in a compressed
  6906. kernel image.
  6907. Look to reduce the areas that are large and taking up around
  6908. the "90% rule."
  6909. </para>
  6910. <para>
  6911. To examine, or drill down, into any particular area, use the
  6912. <filename>-d</filename> option with the script:
  6913. <literallayout class='monospaced'>
  6914. $ ksize.py -d > ksize.log
  6915. </literallayout>
  6916. Using this option breaks out the individual file information
  6917. for each area of the kernel (e.g. drivers, networking, and
  6918. so forth).
  6919. </para>
  6920. <para>
  6921. Use your log file to see what you can eliminate from the kernel
  6922. based on features you can let go.
  6923. For example, if you are not going to need sound, you do not
  6924. need any drivers that support sound.
  6925. </para>
  6926. <para>
  6927. After figuring out what to eliminate, you need to reconfigure
  6928. the kernel to reflect those changes during the next build.
  6929. You could run <filename>menuconfig</filename> and make all your
  6930. changes at once.
  6931. However, that makes it difficult to see the effects of your
  6932. individual eliminations and also makes it difficult to replicate
  6933. the changes for perhaps another target device.
  6934. A better method is to start with no configurations using
  6935. <filename>allnoconfig</filename>, create configuration
  6936. fragments for individual changes, and then manage the
  6937. fragments into a single configuration file using
  6938. <filename>merge_config.sh</filename>.
  6939. The tool makes it easy for you to iterate using the
  6940. configuration change and build cycle.
  6941. </para>
  6942. <para>
  6943. Each time you make configuration changes, you need to rebuild
  6944. the kernel and check to see what impact your changes had on
  6945. the overall size.
  6946. </para>
  6947. </section>
  6948. <section id='remove-package-management-requirements'>
  6949. <title>Remove Package Management Requirements</title>
  6950. <para>
  6951. Packaging requirements add size to the image.
  6952. One way to reduce the size of the image is to remove all the
  6953. packaging requirements from the image.
  6954. This reduction includes both removing the package manager
  6955. and its unique dependencies as well as removing the package
  6956. management data itself.
  6957. </para>
  6958. <para>
  6959. To eliminate all the packaging requirements for an image,
  6960. be sure that "package-management" is not part of your
  6961. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  6962. statement for the image.
  6963. When you remove this feature, you are removing the package
  6964. manager as well as its dependencies from the root filesystem.
  6965. </para>
  6966. </section>
  6967. <section id='look-for-other-ways-to-minimize-size'>
  6968. <title>Look for Other Ways to Minimize Size</title>
  6969. <para>
  6970. Depending on your particular circumstances, other areas that you
  6971. can trim likely exist.
  6972. The key to finding these areas is through tools and methods
  6973. described here combined with experimentation and iteration.
  6974. Here are a couple of areas to experiment with:
  6975. <itemizedlist>
  6976. <listitem><para><filename>glibc</filename>:
  6977. In general, follow this process:
  6978. <orderedlist>
  6979. <listitem><para>Remove <filename>glibc</filename>
  6980. features from
  6981. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6982. that you think you do not need.</para></listitem>
  6983. <listitem><para>Build your distribution.
  6984. </para></listitem>
  6985. <listitem><para>If the build fails due to missing
  6986. symbols in a package, determine if you can
  6987. reconfigure the package to not need those
  6988. features.
  6989. For example, change the configuration to not
  6990. support wide character support as is done for
  6991. <filename>ncurses</filename>.
  6992. Or, if support for those characters is needed,
  6993. determine what <filename>glibc</filename>
  6994. features provide the support and restore the
  6995. configuration.
  6996. </para></listitem>
  6997. <listitem><para>Rebuild and repeat the process.
  6998. </para></listitem>
  6999. </orderedlist></para></listitem>
  7000. <listitem><para><filename>busybox</filename>:
  7001. For BusyBox, use a process similar as described for
  7002. <filename>glibc</filename>.
  7003. A difference is you will need to boot the resulting
  7004. system to see if you are able to do everything you
  7005. expect from the running system.
  7006. You need to be sure to integrate configuration fragments
  7007. into Busybox because BusyBox handles its own core
  7008. features and then allows you to add configuration
  7009. fragments on top.
  7010. </para></listitem>
  7011. </itemizedlist>
  7012. </para>
  7013. </section>
  7014. <section id='iterate-on-the-process'>
  7015. <title>Iterate on the Process</title>
  7016. <para>
  7017. If you have not reached your goals on system size, you need
  7018. to iterate on the process.
  7019. The process is the same.
  7020. Use the tools and see just what is taking up 90% of the root
  7021. filesystem and the kernel.
  7022. Decide what you can eliminate without limiting your device
  7023. beyond what you need.
  7024. </para>
  7025. <para>
  7026. Depending on your system, a good place to look might be
  7027. Busybox, which provides a stripped down
  7028. version of Unix tools in a single, executable file.
  7029. You might be able to drop virtual terminal services or perhaps
  7030. ipv6.
  7031. </para>
  7032. </section>
  7033. </section>
  7034. <section id='building-images-for-more-than-one-machine'>
  7035. <title>Building Images for More than One Machine</title>
  7036. <para>
  7037. A common scenario developers face is creating images for several
  7038. different machines that use the same software environment.
  7039. In this situation, it is tempting to set the
  7040. tunings and optimization flags for each build specifically for
  7041. the targeted hardware (i.e. "maxing out" the tunings).
  7042. Doing so can considerably add to build times and package feed
  7043. maintenance collectively for the machines.
  7044. For example, selecting tunes that are extremely specific to a
  7045. CPU core used in a system might enable some micro optimizations
  7046. in GCC for that particular system but would otherwise not gain
  7047. you much of a performance difference across the other systems
  7048. as compared to using a more general tuning across all the builds
  7049. (e.g. setting
  7050. <ulink url='var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink>
  7051. specifically for each machine's build).
  7052. Rather than "max out" each build's tunings, you can take steps that
  7053. cause the OpenEmbedded build system to reuse software across the
  7054. various machines where it makes sense.
  7055. </para>
  7056. <para>
  7057. If build speed and package feed maintenance are considerations,
  7058. you should consider the points in this section that can help you
  7059. optimize your tunings to best consider build times and package
  7060. feed maintenance.
  7061. <itemizedlist>
  7062. <listitem><para><emphasis>Share the Build Directory:</emphasis>
  7063. If at all possible, share the
  7064. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  7065. across builds.
  7066. The Yocto Project supports switching between different
  7067. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7068. values in the same <filename>TMPDIR</filename>.
  7069. This practice is well supported and regularly used by
  7070. developers when building for multiple machines.
  7071. When you use the same <filename>TMPDIR</filename> for
  7072. multiple machine builds, the OpenEmbedded build system can
  7073. reuse the existing native and often cross-recipes for
  7074. multiple machines.
  7075. Thus, build time decreases.
  7076. <note>
  7077. If
  7078. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  7079. settings change or fundamental configuration settings
  7080. such as the filesystem layout, you need to work with
  7081. a clean <filename>TMPDIR</filename>.
  7082. Sharing <filename>TMPDIR</filename> under these
  7083. circumstances might work but since it is not
  7084. guaranteed, you should use a clean
  7085. <filename>TMPDIR</filename>.
  7086. </note>
  7087. </para></listitem>
  7088. <listitem><para><emphasis>Enable the Appropriate Package Architecture:</emphasis>
  7089. By default, the OpenEmbedded build system enables three
  7090. levels of package architectures: "all", "tune" or "package",
  7091. and "machine".
  7092. Any given recipe usually selects one of these package
  7093. architectures (types) for its output.
  7094. Depending for what a given recipe creates packages, making
  7095. sure you enable the appropriate package architecture can
  7096. directly impact the build time.</para>
  7097. <para>A recipe that just generates scripts can enable
  7098. "all" architecture because there are no binaries to build.
  7099. To specifically enable "all" architecture, be sure your
  7100. recipe inherits the
  7101. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  7102. class.
  7103. This class is useful for "all" architectures because it
  7104. configures many variables so packages can be used across
  7105. multiple architectures.</para>
  7106. <para>If your recipe needs to generate packages that are
  7107. machine-specific or when one of the build or runtime
  7108. dependencies is already machine-architecture dependent,
  7109. which makes your recipe also machine-architecture dependent,
  7110. make sure your recipe enables the "machine" package
  7111. architecture through the
  7112. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>
  7113. variable:
  7114. <literallayout class='monospaced'>
  7115. PACKAGE_ARCH = "${MACHINE_ARCH}"
  7116. </literallayout>
  7117. When you do not specifically enable a package
  7118. architecture through the
  7119. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>,
  7120. The OpenEmbedded build system defaults to the
  7121. <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink>
  7122. setting:
  7123. <literallayout class='monospaced'>
  7124. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  7125. </literallayout>
  7126. </para></listitem>
  7127. <listitem><para><emphasis>Choose a Generic Tuning File if Possible:</emphasis>
  7128. Some tunes are more generic and can run on multiple targets
  7129. (e.g. an <filename>armv5</filename> set of packages could
  7130. run on <filename>armv6</filename> and
  7131. <filename>armv7</filename> processors in most cases).
  7132. Similarly, <filename>i486</filename> binaries could work
  7133. on <filename>i586</filename> and higher processors.
  7134. You should realize, however, that advances on newer
  7135. processor versions would not be used.</para>
  7136. <para>If you select the same tune for several different
  7137. machines, the OpenEmbedded build system reuses software
  7138. previously built, thus speeding up the overall build time.
  7139. Realize that even though a new sysroot for each machine is
  7140. generated, the software is not recompiled and only one
  7141. package feed exists.
  7142. </para></listitem>
  7143. <listitem><para><emphasis>Manage Granular Level Packaging:</emphasis>
  7144. Sometimes cases exist where injecting another level
  7145. of package architecture beyond the three higher levels
  7146. noted earlier can be useful.
  7147. For example, consider the <filename>emgd</filename>
  7148. graphics stack in the
  7149. <filename>meta-intel</filename> layer.
  7150. In this layer, a subset of software exists that is
  7151. compiled against something different from the rest of the
  7152. generic packages.
  7153. You can examine the key code in the
  7154. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Source Repositories</ulink>
  7155. "daisy" branch in
  7156. <filename>classes/emgd-gl.bbclass</filename>.
  7157. For a specific set of packages, the code redefines
  7158. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>.
  7159. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXTRA_ARCHS'><filename>PACKAGE_EXTRA_ARCHS</filename></ulink>
  7160. is then appended with this extra tune name in
  7161. <filename>meta-intel-emgd.inc</filename>.
  7162. The result is that when searching for packages, the
  7163. build system uses a four-level search and the packages
  7164. in this new level are preferred as compared to the standard
  7165. tune.
  7166. The overall result is that the build system reuses most
  7167. software from the common tune except for specific cases
  7168. as needed.
  7169. </para></listitem>
  7170. <listitem><para><emphasis>Use Tools to Debug Issues:</emphasis>
  7171. Sometimes you can run into situations where software is
  7172. being rebuilt when you think it should not be.
  7173. For example, the OpenEmbedded build system might not be
  7174. using shared state between machines when you think it
  7175. should be.
  7176. These types of situations are usually due to references
  7177. to machine-specific variables such as
  7178. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  7179. <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLE'><filename>SERIAL_CONSOLE</filename></ulink>,
  7180. <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>,
  7181. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>,
  7182. and so forth in code that is supposed to only be
  7183. tune-specific or when the recipe depends
  7184. (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  7185. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  7186. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  7187. <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>,
  7188. and so forth) on some other recipe that already has
  7189. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>
  7190. defined as "${MACHINE_ARCH}".
  7191. <note>
  7192. Patches to fix any issues identified are most welcome
  7193. as these issues occasionally do occur.
  7194. </note></para>
  7195. <para>For such cases, you can use some tools to help you
  7196. sort out the situation:
  7197. <itemizedlist>
  7198. <listitem><para><emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis>
  7199. You can find this tool in the
  7200. <filename>scripts</filename> directory of the
  7201. Source Repositories.
  7202. See the comments in the script for information on
  7203. how to use the tool.
  7204. </para></listitem>
  7205. <listitem><para><emphasis>BitBake's "-S printdiff" Option:</emphasis>
  7206. Using this option causes BitBake to try to
  7207. establish the closest signature match it can
  7208. (e.g. in the shared state cache) and then run
  7209. <filename>bitbake-diffsigs</filename> over the
  7210. matches to determine the stamps and delta where
  7211. these two stamp trees diverge.
  7212. </para></listitem>
  7213. </itemizedlist>
  7214. </para></listitem>
  7215. </itemizedlist>
  7216. </para>
  7217. </section>
  7218. <section id='working-with-packages'>
  7219. <title>Working with Packages</title>
  7220. <para>
  7221. This section describes a few tasks that involve packages:
  7222. <itemizedlist>
  7223. <listitem><para>
  7224. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  7225. </para></listitem>
  7226. <listitem><para>
  7227. <link linkend='incrementing-a-binary-package-version'>Incrementing a binary package version</link>
  7228. </para></listitem>
  7229. <listitem><para>
  7230. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  7231. </para></listitem>
  7232. <listitem><para>
  7233. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  7234. </para></listitem>
  7235. <listitem><para>
  7236. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  7237. </para></listitem>
  7238. </itemizedlist>
  7239. </para>
  7240. <section id='excluding-packages-from-an-image'>
  7241. <title>Excluding Packages from an Image</title>
  7242. <para>
  7243. You might find it necessary to prevent specific packages
  7244. from being installed into an image.
  7245. If so, you can use several variables to direct the build
  7246. system to essentially ignore installing recommended packages
  7247. or to not install a package at all.
  7248. </para>
  7249. <para>
  7250. The following list introduces variables you can use to
  7251. prevent packages from being installed into your image.
  7252. Each of these variables only works with IPK and RPM
  7253. package types.
  7254. Support for Debian packages does not exist.
  7255. Also, you can use these variables from your
  7256. <filename>local.conf</filename> file or attach them to a
  7257. specific image recipe by using a recipe name override.
  7258. For more detail on the variables, see the descriptions in the
  7259. Yocto Project Reference Manual's glossary chapter.
  7260. <itemizedlist>
  7261. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  7262. Use this variable to specify "recommended-only"
  7263. packages that you do not want installed.
  7264. </para></listitem>
  7265. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  7266. Use this variable to prevent all "recommended-only"
  7267. packages from being installed.
  7268. </para></listitem>
  7269. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  7270. Use this variable to prevent specific packages from
  7271. being installed regardless of whether they are
  7272. "recommended-only" or not.
  7273. You need to realize that the build process could
  7274. fail with an error when you
  7275. prevent the installation of a package whose presence
  7276. is required by an installed package.
  7277. </para></listitem>
  7278. </itemizedlist>
  7279. </para>
  7280. </section>
  7281. <section id='incrementing-a-binary-package-version'>
  7282. <title>Incrementing a Package Version</title>
  7283. <para>
  7284. This section provides some background on how binary package
  7285. versioning is accomplished and presents some of the services,
  7286. variables, and terminology involved.
  7287. </para>
  7288. <para>
  7289. In order to understand binary package versioning, you need
  7290. to consider the following:
  7291. <itemizedlist>
  7292. <listitem><para>
  7293. Binary Package: The binary package that is eventually
  7294. built and installed into an image.
  7295. </para></listitem>
  7296. <listitem><para>
  7297. Binary Package Version: The binary package version
  7298. is composed of two components - a version and a
  7299. revision.
  7300. <note>
  7301. Technically, a third component, the "epoch" (i.e.
  7302. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>)
  7303. is involved but this discussion for the most part
  7304. ignores <filename>PE</filename>.
  7305. </note>
  7306. The version and revision are taken from the
  7307. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  7308. and
  7309. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  7310. variables, respectively.
  7311. </para></listitem>
  7312. <listitem><para>
  7313. <filename>PV</filename>: The recipe version.
  7314. <filename>PV</filename> represents the version of the
  7315. software being packaged.
  7316. Do not confuse <filename>PV</filename> with the
  7317. binary package version.
  7318. </para></listitem>
  7319. <listitem><para>
  7320. <filename>PR</filename>: The recipe revision.
  7321. </para></listitem>
  7322. <listitem><para>
  7323. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>:
  7324. The OpenEmbedded build system uses this string
  7325. to help define the value of <filename>PV</filename>
  7326. when the source code revision needs to be included
  7327. in it.
  7328. </para></listitem>
  7329. <listitem><para>
  7330. <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>:
  7331. A network-based service that helps automate keeping
  7332. package feeds compatible with existing package
  7333. manager applications such as RPM, APT, and OPKG.
  7334. </para></listitem>
  7335. </itemizedlist>
  7336. </para>
  7337. <para>
  7338. Whenever the binary package content changes, the binary package
  7339. version must change.
  7340. Changing the binary package version is accomplished by changing
  7341. or "bumping" the <filename>PR</filename> and/or
  7342. <filename>PV</filename> values.
  7343. Increasing these values occurs one of two ways:
  7344. <itemizedlist>
  7345. <listitem><para>Automatically using a Package Revision
  7346. Service (PR Service).
  7347. </para></listitem>
  7348. <listitem><para>Manually incrementing the
  7349. <filename>PR</filename> and/or
  7350. <filename>PV</filename> variables.
  7351. </para></listitem>
  7352. </itemizedlist>
  7353. </para>
  7354. <para>
  7355. Given a primary challenge of any build system and its users
  7356. is how to maintain a package feed that is compatible with
  7357. existing package manager applications such as RPM, APT, and
  7358. OPKG, using an automated system is much preferred over a
  7359. manual system.
  7360. In either system, the main requirement is that binary package
  7361. version numbering increases in a linear fashion and that a
  7362. number of version components exist that support that linear
  7363. progression.
  7364. For information on how to ensure package revisioning remains
  7365. linear, see the
  7366. "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>"
  7367. section.
  7368. </para>
  7369. <para>
  7370. The following three sections provide related information on the
  7371. PR Service, the manual method for "bumping"
  7372. <filename>PR</filename> and/or <filename>PV</filename>, and
  7373. on how to ensure binary package revisioning remains linear.
  7374. </para>
  7375. <section id='working-with-a-pr-service'>
  7376. <title>Working With a PR Service</title>
  7377. <para>
  7378. As mentioned, attempting to maintain revision numbers in the
  7379. <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink>
  7380. is error prone, inaccurate, and causes problems for people
  7381. submitting recipes.
  7382. Conversely, the PR Service automatically generates
  7383. increasing numbers, particularly the revision field,
  7384. which removes the human element.
  7385. <note>
  7386. For additional information on using a PR Service, you
  7387. can see the
  7388. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  7389. wiki page.
  7390. </note>
  7391. </para>
  7392. <para>
  7393. The Yocto Project uses variables in order of
  7394. decreasing priority to facilitate revision numbering (i.e.
  7395. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  7396. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  7397. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  7398. for epoch, version, and revision, respectively).
  7399. The values are highly dependent on the policies and
  7400. procedures of a given distribution and package feed.
  7401. </para>
  7402. <para>
  7403. Because the OpenEmbedded build system uses
  7404. "<ulink url='&YOCTO_DOCS_REF_URL;#checksums'>signatures</ulink>",
  7405. which are unique to a given build, the build system
  7406. knows when to rebuild packages.
  7407. All the inputs into a given task are represented by a
  7408. signature, which can trigger a rebuild when different.
  7409. Thus, the build system itself does not rely on the
  7410. <filename>PR</filename>, <filename>PV</filename>, and
  7411. <filename>PE</filename> numbers to trigger a rebuild.
  7412. The signatures, however, can be used to generate
  7413. these values.
  7414. </para>
  7415. <para>
  7416. The PR Service works with both
  7417. <filename>OEBasic</filename> and
  7418. <filename>OEBasicHash</filename> generators.
  7419. The value of <filename>PR</filename> bumps when the
  7420. checksum changes and the different generator mechanisms
  7421. change signatures under different circumstances.
  7422. </para>
  7423. <para>
  7424. As implemented, the build system includes values from
  7425. the PR Service into the <filename>PR</filename> field as
  7426. an addition using the form "<filename>.x</filename>" so
  7427. <filename>r0</filename> becomes <filename>r0.1</filename>,
  7428. <filename>r0.2</filename> and so forth.
  7429. This scheme allows existing <filename>PR</filename> values
  7430. to be used for whatever reasons, which include manual
  7431. <filename>PR</filename> bumps, should it be necessary.
  7432. </para>
  7433. <para>
  7434. By default, the PR Service is not enabled or running.
  7435. Thus, the packages generated are just "self consistent".
  7436. The build system adds and removes packages and
  7437. there are no guarantees about upgrade paths but images
  7438. will be consistent and correct with the latest changes.
  7439. </para>
  7440. <para>
  7441. The simplest form for a PR Service is for it to exist
  7442. for a single host development system that builds the
  7443. package feed (building system).
  7444. For this scenario, you can enable a local PR Service by
  7445. setting
  7446. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  7447. in your <filename>local.conf</filename> file in the
  7448. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  7449. <literallayout class='monospaced'>
  7450. PRSERV_HOST = "localhost:0"
  7451. </literallayout>
  7452. Once the service is started, packages will automatically
  7453. get increasing <filename>PR</filename> values and
  7454. BitBake takes care of starting and stopping the server.
  7455. </para>
  7456. <para>
  7457. If you have a more complex setup where multiple host
  7458. development systems work against a common, shared package
  7459. feed, you have a single PR Service running and it is
  7460. connected to each building system.
  7461. For this scenario, you need to start the PR Service using
  7462. the <filename>bitbake-prserv</filename> command:
  7463. <literallayout class='monospaced'>
  7464. bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start
  7465. </literallayout>
  7466. In addition to hand-starting the service, you need to
  7467. update the <filename>local.conf</filename> file of each
  7468. building system as described earlier so each system
  7469. points to the server and port.
  7470. </para>
  7471. <para>
  7472. It is also recommended you use build history, which adds
  7473. some sanity checks to binary package versions, in
  7474. conjunction with the server that is running the PR Service.
  7475. To enable build history, add the following to each building
  7476. system's <filename>local.conf</filename> file:
  7477. <literallayout class='monospaced'>
  7478. # It is recommended to activate "buildhistory" for testing the PR service
  7479. INHERIT += "buildhistory"
  7480. BUILDHISTORY_COMMIT = "1"
  7481. </literallayout>
  7482. For information on build history, see the
  7483. "<ulink url='&YOCTO_DOCS_REF_URL;#maintaining-build-output-quality'>Maintaining Build Output Quality</ulink>"
  7484. section in the Yocto Project Reference Manual.
  7485. </para>
  7486. <note>
  7487. <para>
  7488. The OpenEmbedded build system does not maintain
  7489. <filename>PR</filename> information as part of the
  7490. shared state (sstate) packages.
  7491. If you maintain an sstate feed, its expected that either
  7492. all your building systems that contribute to the sstate
  7493. feed use a shared PR Service, or you do not run a PR
  7494. Service on any of your building systems.
  7495. Having some systems use a PR Service while others do
  7496. not leads to obvious problems.
  7497. </para>
  7498. <para>
  7499. For more information on shared state, see the
  7500. "<ulink url='&YOCTO_DOCS_REF_URL;#shared-state-cache'>Shared State Cache</ulink>"
  7501. section in the Yocto Project Reference Manual.
  7502. </para>
  7503. </note>
  7504. </section>
  7505. <section id='manually-bumping-pr'>
  7506. <title>Manually Bumping PR</title>
  7507. <para>
  7508. The alternative to setting up a PR Service is to manually
  7509. "bump" the
  7510. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  7511. variable.
  7512. </para>
  7513. <para>
  7514. If a committed change results in changing the package
  7515. output, then the value of the PR variable needs to be
  7516. increased (or "bumped") as part of that commit.
  7517. For new recipes you should add the <filename>PR</filename>
  7518. variable and set its initial value equal to "r0", which is
  7519. the default.
  7520. Even though the default value is "r0", the practice of
  7521. adding it to a new recipe makes it harder to forget to bump
  7522. the variable when you make changes to the recipe in future.
  7523. </para>
  7524. <para>
  7525. If you are sharing a common <filename>.inc</filename> file
  7526. with multiple recipes, you can also use the
  7527. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  7528. variable to ensure that the recipes sharing the
  7529. <filename>.inc</filename> file are rebuilt when the
  7530. <filename>.inc</filename> file itself is changed.
  7531. The <filename>.inc</filename> file must set
  7532. <filename>INC_PR</filename> (initially to "r0"), and all
  7533. recipes referring to it should set <filename>PR</filename>
  7534. to "${INC_PR}.0" initially, incrementing the last number
  7535. when the recipe is changed.
  7536. If the <filename>.inc</filename> file is changed then its
  7537. <filename>INC_PR</filename> should be incremented.
  7538. </para>
  7539. <para>
  7540. When upgrading the version of a binary package, assuming the
  7541. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  7542. changes, the <filename>PR</filename> variable should be
  7543. reset to "r0" (or "${INC_PR}.0" if you are using
  7544. <filename>INC_PR</filename>).
  7545. </para>
  7546. <para>
  7547. Usually, version increases occur only to binary packages.
  7548. However, if for some reason <filename>PV</filename> changes
  7549. but does not increase, you can increase the
  7550. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  7551. variable (Package Epoch).
  7552. The <filename>PE</filename> variable defaults to "0".
  7553. </para>
  7554. <para>
  7555. Binary package version numbering strives to follow the
  7556. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  7557. Debian Version Field Policy Guidelines</ulink>.
  7558. These guidelines define how versions are compared and what
  7559. "increasing" a version means.
  7560. </para>
  7561. </section>
  7562. <section id='automatically-incrementing-a-binary-package-revision-number'>
  7563. <title>Automatically Incrementing a Package Version Number</title>
  7564. <para>
  7565. When fetching a repository, BitBake uses the
  7566. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  7567. variable to determine the specific source code revision
  7568. from which to build.
  7569. You set the <filename>SRCREV</filename> variable to
  7570. <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>
  7571. to cause the OpenEmbedded build system to automatically use the
  7572. latest revision of the software:
  7573. <literallayout class='monospaced'>
  7574. SRCREV = "${AUTOREV}"
  7575. </literallayout>
  7576. </para>
  7577. <para>
  7578. Furthermore, you need to reference <filename>SRCPV</filename>
  7579. in <filename>PV</filename> in order to automatically update
  7580. the version whenever the revision of the source code
  7581. changes.
  7582. Here is an example:
  7583. <literallayout class='monospaced'>
  7584. PV = "1.0+git${SRCPV}"
  7585. </literallayout>
  7586. The OpenEmbedded build system substitutes
  7587. <filename>SRCPV</filename> with the following:
  7588. <literallayout class='monospaced'>
  7589. AUTOINC+<replaceable>source_code_revision</replaceable>
  7590. </literallayout>
  7591. The build system replaces the <filename>AUTOINC</filename> with
  7592. a number.
  7593. The number used depends on the state of the PR Service:
  7594. <itemizedlist>
  7595. <listitem><para>
  7596. If PR Service is enabled, the build system increments
  7597. the number, which is similar to the behavior of
  7598. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>.
  7599. This behavior results in linearly increasing package
  7600. versions, which is desirable.
  7601. Here is an example:
  7602. <literallayout class='monospaced'>
  7603. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  7604. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  7605. </literallayout>
  7606. </para></listitem>
  7607. <listitem><para>
  7608. If PR Service is not enabled, the build system
  7609. replaces the <filename>AUTOINC</filename>
  7610. placeholder with zero (i.e. "0").
  7611. This results in changing the package version since
  7612. the source revision is included.
  7613. However, package versions are not increased linearly.
  7614. Here is an example:
  7615. <literallayout class='monospaced'>
  7616. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  7617. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  7618. </literallayout>
  7619. </para></listitem>
  7620. </itemizedlist>
  7621. </para>
  7622. <para>
  7623. In summary, the OpenEmbedded build system does not track the
  7624. history of binary package versions for this purpose.
  7625. <filename>AUTOINC</filename>, in this case, is comparable to
  7626. <filename>PR</filename>.
  7627. If PR server is not enabled, <filename>AUTOINC</filename>
  7628. in the package version is simply replaced by "0".
  7629. If PR server is enabled, the build system keeps track of the
  7630. package versions and bumps the number when the package
  7631. revision changes.
  7632. </para>
  7633. </section>
  7634. </section>
  7635. <section id='handling-optional-module-packaging'>
  7636. <title>Handling Optional Module Packaging</title>
  7637. <para>
  7638. Many pieces of software split functionality into optional
  7639. modules (or plug-ins) and the plug-ins that are built
  7640. might depend on configuration options.
  7641. To avoid having to duplicate the logic that determines what
  7642. modules are available in your recipe or to avoid having
  7643. to package each module by hand, the OpenEmbedded build system
  7644. provides functionality to handle module packaging dynamically.
  7645. </para>
  7646. <para>
  7647. To handle optional module packaging, you need to do two things:
  7648. <itemizedlist>
  7649. <listitem><para>Ensure the module packaging is actually
  7650. done.</para></listitem>
  7651. <listitem><para>Ensure that any dependencies on optional
  7652. modules from other recipes are satisfied by your recipe.
  7653. </para></listitem>
  7654. </itemizedlist>
  7655. </para>
  7656. <section id='making-sure-the-packaging-is-done'>
  7657. <title>Making Sure the Packaging is Done</title>
  7658. <para>
  7659. To ensure the module packaging actually gets done, you use
  7660. the <filename>do_split_packages</filename> function within
  7661. the <filename>populate_packages</filename> Python function
  7662. in your recipe.
  7663. The <filename>do_split_packages</filename> function
  7664. searches for a pattern of files or directories under a
  7665. specified path and creates a package for each one it finds
  7666. by appending to the
  7667. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  7668. variable and setting the appropriate values for
  7669. <filename>FILES_packagename</filename>,
  7670. <filename>RDEPENDS_packagename</filename>,
  7671. <filename>DESCRIPTION_packagename</filename>, and so forth.
  7672. Here is an example from the <filename>lighttpd</filename>
  7673. recipe:
  7674. <literallayout class='monospaced'>
  7675. python populate_packages_prepend () {
  7676. lighttpd_libdir = d.expand('${libdir}')
  7677. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  7678. 'lighttpd-module-%s', 'Lighttpd module for %s',
  7679. extra_depends='')
  7680. }
  7681. </literallayout>
  7682. The previous example specifies a number of things in the
  7683. call to <filename>do_split_packages</filename>.
  7684. <itemizedlist>
  7685. <listitem><para>A directory within the files installed
  7686. by your recipe through <filename>do_install</filename>
  7687. in which to search.</para></listitem>
  7688. <listitem><para>A regular expression used to match module
  7689. files in that directory.
  7690. In the example, note the parentheses () that mark
  7691. the part of the expression from which the module
  7692. name should be derived.</para></listitem>
  7693. <listitem><para>A pattern to use for the package names.
  7694. </para></listitem>
  7695. <listitem><para>A description for each package.
  7696. </para></listitem>
  7697. <listitem><para>An empty string for
  7698. <filename>extra_depends</filename>, which disables
  7699. the default dependency on the main
  7700. <filename>lighttpd</filename> package.
  7701. Thus, if a file in <filename>${libdir}</filename>
  7702. called <filename>mod_alias.so</filename> is found,
  7703. a package called <filename>lighttpd-module-alias</filename>
  7704. is created for it and the
  7705. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  7706. is set to "Lighttpd module for alias".</para></listitem>
  7707. </itemizedlist>
  7708. </para>
  7709. <para>
  7710. Often, packaging modules is as simple as the previous
  7711. example.
  7712. However, more advanced options exist that you can use
  7713. within <filename>do_split_packages</filename> to modify its
  7714. behavior.
  7715. And, if you need to, you can add more logic by specifying
  7716. a hook function that is called for each package.
  7717. It is also perfectly acceptable to call
  7718. <filename>do_split_packages</filename> multiple times if
  7719. you have more than one set of modules to package.
  7720. </para>
  7721. <para>
  7722. For more examples that show how to use
  7723. <filename>do_split_packages</filename>, see the
  7724. <filename>connman.inc</filename> file in the
  7725. <filename>meta/recipes-connectivity/connman/</filename>
  7726. directory of the <filename>poky</filename>
  7727. <link linkend='yocto-project-repositories'>source repository</link>.
  7728. You can also find examples in
  7729. <filename>meta/classes/kernel.bbclass</filename>.
  7730. </para>
  7731. <para>
  7732. Following is a reference that shows
  7733. <filename>do_split_packages</filename> mandatory and
  7734. optional arguments:
  7735. <literallayout class='monospaced'>
  7736. Mandatory arguments
  7737. root
  7738. The path in which to search
  7739. file_regex
  7740. Regular expression to match searched files.
  7741. Use parentheses () to mark the part of this
  7742. expression that should be used to derive the
  7743. module name (to be substituted where %s is
  7744. used in other function arguments as noted below)
  7745. output_pattern
  7746. Pattern to use for the package names. Must
  7747. include %s.
  7748. description
  7749. Description to set for each package. Must
  7750. include %s.
  7751. Optional arguments
  7752. postinst
  7753. Postinstall script to use for all packages
  7754. (as a string)
  7755. recursive
  7756. True to perform a recursive search - default
  7757. False
  7758. hook
  7759. A hook function to be called for every match.
  7760. The function will be called with the following
  7761. arguments (in the order listed):
  7762. f
  7763. Full path to the file/directory match
  7764. pkg
  7765. The package name
  7766. file_regex
  7767. As above
  7768. output_pattern
  7769. As above
  7770. modulename
  7771. The module name derived using file_regex
  7772. extra_depends
  7773. Extra runtime dependencies (RDEPENDS) to be
  7774. set for all packages. The default value of None
  7775. causes a dependency on the main package
  7776. (${PN}) - if you do not want this, pass empty
  7777. string '' for this parameter.
  7778. aux_files_pattern
  7779. Extra item(s) to be added to FILES for each
  7780. package. Can be a single string item or a list
  7781. of strings for multiple items. Must include %s.
  7782. postrm
  7783. postrm script to use for all packages (as a
  7784. string)
  7785. allow_dirs
  7786. True to allow directories to be matched -
  7787. default False
  7788. prepend
  7789. If True, prepend created packages to PACKAGES
  7790. instead of the default False which appends them
  7791. match_path
  7792. match file_regex on the whole relative path to
  7793. the root rather than just the file name
  7794. aux_files_pattern_verbatim
  7795. Extra item(s) to be added to FILES for each
  7796. package, using the actual derived module name
  7797. rather than converting it to something legal
  7798. for a package name. Can be a single string item
  7799. or a list of strings for multiple items. Must
  7800. include %s.
  7801. allow_links
  7802. True to allow symlinks to be matched - default
  7803. False
  7804. summary
  7805. Summary to set for each package. Must include %s;
  7806. defaults to description if not set.
  7807. </literallayout>
  7808. </para>
  7809. </section>
  7810. <section id='satisfying-dependencies'>
  7811. <title>Satisfying Dependencies</title>
  7812. <para>
  7813. The second part for handling optional module packaging
  7814. is to ensure that any dependencies on optional modules
  7815. from other recipes are satisfied by your recipe.
  7816. You can be sure these dependencies are satisfied by
  7817. using the
  7818. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  7819. Here is an example that continues with the
  7820. <filename>lighttpd</filename> recipe shown earlier:
  7821. <literallayout class='monospaced'>
  7822. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  7823. </literallayout>
  7824. The name specified in the regular expression can of
  7825. course be anything.
  7826. In this example, it is <filename>lighttpd-module-</filename>
  7827. and is specified as the prefix to ensure that any
  7828. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  7829. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  7830. on a package name starting with the prefix are satisfied
  7831. during build time.
  7832. If you are using <filename>do_split_packages</filename>
  7833. as described in the previous section, the value you put in
  7834. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  7835. the name pattern specified in the call to
  7836. <filename>do_split_packages</filename>.
  7837. </para>
  7838. </section>
  7839. </section>
  7840. <section id='using-runtime-package-management'>
  7841. <title>Using Runtime Package Management</title>
  7842. <para>
  7843. During a build, BitBake always transforms a recipe into one or
  7844. more packages.
  7845. For example, BitBake takes the <filename>bash</filename> recipe
  7846. and currently produces the <filename>bash-dbg</filename>,
  7847. <filename>bash-staticdev</filename>,
  7848. <filename>bash-dev</filename>, <filename>bash-doc</filename>,
  7849. <filename>bash-locale</filename>, and
  7850. <filename>bash</filename> packages.
  7851. Not all generated packages are included in an image.
  7852. </para>
  7853. <para>
  7854. In several situations, you might need to update, add, remove,
  7855. or query the packages on a target device at runtime
  7856. (i.e. without having to generate a new image).
  7857. Examples of such situations include:
  7858. <itemizedlist>
  7859. <listitem><para>
  7860. You want to provide in-the-field updates to deployed
  7861. devices (e.g. security updates).
  7862. </para></listitem>
  7863. <listitem><para>
  7864. You want to have a fast turn-around development cycle
  7865. for one or more applications that run on your device.
  7866. </para></listitem>
  7867. <listitem><para>
  7868. You want to temporarily install the "debug" packages
  7869. of various applications on your device so that
  7870. debugging can be greatly improved by allowing
  7871. access to symbols and source debugging.
  7872. </para></listitem>
  7873. <listitem><para>
  7874. You want to deploy a more minimal package selection of
  7875. your device but allow in-the-field updates to add a
  7876. larger selection for customization.
  7877. </para></listitem>
  7878. </itemizedlist>
  7879. </para>
  7880. <para>
  7881. In all these situations, you have something similar to a more
  7882. traditional Linux distribution in that in-field devices
  7883. are able to receive pre-compiled packages from a server for
  7884. installation or update.
  7885. Being able to install these packages on a running,
  7886. in-field device is what is termed "runtime package
  7887. management".
  7888. </para>
  7889. <para>
  7890. In order to use runtime package management, you
  7891. need a host/server machine that serves up the pre-compiled
  7892. packages plus the required metadata.
  7893. You also need package manipulation tools on the target.
  7894. The build machine is a likely candidate to act as the server.
  7895. However, that machine does not necessarily have to be the
  7896. package server.
  7897. The build machine could push its artifacts to another machine
  7898. that acts as the server (e.g. Internet-facing).
  7899. </para>
  7900. <para>
  7901. A simple build that targets just one device produces
  7902. more than one package database.
  7903. In other words, the packages produced by a build are separated
  7904. out into a couple of different package groupings based on
  7905. criteria such as the target's CPU architecture, the target
  7906. board, or the C library used on the target.
  7907. For example, a build targeting the <filename>qemuarm</filename>
  7908. device produces the following three package databases:
  7909. <filename>all</filename>, <filename>armv5te</filename>, and
  7910. <filename>qemuarm</filename>.
  7911. If you wanted your <filename>qemuarm</filename> device to be
  7912. aware of all the packages that were available to it,
  7913. you would need to point it to each of these databases
  7914. individually.
  7915. In a similar way, a traditional Linux distribution usually is
  7916. configured to be aware of a number of software repositories
  7917. from which it retrieves packages.
  7918. </para>
  7919. <para>
  7920. Using runtime package management is completely optional and
  7921. not required for a successful build or deployment in any
  7922. way.
  7923. But if you want to make use of runtime package management,
  7924. you need to do a couple things above and beyond the basics.
  7925. The remainder of this section describes what you need to do.
  7926. </para>
  7927. <section id='runtime-package-management-build'>
  7928. <title>Build Considerations</title>
  7929. <para>
  7930. This section describes build considerations of which you
  7931. need to be aware in order to provide support for runtime
  7932. package management.
  7933. </para>
  7934. <para>
  7935. When BitBake generates packages, it needs to know
  7936. what format or formats to use.
  7937. In your configuration, you use the
  7938. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  7939. variable to specify the format:
  7940. <orderedlist>
  7941. <listitem><para>
  7942. Open the <filename>local.conf</filename> file
  7943. inside your
  7944. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  7945. (e.g. <filename>~/poky/build/conf/local.conf</filename>).
  7946. </para></listitem>
  7947. <listitem><para>
  7948. Select the desired package format as follows:
  7949. <literallayout class='monospaced'>
  7950. PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>”
  7951. </literallayout>
  7952. where <replaceable>packageformat</replaceable>
  7953. can be "ipk", "rpm", and "deb", which are the
  7954. supported package formats.
  7955. <note>
  7956. Because the Yocto Project supports three
  7957. different package formats, you can set the
  7958. variable with more than one argument.
  7959. However, the OpenEmbedded build system only
  7960. uses the first argument when creating an image
  7961. or Software Development Kit (SDK).
  7962. </note>
  7963. </para></listitem>
  7964. </orderedlist>
  7965. </para>
  7966. <para>
  7967. If you would like your image to start off with a basic
  7968. package database containing the packages in your current
  7969. build as well as to have the relevant tools available on the
  7970. target for runtime package management, you can include
  7971. "package-management" in the
  7972. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  7973. variable.
  7974. Including "package-management" in this
  7975. configuration variable ensures that when the image
  7976. is assembled for your target, the image includes
  7977. the currently-known package databases as well as
  7978. the target-specific tools required for runtime
  7979. package management to be performed on the target.
  7980. However, this is not strictly necessary.
  7981. You could start your image off without any databases
  7982. but only include the required on-target package
  7983. tool(s).
  7984. As an example, you could include "opkg" in your
  7985. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  7986. variable if you are using the IPK package format.
  7987. You can then initialize your target's package database(s)
  7988. later once your image is up and running.
  7989. </para>
  7990. <para>
  7991. Whenever you perform any sort of build step that can
  7992. potentially generate a package or modify an existing
  7993. package, it is always a good idea to re-generate the
  7994. package index with:
  7995. <literallayout class='monospaced'>
  7996. $ bitbake package-index
  7997. </literallayout>
  7998. Realize that it is not sufficient to simply do the
  7999. following:
  8000. <literallayout class='monospaced'>
  8001. $ bitbake <replaceable>some-package</replaceable> package-index
  8002. </literallayout>
  8003. The reason for this restriction is because BitBake does not
  8004. properly schedule the <filename>package-index</filename>
  8005. target fully after any other target has completed.
  8006. Thus, be sure to run the package update step separately.
  8007. </para>
  8008. <para>
  8009. You can use the
  8010. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8011. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  8012. and
  8013. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8014. variables to pre-configure target images to use a package
  8015. feed.
  8016. If you do not define these variables, then manual steps
  8017. as described in the subsequent sections are necessary to
  8018. configure the target.
  8019. You should set these variables before building the image
  8020. in order to produce a correctly configured image.
  8021. </para>
  8022. <para>
  8023. When your build is complete, your packages reside in the
  8024. <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename>
  8025. directory.
  8026. For example, if
  8027. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename>
  8028. is <filename>tmp</filename> and your selected package type
  8029. is IPK, then your IPK packages are available in
  8030. <filename>tmp/deploy/ipk</filename>.
  8031. </para>
  8032. </section>
  8033. <section id='runtime-package-management-server'>
  8034. <title>Host or Server Machine Setup</title>
  8035. <para>
  8036. Although other protocols are possible, a server using HTTP
  8037. typically serves packages.
  8038. If you want to use HTTP, then set up and configure a
  8039. web server such as Apache 2, lighttpd, or
  8040. SimpleHTTPServer on the machine serving the packages.
  8041. </para>
  8042. <para>
  8043. To keep things simple, this section describes how to set
  8044. up a SimpleHTTPServer web server to share package feeds
  8045. from the developer's machine.
  8046. Although this server might not be the best for a production
  8047. environment, the setup is simple and straight forward.
  8048. Should you want to use a different server more suited for
  8049. production (e.g. Apache 2, Lighttpd, or Nginx), take the
  8050. appropriate steps to do so.
  8051. </para>
  8052. <para>
  8053. From within the build directory where you have built an
  8054. image based on your packaging choice (i.e. the
  8055. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  8056. setting), simply start the server.
  8057. The following example assumes a build directory of
  8058. <filename>~/poky/build/tmp/deploy/rpm</filename> and a
  8059. <filename>PACKAGE_CLASSES</filename> setting of
  8060. "package_rpm":
  8061. <literallayout class='monospaced'>
  8062. $ cd ~/poky/build/tmp/deploy/rpm
  8063. $ python -m SimpleHTTPServer
  8064. </literallayout>
  8065. </para>
  8066. </section>
  8067. <section id='runtime-package-management-target'>
  8068. <title>Target Setup</title>
  8069. <para>
  8070. Setting up the target differs depending on the
  8071. package management system.
  8072. This section provides information for RPM, IPK, and DEB.
  8073. </para>
  8074. <section id='runtime-package-management-target-rpm'>
  8075. <title>Using RPM</title>
  8076. <para>
  8077. The <filename>dnf</filename> application performs
  8078. runtime package management of RPM packages.
  8079. You must perform an initial setup for
  8080. <filename>dnf</filename> on the target machine
  8081. if the
  8082. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8083. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  8084. and
  8085. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8086. variables have not been set or the target image was
  8087. built before the variables were set.
  8088. </para>
  8089. <para>
  8090. As an example, assume the target is able to use the
  8091. following package databases:
  8092. <filename>all</filename>, <filename>i586</filename>,
  8093. and <filename>qemux86</filename> from a server named
  8094. <filename>my.server</filename>.
  8095. You must inform <filename>dnf</filename> of the
  8096. availability of these databases by creating a
  8097. <filename>/etc/yum.repos.d/oe-packages.repo</filename>
  8098. file with the following content:
  8099. <literallayout class='monospaced'>
  8100. [oe-packages]
  8101. baseurl="http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all"
  8102. </literallayout>
  8103. From the target machine, fetch the repository:
  8104. <literallayout class='monospaced'>
  8105. # dnf makecache
  8106. </literallayout>
  8107. After everything is set up, <filename>dnf</filename>
  8108. is able to find, install, and upgrade packages from
  8109. the specified repository.
  8110. <note>
  8111. See the
  8112. <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink>
  8113. for additional information.
  8114. </note>
  8115. </para>
  8116. </section>
  8117. <section id='runtime-package-management-target-ipk'>
  8118. <title>Using IPK</title>
  8119. <para>
  8120. The <filename>opkg</filename> application performs
  8121. runtime package management of IPK packages.
  8122. You must perform an initial setup for
  8123. <filename>opkg</filename> on the target machine
  8124. if the
  8125. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8126. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  8127. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8128. variables have not been set or the target image was
  8129. built before the variables were set.
  8130. </para>
  8131. <para>
  8132. The <filename>opkg</filename> application uses
  8133. configuration files to find available package
  8134. databases.
  8135. Thus, you need to create a configuration file inside
  8136. the <filename>/etc/opkg/</filename> direction, which
  8137. informs <filename>opkg</filename> of any repository
  8138. you want to use.
  8139. </para>
  8140. <para>
  8141. As an example, suppose you are serving packages from a
  8142. <filename>ipk/</filename> directory containing the
  8143. <filename>i586</filename>,
  8144. <filename>all</filename>, and
  8145. <filename>qemux86</filename> databases through an
  8146. HTTP server named <filename>my.server</filename>.
  8147. On the target, create a configuration file
  8148. (e.g. <filename>my_repo.conf</filename>) inside the
  8149. <filename>/etc/opkg/</filename> directory containing
  8150. the following:
  8151. <literallayout class='monospaced'>
  8152. src/gz all http://my.server/ipk/all
  8153. src/gz i586 http://my.server/ipk/i586
  8154. src/gz qemux86 http://my.server/ipk/qemux86
  8155. </literallayout>
  8156. Next, instruct <filename>opkg</filename> to fetch
  8157. the repository information:
  8158. <literallayout class='monospaced'>
  8159. # opkg update
  8160. </literallayout>
  8161. The <filename>opkg</filename> application is now able
  8162. to find, install, and upgrade packages from the
  8163. specified repository.
  8164. </para>
  8165. </section>
  8166. <section id='runtime-package-management-target-deb'>
  8167. <title>Using DEB</title>
  8168. <para>
  8169. The <filename>apt</filename> application performs
  8170. runtime package management of DEB packages.
  8171. This application uses a source list file to find
  8172. available package databases.
  8173. You must perform an initial setup for
  8174. <filename>apt</filename> on the target machine
  8175. if the
  8176. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8177. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  8178. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8179. variables have not been set or the target image was
  8180. built before the variables were set.
  8181. </para>
  8182. <para>
  8183. To inform <filename>apt</filename> of the repository
  8184. you want to use, you might create a list file (e.g.
  8185. <filename>my_repo.list</filename>) inside the
  8186. <filename>/etc/apt/sources.list.d/</filename>
  8187. directory.
  8188. As an example, suppose you are serving packages from a
  8189. <filename>deb/</filename> directory containing the
  8190. <filename>i586</filename>,
  8191. <filename>all</filename>, and
  8192. <filename>qemux86</filename> databases through an
  8193. HTTP server named <filename>my.server</filename>.
  8194. The list file should contain:
  8195. <literallayout class='monospaced'>
  8196. deb http://my.server/deb/all ./
  8197. deb http://my.server/deb/i586 ./
  8198. deb http://my.server/deb/qemux86 ./
  8199. </literallayout>
  8200. Next, instruct the <filename>apt</filename>
  8201. application to fetch the repository information:
  8202. <literallayout class='monospaced'>
  8203. # apt-get update
  8204. </literallayout>
  8205. After this step, <filename>apt</filename> is able
  8206. to find, install, and upgrade packages from the
  8207. specified repository.
  8208. </para>
  8209. </section>
  8210. </section>
  8211. </section>
  8212. <section id='generating-and-using-signed-packages'>
  8213. <title>Generating and Using Signed Packages</title>
  8214. <para>
  8215. In order to add security to RPM packages used during a build,
  8216. you can take steps to securely sign them.
  8217. Once a signature is verified, the OpenEmbedded build system
  8218. can use the package in the build.
  8219. If security fails for a signed package, the build system
  8220. aborts the build.
  8221. </para>
  8222. <para>
  8223. This section describes how to sign RPM packages during a build
  8224. and how to use signed package feeds (repositories) when
  8225. doing a build.
  8226. </para>
  8227. <section id='signing-rpm-packages'>
  8228. <title>Signing RPM Packages</title>
  8229. <para>
  8230. To enable signing RPM packages, you must set up the
  8231. following configurations in either your
  8232. <filename>local.config</filename> or
  8233. <filename>distro.config</filename> file:
  8234. <literallayout class='monospaced'>
  8235. # Inherit sign_rpm.bbclass to enable signing functionality
  8236. INHERIT += " sign_rpm"
  8237. # Define the GPG key that will be used for signing.
  8238. RPM_GPG_NAME = "<replaceable>key_name</replaceable>"
  8239. # Provide passphrase for the key
  8240. RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>"
  8241. </literallayout>
  8242. <note>
  8243. Be sure to supply appropriate values for both
  8244. <replaceable>key_name</replaceable> and
  8245. <replaceable>passphrase</replaceable>
  8246. </note>
  8247. Aside from the
  8248. <filename>RPM_GPG_NAME</filename> and
  8249. <filename>RPM_GPG_PASSPHRASE</filename> variables in the
  8250. previous example, two optional variables related to signing
  8251. exist:
  8252. <itemizedlist>
  8253. <listitem><para>
  8254. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  8255. Specifies a <filename>gpg</filename> binary/wrapper
  8256. that is executed when the package is signed.
  8257. </para></listitem>
  8258. <listitem><para>
  8259. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  8260. Specifies the <filename>gpg</filename> home
  8261. directory used when the package is signed.
  8262. </para></listitem>
  8263. </itemizedlist>
  8264. </para>
  8265. </section>
  8266. <section id='processing-package-feeds'>
  8267. <title>Processing Package Feeds</title>
  8268. <para>
  8269. In addition to being able to sign RPM packages, you can
  8270. also enable the OpenEmbedded build system to be able to
  8271. handle previously signed package feeds for IPK
  8272. packages.
  8273. <note>
  8274. The OpenEmbedded build system does not currently
  8275. support signed DPKG or RPM package feeds.
  8276. </note>
  8277. The steps you need to take to enable signed package feed
  8278. use are similar to the steps used to sign RPM packages.
  8279. You must define the following in your
  8280. <filename>local.config</filename> or
  8281. <filename>distro.config</filename> file:
  8282. <literallayout class='monospaced'>
  8283. INHERIT += "sign_package_feed"
  8284. PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>"
  8285. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>"
  8286. </literallayout>
  8287. For signed package feeds, the passphrase must exist in a
  8288. separate file, which is pointed to by the
  8289. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  8290. variable.
  8291. Regarding security, keeping a plain text passphrase out of
  8292. the configuration is more secure.
  8293. </para>
  8294. <para>
  8295. Aside from the
  8296. <filename>PACKAGE_FEED_GPG_NAME</filename> and
  8297. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  8298. variables, three optional variables related to signed
  8299. package feeds exist:
  8300. <itemizedlist>
  8301. <listitem><para>
  8302. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  8303. Specifies a <filename>gpg</filename> binary/wrapper
  8304. that is executed when the package is signed.
  8305. </para></listitem>
  8306. <listitem><para>
  8307. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  8308. Specifies the <filename>gpg</filename> home
  8309. directory used when the package is signed.
  8310. </para></listitem>
  8311. <listitem><para>
  8312. <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis>
  8313. Specifies the type of <filename>gpg</filename>
  8314. signature.
  8315. This variable applies only to RPM and IPK package
  8316. feeds.
  8317. Allowable values for the
  8318. <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>
  8319. are "ASC", which is the default and specifies ascii
  8320. armored, and "BIN", which specifies binary.
  8321. </para></listitem>
  8322. </itemizedlist>
  8323. </para>
  8324. </section>
  8325. </section>
  8326. <section id='testing-packages-with-ptest'>
  8327. <title>Testing Packages With ptest</title>
  8328. <para>
  8329. A Package Test (ptest) runs tests against packages built
  8330. by the OpenEmbedded build system on the target machine.
  8331. A ptest contains at least two items: the actual test, and
  8332. a shell script (<filename>run-ptest</filename>) that starts
  8333. the test.
  8334. The shell script that starts the test must not contain
  8335. the actual test - the script only starts the test.
  8336. On the other hand, the test can be anything from a simple
  8337. shell script that runs a binary and checks the output to
  8338. an elaborate system of test binaries and data files.
  8339. </para>
  8340. <para>
  8341. The test generates output in the format used by
  8342. Automake:
  8343. <literallayout class='monospaced'>
  8344. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  8345. </literallayout>
  8346. where the result can be <filename>PASS</filename>,
  8347. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  8348. and the testname can be any identifying string.
  8349. </para>
  8350. <para>
  8351. For a list of Yocto Project recipes that are already
  8352. enabled with ptest, see the
  8353. <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink>
  8354. wiki page.
  8355. <note>
  8356. A recipe is "ptest-enabled" if it inherits the
  8357. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  8358. class.
  8359. </note>
  8360. </para>
  8361. <section id='adding-ptest-to-your-build'>
  8362. <title>Adding ptest to Your Build</title>
  8363. <para>
  8364. To add package testing to your build, add the
  8365. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  8366. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  8367. variables to your <filename>local.conf</filename> file,
  8368. which is found in the
  8369. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8370. <literallayout class='monospaced'>
  8371. DISTRO_FEATURES_append = " ptest"
  8372. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  8373. </literallayout>
  8374. Once your build is complete, the ptest files are installed
  8375. into the
  8376. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  8377. directory within the image, where
  8378. <filename><replaceable>package</replaceable></filename>
  8379. is the name of the package.
  8380. </para>
  8381. </section>
  8382. <section id='running-ptest'>
  8383. <title>Running ptest</title>
  8384. <para>
  8385. The <filename>ptest-runner</filename> package installs a
  8386. shell script that loops through all installed ptest test
  8387. suites and runs them in sequence.
  8388. Consequently, you might want to add this package to
  8389. your image.
  8390. </para>
  8391. </section>
  8392. <section id='getting-your-package-ready'>
  8393. <title>Getting Your Package Ready</title>
  8394. <para>
  8395. In order to enable a recipe to run installed ptests
  8396. on target hardware,
  8397. you need to prepare the recipes that build the packages
  8398. you want to test.
  8399. Here is what you have to do for each recipe:
  8400. <itemizedlist>
  8401. <listitem><para><emphasis>Be sure the recipe
  8402. inherits the
  8403. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  8404. class:</emphasis>
  8405. Include the following line in each recipe:
  8406. <literallayout class='monospaced'>
  8407. inherit ptest
  8408. </literallayout>
  8409. </para></listitem>
  8410. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  8411. This script starts your test.
  8412. Locate the script where you will refer to it
  8413. using
  8414. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  8415. Here is an example that starts a test for
  8416. <filename>dbus</filename>:
  8417. <literallayout class='monospaced'>
  8418. #!/bin/sh
  8419. cd test
  8420. make -k runtest-TESTS
  8421. </literallayout>
  8422. </para></listitem>
  8423. <listitem><para><emphasis>Ensure dependencies are
  8424. met:</emphasis>
  8425. If the test adds build or runtime dependencies
  8426. that normally do not exist for the package
  8427. (such as requiring "make" to run the test suite),
  8428. use the
  8429. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  8430. and
  8431. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  8432. variables in your recipe in order for the package
  8433. to meet the dependencies.
  8434. Here is an example where the package has a runtime
  8435. dependency on "make":
  8436. <literallayout class='monospaced'>
  8437. RDEPENDS_${PN}-ptest += "make"
  8438. </literallayout>
  8439. </para></listitem>
  8440. <listitem><para><emphasis>Add a function to build the
  8441. test suite:</emphasis>
  8442. Not many packages support cross-compilation of
  8443. their test suites.
  8444. Consequently, you usually need to add a
  8445. cross-compilation function to the package.
  8446. </para>
  8447. <para>Many packages based on Automake compile and
  8448. run the test suite by using a single command
  8449. such as <filename>make check</filename>.
  8450. However, the host <filename>make check</filename>
  8451. builds and runs on the same computer, while
  8452. cross-compiling requires that the package is built
  8453. on the host but executed for the target
  8454. architecture (though often, as in the case for
  8455. ptest, the execution occurs on the host).
  8456. The built version of Automake that ships with the
  8457. Yocto Project includes a patch that separates
  8458. building and execution.
  8459. Consequently, packages that use the unaltered,
  8460. patched version of <filename>make check</filename>
  8461. automatically cross-compiles.</para>
  8462. <para>Regardless, you still must add a
  8463. <filename>do_compile_ptest</filename> function to
  8464. build the test suite.
  8465. Add a function similar to the following to your
  8466. recipe:
  8467. <literallayout class='monospaced'>
  8468. do_compile_ptest() {
  8469. oe_runmake buildtest-TESTS
  8470. }
  8471. </literallayout>
  8472. </para></listitem>
  8473. <listitem><para><emphasis>Ensure special configurations
  8474. are set:</emphasis>
  8475. If the package requires special configurations
  8476. prior to compiling the test code, you must
  8477. insert a <filename>do_configure_ptest</filename>
  8478. function into the recipe.
  8479. </para></listitem>
  8480. <listitem><para><emphasis>Install the test
  8481. suite:</emphasis>
  8482. The <filename>ptest</filename> class
  8483. automatically copies the file
  8484. <filename>run-ptest</filename> to the target and
  8485. then runs make <filename>install-ptest</filename>
  8486. to run the tests.
  8487. If this is not enough, you need to create a
  8488. <filename>do_install_ptest</filename> function and
  8489. make sure it gets called after the
  8490. "make install-ptest" completes.
  8491. </para></listitem>
  8492. </itemizedlist>
  8493. </para>
  8494. </section>
  8495. </section>
  8496. </section>
  8497. <section id='working-with-source-files'>
  8498. <title>Working with Source Files</title>
  8499. <para>
  8500. The OpenEmbedded build system works with source files located
  8501. through the
  8502. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  8503. variable.
  8504. When you build something using BitBake, a big part of the operation
  8505. is locating and downloading all the source tarballs.
  8506. For images, downloading all the source for various packages can
  8507. take a significant amount of time.
  8508. </para>
  8509. <para>
  8510. This section presents information for working with source
  8511. files that can lead to more efficient use of resources and
  8512. time.
  8513. </para>
  8514. <section id='setting-up-effective-mirrors'>
  8515. <title>Setting up Effective Mirrors</title>
  8516. <para>
  8517. As mentioned, a good deal that goes into a Yocto Project
  8518. build is simply downloading all of the source tarballs.
  8519. Maybe you have been working with another build system
  8520. (OpenEmbedded or Angstrom) for which you have built up a
  8521. sizable directory of source tarballs.
  8522. Or, perhaps someone else has such a directory for which you
  8523. have read access.
  8524. If so, you can save time by adding statements to your
  8525. configuration file so that the build process checks local
  8526. directories first for existing tarballs before checking the
  8527. Internet.
  8528. </para>
  8529. <para>
  8530. Here is an efficient way to set it up in your
  8531. <filename>local.conf</filename> file:
  8532. <literallayout class='monospaced'>
  8533. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  8534. INHERIT += "own-mirrors"
  8535. BB_GENERATE_MIRROR_TARBALLS = "1"
  8536. # BB_NO_NETWORK = "1"
  8537. </literallayout>
  8538. </para>
  8539. <para>
  8540. In the previous example, the
  8541. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  8542. variable causes the OpenEmbedded build system to generate
  8543. tarballs of the Git repositories and store them in the
  8544. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  8545. directory.
  8546. Due to performance reasons, generating and storing these
  8547. tarballs is not the build system's default behavior.
  8548. </para>
  8549. <para>
  8550. You can also use the
  8551. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  8552. variable.
  8553. For an example, see the variable's glossary entry in the
  8554. Yocto Project Reference Manual.
  8555. </para>
  8556. </section>
  8557. <section id='getting-source-files-and-suppressing-the-build'>
  8558. <title>Getting Source Files and Suppressing the Build</title>
  8559. <para>
  8560. Another technique you can use to ready yourself for a
  8561. successive string of build operations, is to pre-fetch
  8562. all the source files without actually starting a build.
  8563. This technique lets you work through any download issues
  8564. and ultimately gathers all the source files into your
  8565. download directory
  8566. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  8567. which is located with
  8568. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  8569. </para>
  8570. <para>
  8571. Use the following BitBake command form to fetch all the
  8572. necessary sources without starting the build:
  8573. <literallayout class='monospaced'>
  8574. $ bitbake -c fetchall <replaceable>target</replaceable>
  8575. </literallayout>
  8576. This variation of the BitBake command guarantees that you
  8577. have all the sources for that BitBake target should you
  8578. disconnect from the Internet and want to do the build
  8579. later offline.
  8580. </para>
  8581. </section>
  8582. </section>
  8583. <section id="building-software-from-an-external-source">
  8584. <title>Building Software from an External Source</title>
  8585. <para>
  8586. By default, the OpenEmbedded build system uses the
  8587. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8588. when building source code.
  8589. The build process involves fetching the source files, unpacking
  8590. them, and then patching them if necessary before the build takes
  8591. place.
  8592. </para>
  8593. <para>
  8594. Situations exist where you might want to build software from source
  8595. files that are external to and thus outside of the
  8596. OpenEmbedded build system.
  8597. For example, suppose you have a project that includes a new BSP with
  8598. a heavily customized kernel.
  8599. And, you want to minimize exposing the build system to the
  8600. development team so that they can focus on their project and
  8601. maintain everyone's workflow as much as possible.
  8602. In this case, you want a kernel source directory on the development
  8603. machine where the development occurs.
  8604. You want the recipe's
  8605. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  8606. variable to point to the external directory and use it as is, not
  8607. copy it.
  8608. </para>
  8609. <para>
  8610. To build from software that comes from an external source, all you
  8611. need to do is inherit the
  8612. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  8613. class and then set the
  8614. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>
  8615. variable to point to your external source code.
  8616. Here are the statements to put in your
  8617. <filename>local.conf</filename> file:
  8618. <literallayout class='monospaced'>
  8619. INHERIT += "externalsrc"
  8620. EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  8621. </literallayout>
  8622. </para>
  8623. <para>
  8624. This next example shows how to accomplish the same thing by setting
  8625. <filename>EXTERNALSRC</filename> in the recipe itself or in the
  8626. recipe's append file:
  8627. <literallayout class='monospaced'>
  8628. EXTERNALSRC = "<replaceable>path</replaceable>"
  8629. EXTERNALSRC_BUILD = "<replaceable>path</replaceable>"
  8630. </literallayout>
  8631. <note>
  8632. In order for these settings to take effect, you must globally
  8633. or locally inherit the
  8634. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  8635. class.
  8636. </note>
  8637. </para>
  8638. <para>
  8639. By default, <filename>externalsrc.bbclass</filename> builds
  8640. the source code in a directory separate from the external source
  8641. directory as specified by
  8642. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>.
  8643. If you need to have the source built in the same directory in
  8644. which it resides, or some other nominated directory, you can set
  8645. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink>
  8646. to point to that directory:
  8647. <literallayout class='monospaced'>
  8648. EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  8649. </literallayout>
  8650. </para>
  8651. </section>
  8652. <section id="selecting-an-initialization-manager">
  8653. <title>Selecting an Initialization Manager</title>
  8654. <para>
  8655. By default, the Yocto Project uses SysVinit as the initialization
  8656. manager.
  8657. However, support also exists for systemd,
  8658. which is a full replacement for init with
  8659. parallel starting of services, reduced shell overhead and other
  8660. features that are used by many distributions.
  8661. </para>
  8662. <para>
  8663. If you want to use SysVinit, you do
  8664. not have to do anything.
  8665. But, if you want to use systemd, you must
  8666. take some steps as described in the following sections.
  8667. </para>
  8668. <section id='using-systemd-exclusively'>
  8669. <title>Using systemd Exclusively</title>
  8670. <para>
  8671. Set the these variables in your distribution configuration
  8672. file as follows:
  8673. <literallayout class='monospaced'>
  8674. DISTRO_FEATURES_append = " systemd"
  8675. VIRTUAL-RUNTIME_init_manager = "systemd"
  8676. </literallayout>
  8677. You can also prevent the SysVinit
  8678. distribution feature from
  8679. being automatically enabled as follows:
  8680. <literallayout class='monospaced'>
  8681. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  8682. </literallayout>
  8683. Doing so removes any redundant SysVinit scripts.
  8684. </para>
  8685. <para>
  8686. To remove initscripts from your image altogether,
  8687. set this variable also:
  8688. <literallayout class='monospaced'>
  8689. VIRTUAL-RUNTIME_initscripts = ""
  8690. </literallayout>
  8691. </para>
  8692. <para>
  8693. For information on the backfill variable, see
  8694. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  8695. </para>
  8696. </section>
  8697. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  8698. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  8699. <para>
  8700. Set these variables in your distribution configuration
  8701. file as follows:
  8702. <literallayout class='monospaced'>
  8703. DISTRO_FEATURES_append = " systemd"
  8704. VIRTUAL-RUNTIME_init_manager = "systemd"
  8705. </literallayout>
  8706. Doing so causes your main image to use the
  8707. <filename>packagegroup-core-boot.bb</filename> recipe and
  8708. systemd.
  8709. The rescue/minimal image cannot use this package group.
  8710. However, it can install SysVinit
  8711. and the appropriate packages will have support for both
  8712. systemd and SysVinit.
  8713. </para>
  8714. </section>
  8715. </section>
  8716. <section id="selecting-dev-manager">
  8717. <title>Selecting a Device Manager</title>
  8718. <para>
  8719. The Yocto Project provides multiple ways to manage the device
  8720. manager (<filename>/dev</filename>):
  8721. <itemizedlist>
  8722. <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis>
  8723. For this case, the <filename>/dev</filename> directory
  8724. is persistent and the required device nodes are created
  8725. during the build.
  8726. </para></listitem>
  8727. <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis>
  8728. For this case, the <filename>/dev</filename> directory
  8729. is provided by the kernel as an in-memory file system and
  8730. is automatically populated by the kernel at runtime.
  8731. Additional configuration of device nodes is done in user
  8732. space by a device manager like
  8733. <filename>udev</filename> or
  8734. <filename>busybox-mdev</filename>.
  8735. </para></listitem>
  8736. </itemizedlist>
  8737. </para>
  8738. <section id="static-dev-management">
  8739. <title>Using Persistent and Pre-Populated<filename>/dev</filename></title>
  8740. <para>
  8741. To use the static method for device population, you need to
  8742. set the
  8743. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  8744. variable to "0" as follows:
  8745. <literallayout class='monospaced'>
  8746. USE_DEVFS = "0"
  8747. </literallayout>
  8748. </para>
  8749. <para>
  8750. The content of the resulting <filename>/dev</filename>
  8751. directory is defined in a Device Table file.
  8752. The
  8753. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink>
  8754. variable defines the Device Table to use and should be set
  8755. in the machine or distro configuration file.
  8756. Alternatively, you can set this variable in your
  8757. <filename>local.conf</filename> configuration file.
  8758. </para>
  8759. <para>
  8760. If you do not define the
  8761. <filename>IMAGE_DEVICE_TABLES</filename> variable, the default
  8762. <filename>device_table-minimal.txt</filename> is used:
  8763. <literallayout class='monospaced'>
  8764. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  8765. </literallayout>
  8766. </para>
  8767. <para>
  8768. The population is handled by the <filename>makedevs</filename>
  8769. utility during image creation:
  8770. </para>
  8771. </section>
  8772. <section id="devtmpfs-dev-management">
  8773. <title>Using <filename>devtmpfs</filename> and a Device Manager</title>
  8774. <para>
  8775. To use the dynamic method for device population, you need to
  8776. use (or be sure to set) the
  8777. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  8778. variable to "1", which is the default:
  8779. <literallayout class='monospaced'>
  8780. USE_DEVFS = "1"
  8781. </literallayout>
  8782. With this setting, the resulting <filename>/dev</filename>
  8783. directory is populated by the kernel using
  8784. <filename>devtmpfs</filename>.
  8785. Make sure the corresponding kernel configuration variable
  8786. <filename>CONFIG_DEVTMPFS</filename> is set when building
  8787. you build a Linux kernel.
  8788. </para>
  8789. <para>
  8790. All devices created by <filename>devtmpfs</filename> will be
  8791. owned by <filename>root</filename> and have permissions
  8792. <filename>0600</filename>.
  8793. </para>
  8794. <para>
  8795. To have more control over the device nodes, you can use a
  8796. device manager like <filename>udev</filename> or
  8797. <filename>busybox-mdev</filename>.
  8798. You choose the device manager by defining the
  8799. <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable
  8800. in your machine or distro configuration file.
  8801. Alternatively, you can set this variable in your
  8802. <filename>local.conf</filename> configuration file:
  8803. <literallayout class='monospaced'>
  8804. VIRTUAL-RUNTIME_dev_manager = "udev"
  8805. # Some alternative values
  8806. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  8807. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  8808. </literallayout>
  8809. </para>
  8810. </section>
  8811. </section>
  8812. <section id="platdev-appdev-srcrev">
  8813. <title>Using an External SCM</title>
  8814. <para>
  8815. If you're working on a recipe that pulls from an external Source
  8816. Code Manager (SCM), it is possible to have the OpenEmbedded build
  8817. system notice new recipe changes added to the SCM and then build
  8818. the resulting packages that depend on the new recipes by using
  8819. the latest versions.
  8820. This only works for SCMs from which it is possible to get a
  8821. sensible revision number for changes.
  8822. Currently, you can do this with Apache Subversion (SVN), Git, and
  8823. Bazaar (BZR) repositories.
  8824. </para>
  8825. <para>
  8826. To enable this behavior, the
  8827. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  8828. of the recipe needs to reference
  8829. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  8830. Here is an example:
  8831. <literallayout class='monospaced'>
  8832. PV = "1.2.3+git${SRCPV}"
  8833. </literallayout>
  8834. Then, you can add the following to your
  8835. <filename>local.conf</filename>:
  8836. <literallayout class='monospaced'>
  8837. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  8838. </literallayout>
  8839. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  8840. is the name of the recipe for which you want to enable automatic source
  8841. revision updating.
  8842. </para>
  8843. <para>
  8844. If you do not want to update your local configuration file, you can
  8845. add the following directly to the recipe to finish enabling
  8846. the feature:
  8847. <literallayout class='monospaced'>
  8848. SRCREV = "${AUTOREV}"
  8849. </literallayout>
  8850. </para>
  8851. <para>
  8852. The Yocto Project provides a distribution named
  8853. <filename>poky-bleeding</filename>, whose configuration
  8854. file contains the line:
  8855. <literallayout class='monospaced'>
  8856. require conf/distro/include/poky-floating-revisions.inc
  8857. </literallayout>
  8858. This line pulls in the listed include file that contains
  8859. numerous lines of exactly that form:
  8860. <literallayout class='monospaced'>
  8861. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  8862. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  8863. #SRCREV_pn-opkg ?= "${AUTOREV}"
  8864. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  8865. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  8866. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  8867. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  8868. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  8869. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  8870. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  8871. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  8872. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  8873. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  8874. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  8875. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  8876. SRCREV_pn-screenshot ?= "${AUTOREV}"
  8877. .
  8878. .
  8879. .
  8880. </literallayout>
  8881. These lines allow you to experiment with building a
  8882. distribution that tracks the latest development source
  8883. for numerous packages.
  8884. <note><title>Caution</title>
  8885. The <filename>poky-bleeding</filename> distribution
  8886. is not tested on a regular basis.
  8887. Keep this in mind if you use it.
  8888. </note>
  8889. </para>
  8890. </section>
  8891. <section id='creating-a-read-only-root-filesystem'>
  8892. <title>Creating a Read-Only Root Filesystem</title>
  8893. <para>
  8894. Suppose, for security reasons, you need to disable
  8895. your target device's root filesystem's write permissions
  8896. (i.e. you need a read-only root filesystem).
  8897. Or, perhaps you are running the device's operating system
  8898. from a read-only storage device.
  8899. For either case, you can customize your image for
  8900. that behavior.
  8901. </para>
  8902. <note>
  8903. Supporting a read-only root filesystem requires that the system and
  8904. applications do not try to write to the root filesystem.
  8905. You must configure all parts of the target system to write
  8906. elsewhere, or to gracefully fail in the event of attempting to
  8907. write to the root filesystem.
  8908. </note>
  8909. <section id='creating-the-root-filesystem'>
  8910. <title>Creating the Root Filesystem</title>
  8911. <para>
  8912. To create the read-only root filesystem, simply add the
  8913. "read-only-rootfs" feature to your image.
  8914. Using either of the following statements in your
  8915. image recipe or from within the
  8916. <filename>local.conf</filename> file found in the
  8917. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8918. causes the build system to create a read-only root filesystem:
  8919. <literallayout class='monospaced'>
  8920. IMAGE_FEATURES = "read-only-rootfs"
  8921. </literallayout>
  8922. or
  8923. <literallayout class='monospaced'>
  8924. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  8925. </literallayout>
  8926. </para>
  8927. <para>
  8928. For more information on how to use these variables, see the
  8929. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  8930. section.
  8931. For information on the variables, see
  8932. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  8933. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  8934. </para>
  8935. </section>
  8936. <section id='post-installation-scripts'>
  8937. <title>Post-Installation Scripts</title>
  8938. <para>
  8939. It is very important that you make sure all
  8940. post-Installation (<filename>pkg_postinst</filename>) scripts
  8941. for packages that are installed into the image can be run
  8942. at the time when the root filesystem is created during the
  8943. build on the host system.
  8944. These scripts cannot attempt to run during first-boot on the
  8945. target device.
  8946. With the "read-only-rootfs" feature enabled,
  8947. the build system checks during root filesystem creation to make
  8948. sure all post-installation scripts succeed.
  8949. If any of these scripts still need to be run after the root
  8950. filesystem is created, the build immediately fails.
  8951. These build-time checks ensure that the build fails
  8952. rather than the target device fails later during its
  8953. initial boot operation.
  8954. </para>
  8955. <para>
  8956. Most of the common post-installation scripts generated by the
  8957. build system for the out-of-the-box Yocto Project are engineered
  8958. so that they can run during root filesystem creation
  8959. (e.g. post-installation scripts for caching fonts).
  8960. However, if you create and add custom scripts, you need
  8961. to be sure they can be run during this file system creation.
  8962. </para>
  8963. <para>
  8964. Here are some common problems that prevent
  8965. post-installation scripts from running during root filesystem
  8966. creation:
  8967. <itemizedlist>
  8968. <listitem><para>
  8969. <emphasis>Not using $D in front of absolute
  8970. paths:</emphasis>
  8971. The build system defines
  8972. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  8973. when the root filesystem is created.
  8974. Furthermore, <filename>$D</filename> is blank when the
  8975. script is run on the target device.
  8976. This implies two purposes for <filename>$D</filename>:
  8977. ensuring paths are valid in both the host and target
  8978. environments, and checking to determine which
  8979. environment is being used as a method for taking
  8980. appropriate actions.
  8981. </para></listitem>
  8982. <listitem><para>
  8983. <emphasis>Attempting to run processes that are
  8984. specific to or dependent on the target
  8985. architecture:</emphasis>
  8986. You can work around these attempts by using native
  8987. tools, which run on the host system,
  8988. to accomplish the same tasks, or
  8989. by alternatively running the processes under QEMU,
  8990. which has the <filename>qemu_run_binary</filename>
  8991. function.
  8992. For more information, see the
  8993. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  8994. class.</para></listitem>
  8995. </itemizedlist>
  8996. </para>
  8997. </section>
  8998. <section id='areas-with-write-access'>
  8999. <title>Areas With Write Access</title>
  9000. <para>
  9001. With the "read-only-rootfs" feature enabled,
  9002. any attempt by the target to write to the root filesystem at
  9003. runtime fails.
  9004. Consequently, you must make sure that you configure processes
  9005. and applications that attempt these types of writes do so
  9006. to directories with write access (e.g.
  9007. <filename>/tmp</filename> or <filename>/var/run</filename>).
  9008. </para>
  9009. </section>
  9010. </section>
  9011. <section id="performing-automated-runtime-testing">
  9012. <title>Performing Automated Runtime Testing</title>
  9013. <para>
  9014. The OpenEmbedded build system makes available a series of automated
  9015. tests for images to verify runtime functionality.
  9016. You can run these tests on either QEMU or actual target hardware.
  9017. Tests are written in Python making use of the
  9018. <filename>unittest</filename> module, and the majority of them
  9019. run commands on the target system over SSH.
  9020. This section describes how you set up the environment to use these
  9021. tests, run available tests, and write and add your own tests.
  9022. </para>
  9023. <para>
  9024. For information on the test and QA infrastructure available
  9025. within the Yocto Project, see the
  9026. "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>"
  9027. section in the Yocto Project Reference Manual.
  9028. </para>
  9029. <section id='enabling-tests'>
  9030. <title>Enabling Tests</title>
  9031. <para>
  9032. Depending on whether you are planning to run tests using
  9033. QEMU or on the hardware, you have to take
  9034. different steps to enable the tests.
  9035. See the following subsections for information on how to
  9036. enable both types of tests.
  9037. </para>
  9038. <section id='qemu-image-enabling-tests'>
  9039. <title>Enabling Runtime Tests on QEMU</title>
  9040. <para>
  9041. In order to run tests, you need to do the following:
  9042. <itemizedlist>
  9043. <listitem><para><emphasis>Set up to avoid interaction
  9044. with <filename>sudo</filename> for networking:</emphasis>
  9045. To accomplish this, you must do one of the
  9046. following:
  9047. <itemizedlist>
  9048. <listitem><para>Add
  9049. <filename>NOPASSWD</filename> for your user
  9050. in <filename>/etc/sudoers</filename> either for
  9051. all commands or just for
  9052. <filename>runqemu-ifup</filename>.
  9053. You must provide the full path as that can
  9054. change if you are using multiple clones of the
  9055. source repository.
  9056. <note>
  9057. On some distributions, you also need to
  9058. comment out "Defaults requiretty" in
  9059. <filename>/etc/sudoers</filename>.
  9060. </note></para></listitem>
  9061. <listitem><para>Manually configure a tap interface
  9062. for your system.</para></listitem>
  9063. <listitem><para>Run as root the script in
  9064. <filename>scripts/runqemu-gen-tapdevs</filename>,
  9065. which should generate a list of tap devices.
  9066. This is the option typically chosen for
  9067. Autobuilder-type environments.
  9068. </para></listitem>
  9069. </itemizedlist></para></listitem>
  9070. <listitem><para><emphasis>Set the
  9071. <filename>DISPLAY</filename> variable:</emphasis>
  9072. You need to set this variable so that you have an X
  9073. server available (e.g. start
  9074. <filename>vncserver</filename> for a headless machine).
  9075. </para></listitem>
  9076. <listitem><para><emphasis>Be sure your host's firewall
  9077. accepts incoming connections from
  9078. 192.168.7.0/24:</emphasis>
  9079. Some of the tests (in particular DNF tests) start
  9080. an HTTP server on a random high number port,
  9081. which is used to serve files to the target.
  9082. The DNF module serves
  9083. <filename>${WORKDIR}/oe-rootfs-repo</filename>
  9084. so it can run DNF channel commands.
  9085. That means your host's firewall
  9086. must accept incoming connections from 192.168.7.0/24,
  9087. which is the default IP range used for tap devices
  9088. by <filename>runqemu</filename>.</para></listitem>
  9089. <listitem><para><emphasis>Be sure your host has the
  9090. correct packages installed:</emphasis>
  9091. Depending your host's distribution, you need
  9092. to have the following packages installed:
  9093. <itemizedlist>
  9094. <listitem><para>Ubuntu and Debian:
  9095. <filename>sysstat</filename> and
  9096. <filename>iproute2</filename>
  9097. </para></listitem>
  9098. <listitem><para>OpenSUSE:
  9099. <filename>sysstat</filename> and
  9100. <filename>iproute2</filename>
  9101. </para></listitem>
  9102. <listitem><para>Fedora:
  9103. <filename>sysstat</filename> and
  9104. <filename>iproute</filename>
  9105. </para></listitem>
  9106. <listitem><para>CentOS:
  9107. <filename>sysstat</filename> and
  9108. <filename>iproute</filename>
  9109. </para></listitem>
  9110. </itemizedlist>
  9111. </para></listitem>
  9112. </itemizedlist>
  9113. </para>
  9114. <para>
  9115. Once you start running the tests, the following happens:
  9116. <orderedlist>
  9117. <listitem><para>A copy of the root filesystem is written
  9118. to <filename>${WORKDIR}/testimage</filename>.
  9119. </para></listitem>
  9120. <listitem><para>The image is booted under QEMU using the
  9121. standard <filename>runqemu</filename> script.
  9122. </para></listitem>
  9123. <listitem><para>A default timeout of 500 seconds occurs
  9124. to allow for the boot process to reach the login prompt.
  9125. You can change the timeout period by setting
  9126. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  9127. in the <filename>local.conf</filename> file.
  9128. </para></listitem>
  9129. <listitem><para>Once the boot process is reached and the
  9130. login prompt appears, the tests run.
  9131. The full boot log is written to
  9132. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  9133. </para></listitem>
  9134. <listitem><para>Each test module loads in the order found
  9135. in <filename>TEST_SUITES</filename>.
  9136. You can find the full output of the commands run over
  9137. SSH in
  9138. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  9139. </para></listitem>
  9140. <listitem><para>If no failures occur, the task running the
  9141. tests ends successfully.
  9142. You can find the output from the
  9143. <filename>unittest</filename> in the task log at
  9144. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  9145. </para></listitem>
  9146. </orderedlist>
  9147. </para>
  9148. </section>
  9149. <section id='hardware-image-enabling-tests'>
  9150. <title>Enabling Runtime Tests on Hardware</title>
  9151. <para>
  9152. The OpenEmbedded build system can run tests on real
  9153. hardware, and for certain devices it can also deploy
  9154. the image to be tested onto the device beforehand.
  9155. </para>
  9156. <para>
  9157. For automated deployment, a "master image" is installed
  9158. onto the hardware once as part of setup.
  9159. Then, each time tests are to be run, the following
  9160. occurs:
  9161. <orderedlist>
  9162. <listitem><para>The master image is booted into and
  9163. used to write the image to be tested to
  9164. a second partition.
  9165. </para></listitem>
  9166. <listitem><para>The device is then rebooted using an
  9167. external script that you need to provide.
  9168. </para></listitem>
  9169. <listitem><para>The device boots into the image to be
  9170. tested.
  9171. </para></listitem>
  9172. </orderedlist>
  9173. </para>
  9174. <para>
  9175. When running tests (independent of whether the image
  9176. has been deployed automatically or not), the device is
  9177. expected to be connected to a network on a
  9178. pre-determined IP address.
  9179. You can either use static IP addresses written into
  9180. the image, or set the image to use DHCP and have your
  9181. DHCP server on the test network assign a known IP address
  9182. based on the MAC address of the device.
  9183. </para>
  9184. <para>
  9185. In order to run tests on hardware, you need to set
  9186. <filename>TEST_TARGET</filename> to an appropriate value.
  9187. For QEMU, you do not have to change anything, the default
  9188. value is "QemuTarget".
  9189. For running tests on hardware, the following options exist:
  9190. <itemizedlist>
  9191. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  9192. Choose "SimpleRemoteTarget" if you are going to
  9193. run tests on a target system that is already
  9194. running the image to be tested and is available
  9195. on the network.
  9196. You can use "SimpleRemoteTarget" in conjunction
  9197. with either real hardware or an image running
  9198. within a separately started QEMU or any
  9199. other virtual machine manager.
  9200. </para></listitem>
  9201. <listitem><para><emphasis>"Systemd-bootTarget":</emphasis>
  9202. Choose "Systemd-bootTarget" if your hardware is
  9203. an EFI-based machine with
  9204. <filename>systemd-boot</filename> as bootloader and
  9205. <filename>core-image-testmaster</filename>
  9206. (or something similar) is installed.
  9207. Also, your hardware under test must be in a
  9208. DHCP-enabled network that gives it the same IP
  9209. address for each reboot.</para>
  9210. <para>If you choose "Systemd-bootTarget", there are
  9211. additional requirements and considerations.
  9212. See the
  9213. "<link linkend='selecting-systemd-boottarget'>Selecting Systemd-bootTarget</link>"
  9214. section, which follows, for more information.
  9215. </para></listitem>
  9216. <listitem><para><emphasis>"BeagleBoneTarget":</emphasis>
  9217. Choose "BeagleBoneTarget" if you are deploying
  9218. images and running tests on the BeagleBone
  9219. "Black" or original "White" hardware.
  9220. For information on how to use these tests, see the
  9221. comments at the top of the BeagleBoneTarget
  9222. <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename>
  9223. file.
  9224. </para></listitem>
  9225. <listitem><para><emphasis>"EdgeRouterTarget":</emphasis>
  9226. Choose "EdgeRouterTarget" is you are deploying
  9227. images and running tests on the Ubiquiti Networks
  9228. EdgeRouter Lite.
  9229. For information on how to use these tests, see the
  9230. comments at the top of the EdgeRouterTarget
  9231. <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename>
  9232. file.
  9233. </para></listitem>
  9234. <listitem><para><emphasis>"GrubTarget":</emphasis>
  9235. Choose the "supports deploying images and running
  9236. tests on any generic PC that boots using GRUB.
  9237. For information on how to use these tests, see the
  9238. comments at the top of the GrubTarget
  9239. <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename>
  9240. file.
  9241. </para></listitem>
  9242. <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis>
  9243. Create your own custom target if you want to run
  9244. tests when you are deploying images and running
  9245. tests on a custom machine within your BSP layer.
  9246. To do this, you need to add a Python unit that
  9247. defines the target class under
  9248. <filename>lib/oeqa/controllers/</filename> within
  9249. your layer.
  9250. You must also provide an empty
  9251. <filename>__init__.py</filename>.
  9252. For examples, see files in
  9253. <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>.
  9254. </para></listitem>
  9255. </itemizedlist>
  9256. </para>
  9257. </section>
  9258. <section id='selecting-systemd-boottarget'>
  9259. <title>Selecting Systemd-bootTarget</title>
  9260. <para>
  9261. If you did not set <filename>TEST_TARGET</filename> to
  9262. "Systemd-bootTarget", then you do not need any information
  9263. in this section.
  9264. You can skip down to the
  9265. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  9266. section.
  9267. </para>
  9268. <para>
  9269. If you did set <filename>TEST_TARGET</filename> to
  9270. "Systemd-bootTarget", you also need to perform a one-time
  9271. setup of your master image by doing the following:
  9272. <orderedlist>
  9273. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  9274. Be sure that <filename>EFI_PROVIDER</filename>
  9275. is as follows:
  9276. <literallayout class='monospaced'>
  9277. EFI_PROVIDER = "systemd-boot"
  9278. </literallayout>
  9279. </para></listitem>
  9280. <listitem><para><emphasis>Build the master image:</emphasis>
  9281. Build the <filename>core-image-testmaster</filename>
  9282. image.
  9283. The <filename>core-image-testmaster</filename>
  9284. recipe is provided as an example for a
  9285. "master" image and you can customize the image
  9286. recipe as you would any other recipe.
  9287. </para>
  9288. <para>Here are the image recipe requirements:
  9289. <itemizedlist>
  9290. <listitem><para>Inherits
  9291. <filename>core-image</filename>
  9292. so that kernel modules are installed.
  9293. </para></listitem>
  9294. <listitem><para>Installs normal linux utilities
  9295. not busybox ones (e.g.
  9296. <filename>bash</filename>,
  9297. <filename>coreutils</filename>,
  9298. <filename>tar</filename>,
  9299. <filename>gzip</filename>, and
  9300. <filename>kmod</filename>).
  9301. </para></listitem>
  9302. <listitem><para>Uses a custom
  9303. Initial RAM Disk (initramfs) image with a
  9304. custom installer.
  9305. A normal image that you can install usually
  9306. creates a single rootfs partition.
  9307. This image uses another installer that
  9308. creates a specific partition layout.
  9309. Not all Board Support Packages (BSPs)
  9310. can use an installer.
  9311. For such cases, you need to manually create
  9312. the following partition layout on the
  9313. target:
  9314. <itemizedlist>
  9315. <listitem><para>First partition mounted
  9316. under <filename>/boot</filename>,
  9317. labeled "boot".
  9318. </para></listitem>
  9319. <listitem><para>The main rootfs
  9320. partition where this image gets
  9321. installed, which is mounted under
  9322. <filename>/</filename>.
  9323. </para></listitem>
  9324. <listitem><para>Another partition
  9325. labeled "testrootfs" where test
  9326. images get deployed.
  9327. </para></listitem>
  9328. </itemizedlist>
  9329. </para></listitem>
  9330. </itemizedlist>
  9331. </para></listitem>
  9332. <listitem><para><emphasis>Install image:</emphasis>
  9333. Install the image that you just built on the target
  9334. system.
  9335. </para></listitem>
  9336. </orderedlist>
  9337. </para>
  9338. <para>
  9339. The final thing you need to do when setting
  9340. <filename>TEST_TARGET</filename> to "Systemd-bootTarget" is
  9341. to set up the test image:
  9342. <orderedlist>
  9343. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  9344. Make sure you have the following statements in
  9345. your <filename>local.conf</filename> file:
  9346. <literallayout class='monospaced'>
  9347. IMAGE_FSTYPES += "tar.gz"
  9348. INHERIT += "testimage"
  9349. TEST_TARGET = "Systemd-bootTarget"
  9350. TEST_TARGET_IP = "192.168.2.3"
  9351. </literallayout>
  9352. </para></listitem>
  9353. <listitem><para><emphasis>Build your test image:</emphasis>
  9354. Use BitBake to build the image:
  9355. <literallayout class='monospaced'>
  9356. $ bitbake core-image-sato
  9357. </literallayout>
  9358. </para></listitem>
  9359. </orderedlist>
  9360. </para>
  9361. </section>
  9362. <section id='power-control'>
  9363. <title>Power Control</title>
  9364. <para>
  9365. For most hardware targets other than SimpleRemoteTarget,
  9366. you can control power:
  9367. <itemizedlist>
  9368. <listitem><para>
  9369. You can use
  9370. <filename>TEST_POWERCONTROL_CMD</filename>
  9371. together with
  9372. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  9373. as a command that runs on the host and does power
  9374. cycling.
  9375. The test code passes one argument to that command:
  9376. off, on or cycle (off then on).
  9377. Here is an example that could appear in your
  9378. <filename>local.conf</filename> file:
  9379. <literallayout class='monospaced'>
  9380. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  9381. </literallayout>
  9382. In this example, the expect script does the
  9383. following:
  9384. <literallayout class='monospaced'>
  9385. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  9386. </literallayout>
  9387. It then runs a Python script that controls power
  9388. for a label called <filename>nuc1</filename>.
  9389. <note>
  9390. You need to customize
  9391. <filename>TEST_POWERCONTROL_CMD</filename>
  9392. and
  9393. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  9394. for your own setup.
  9395. The one requirement is that it accepts
  9396. "on", "off", and "cycle" as the last argument.
  9397. </note>
  9398. </para></listitem>
  9399. <listitem><para>
  9400. When no command is defined, it connects to the
  9401. device over SSH and uses the classic reboot command
  9402. to reboot the device.
  9403. Classic reboot is fine as long as the machine
  9404. actually reboots (i.e. the SSH test has not
  9405. failed).
  9406. It is useful for scenarios where you have a simple
  9407. setup, typically with a single board, and where
  9408. some manual interaction is okay from time to time.
  9409. </para></listitem>
  9410. </itemizedlist>
  9411. If you have no hardware to automatically perform power
  9412. control but still wish to experiment with automated
  9413. hardware testing, you can use the dialog-power-control
  9414. script that shows a dialog prompting you to perform the
  9415. required power action.
  9416. This script requires either KDialog or Zenity to be
  9417. installed.
  9418. To use this script, set the
  9419. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink>
  9420. variable as follows:
  9421. <literallayout class='monospaced'>
  9422. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  9423. </literallayout>
  9424. </para>
  9425. </section>
  9426. <section id='serial-console-connection'>
  9427. <title>Serial Console Connection</title>
  9428. <para>
  9429. For test target classes requiring a serial console
  9430. to interact with the bootloader (e.g. BeagleBoneTarget,
  9431. EdgeRouterTarget, and GrubTarget), you need to
  9432. specify a command to use to connect to the serial console
  9433. of the target machine by using the
  9434. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink>
  9435. variable and optionally the
  9436. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink>
  9437. variable.
  9438. </para>
  9439. <para>
  9440. These cases could be a serial terminal program if the
  9441. machine is connected to a local serial port, or a
  9442. <filename>telnet</filename> or
  9443. <filename>ssh</filename> command connecting to a remote
  9444. console server.
  9445. Regardless of the case, the command simply needs to
  9446. connect to the serial console and forward that connection
  9447. to standard input and output as any normal terminal
  9448. program does.
  9449. For example, to use the picocom terminal program on
  9450. serial device <filename>/dev/ttyUSB0</filename>
  9451. at 115200bps, you would set the variable as follows:
  9452. <literallayout class='monospaced'>
  9453. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  9454. </literallayout>
  9455. For local devices where the serial port device disappears
  9456. when the device reboots, an additional "serdevtry" wrapper
  9457. script is provided.
  9458. To use this wrapper, simply prefix the terminal command
  9459. with
  9460. <filename>${COREBASE}/scripts/contrib/serdevtry</filename>:
  9461. <literallayout class='monospaced'>
  9462. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b
  9463. 115200 /dev/ttyUSB0"
  9464. </literallayout>
  9465. </para>
  9466. </section>
  9467. </section>
  9468. <section id="qemu-image-running-tests">
  9469. <title>Running Tests</title>
  9470. <para>
  9471. You can start the tests automatically or manually:
  9472. <itemizedlist>
  9473. <listitem><para><emphasis>Automatically running tests:</emphasis>
  9474. To run the tests automatically after the
  9475. OpenEmbedded build system successfully creates an image,
  9476. first set the
  9477. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink>
  9478. variable to "1" in your <filename>local.conf</filename>
  9479. file in the
  9480. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  9481. <literallayout class='monospaced'>
  9482. TEST_IMAGE = "1"
  9483. </literallayout>
  9484. Next, build your image.
  9485. If the image successfully builds, the tests will be
  9486. run:
  9487. <literallayout class='monospaced'>
  9488. bitbake core-image-sato
  9489. </literallayout></para></listitem>
  9490. <listitem><para><emphasis>Manually running tests:</emphasis>
  9491. To manually run the tests, first globally inherit the
  9492. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  9493. class by editing your <filename>local.conf</filename>
  9494. file:
  9495. <literallayout class='monospaced'>
  9496. INHERIT += "testimage"
  9497. </literallayout>
  9498. Next, use BitBake to run the tests:
  9499. <literallayout class='monospaced'>
  9500. bitbake -c testimage <replaceable>image</replaceable>
  9501. </literallayout></para></listitem>
  9502. </itemizedlist>
  9503. </para>
  9504. <para>
  9505. All test files reside in
  9506. <filename>meta/lib/oeqa/runtime</filename> in the
  9507. <link linkend='source-directory'>Source Directory</link>.
  9508. A test name maps directly to a Python module.
  9509. Each test module may contain a number of individual tests.
  9510. Tests are usually grouped together by the area
  9511. tested (e.g tests for systemd reside in
  9512. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  9513. </para>
  9514. <para>
  9515. You can add tests to any layer provided you place them in the
  9516. proper area and you extend
  9517. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  9518. in the <filename>local.conf</filename> file as normal.
  9519. Be sure that tests reside in
  9520. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  9521. <note>
  9522. Be sure that module names do not collide with module names
  9523. used in the default set of test modules in
  9524. <filename>meta/lib/oeqa/runtime</filename>.
  9525. </note>
  9526. </para>
  9527. <para>
  9528. You can change the set of tests run by appending or overriding
  9529. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  9530. variable in <filename>local.conf</filename>.
  9531. Each name in <filename>TEST_SUITES</filename> represents a
  9532. required test for the image.
  9533. Test modules named within <filename>TEST_SUITES</filename>
  9534. cannot be skipped even if a test is not suitable for an image
  9535. (e.g. running the RPM tests on an image without
  9536. <filename>rpm</filename>).
  9537. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  9538. build system to try to run all tests that are suitable for the
  9539. image (i.e. each test module may elect to skip itself).
  9540. </para>
  9541. <para>
  9542. The order you list tests in <filename>TEST_SUITES</filename>
  9543. is important and influences test dependencies.
  9544. Consequently, tests that depend on other tests should be added
  9545. after the test on which they depend.
  9546. For example, since the <filename>ssh</filename> test
  9547. depends on the
  9548. <filename>ping</filename> test, "ssh" needs to come after
  9549. "ping" in the list.
  9550. The test class provides no re-ordering or dependency handling.
  9551. <note>
  9552. Each module can have multiple classes with multiple test
  9553. methods.
  9554. And, Python <filename>unittest</filename> rules apply.
  9555. </note>
  9556. </para>
  9557. <para>
  9558. Here are some things to keep in mind when running tests:
  9559. <itemizedlist>
  9560. <listitem><para>The default tests for the image are defined
  9561. as:
  9562. <literallayout class='monospaced'>
  9563. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  9564. </literallayout></para></listitem>
  9565. <listitem><para>Add your own test to the list of the
  9566. by using the following:
  9567. <literallayout class='monospaced'>
  9568. TEST_SUITES_append = " mytest"
  9569. </literallayout></para></listitem>
  9570. <listitem><para>Run a specific list of tests as follows:
  9571. <literallayout class='monospaced'>
  9572. TEST_SUITES = "test1 test2 test3"
  9573. </literallayout>
  9574. Remember, order is important.
  9575. Be sure to place a test that is dependent on another test
  9576. later in the order.</para></listitem>
  9577. </itemizedlist>
  9578. </para>
  9579. </section>
  9580. <section id="exporting-tests">
  9581. <title>Exporting Tests</title>
  9582. <para>
  9583. You can export tests so that they can run independently of
  9584. the build system.
  9585. Exporting tests is required if you want to be able to hand
  9586. the test execution off to a scheduler.
  9587. You can only export tests that are defined in
  9588. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  9589. </para>
  9590. <para>
  9591. If your image is already built, make sure the following are set
  9592. in your <filename>local.conf</filename> file:
  9593. <literallayout class='monospaced'>
  9594. INHERIT +="testexport"
  9595. TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>"
  9596. TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>"
  9597. </literallayout>
  9598. You can then export the tests with the following BitBake
  9599. command form:
  9600. <literallayout class='monospaced'>
  9601. $ bitbake <replaceable>image</replaceable> -c testexport
  9602. </literallayout>
  9603. Exporting the tests places them in the
  9604. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9605. in
  9606. <filename>tmp/testexport/</filename><replaceable>image</replaceable>,
  9607. which is controlled by the
  9608. <filename>TEST_EXPORT_DIR</filename> variable.
  9609. </para>
  9610. <para>
  9611. You can now run the tests outside of the build environment:
  9612. <literallayout class='monospaced'>
  9613. $ cd tmp/testexport/<replaceable>image</replaceable>
  9614. $ ./runexported.py testdata.json
  9615. </literallayout>
  9616. </para>
  9617. <para>
  9618. Here is a complete example that shows IP addresses and uses
  9619. the <filename>core-image-sato</filename> image:
  9620. <literallayout class='monospaced'>
  9621. INHERIT +="testexport"
  9622. TEST_TARGET_IP = "192.168.7.2"
  9623. TEST_SERVER_IP = "192.168.7.1"
  9624. </literallayout>
  9625. Use BitBake to export the tests:
  9626. <literallayout class='monospaced'>
  9627. $ bitbake core-image-sato -c testexport
  9628. </literallayout>
  9629. Run the tests outside of the build environment using the
  9630. following:
  9631. <literallayout class='monospaced'>
  9632. $ cd tmp/testexport/core-image-sato
  9633. $ ./runexported.py testdata.json
  9634. </literallayout>
  9635. </para>
  9636. </section>
  9637. <section id="qemu-image-writing-new-tests">
  9638. <title>Writing New Tests</title>
  9639. <para>
  9640. As mentioned previously, all new test files need to be in the
  9641. proper place for the build system to find them.
  9642. New tests for additional functionality outside of the core
  9643. should be added to the layer that adds the functionality, in
  9644. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  9645. (as long as
  9646. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  9647. is extended in the layer's
  9648. <filename>layer.conf</filename> file as normal).
  9649. Just remember the following:
  9650. <itemizedlist>
  9651. <listitem><para>Filenames need to map directly to test
  9652. (module) names.
  9653. </para></listitem>
  9654. <listitem><para>Do not use module names that
  9655. collide with existing core tests.
  9656. </para></listitem>
  9657. <listitem><para>Minimally, an empty
  9658. <filename>__init__.py</filename> file must exist
  9659. in the runtime directory.
  9660. </para></listitem>
  9661. </itemizedlist>
  9662. </para>
  9663. <para>
  9664. To create a new test, start by copying an existing module
  9665. (e.g. <filename>syslog.py</filename> or
  9666. <filename>gcc.py</filename> are good ones to use).
  9667. Test modules can use code from
  9668. <filename>meta/lib/oeqa/utils</filename>, which are helper
  9669. classes.
  9670. </para>
  9671. <note>
  9672. Structure shell commands such that you rely on them and they
  9673. return a single code for success.
  9674. Be aware that sometimes you will need to parse the output.
  9675. See the <filename>df.py</filename> and
  9676. <filename>date.py</filename> modules for examples.
  9677. </note>
  9678. <para>
  9679. You will notice that all test classes inherit
  9680. <filename>oeRuntimeTest</filename>, which is found in
  9681. <filename>meta/lib/oetest.py</filename>.
  9682. This base class offers some helper attributes, which are
  9683. described in the following sections:
  9684. </para>
  9685. <section id='qemu-image-writing-tests-class-methods'>
  9686. <title>Class Methods</title>
  9687. <para>
  9688. Class methods are as follows:
  9689. <itemizedlist>
  9690. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  9691. Returns "True" if <filename>pkg</filename> is in the
  9692. installed package list of the image, which is based
  9693. on the manifest file that is generated during the
  9694. <filename>do_rootfs</filename> task.
  9695. </para></listitem>
  9696. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  9697. Returns "True" if the feature is in
  9698. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  9699. or
  9700. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  9701. </para></listitem>
  9702. </itemizedlist>
  9703. </para>
  9704. </section>
  9705. <section id='qemu-image-writing-tests-class-attributes'>
  9706. <title>Class Attributes</title>
  9707. <para>
  9708. Class attributes are as follows:
  9709. <itemizedlist>
  9710. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  9711. Equals "ps -ef" if <filename>procps</filename> is
  9712. installed in the image.
  9713. Otherwise, <filename>pscmd</filename> equals
  9714. "ps" (busybox).
  9715. </para></listitem>
  9716. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  9717. The called test context, which gives access to the
  9718. following attributes:
  9719. <itemizedlist>
  9720. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  9721. The BitBake datastore, which allows you to
  9722. use stuff such as
  9723. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  9724. </para></listitem>
  9725. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  9726. Used internally.
  9727. The tests do not need these.
  9728. </para></listitem>
  9729. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  9730. The absolute path to
  9731. <filename>meta/lib/oeqa/runtime/files</filename>,
  9732. which contains helper files for tests meant
  9733. for copying on the target such as small
  9734. files written in C for compilation.
  9735. </para></listitem>
  9736. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  9737. The target controller object used to deploy
  9738. and start an image on a particular target
  9739. (e.g. QemuTarget, SimpleRemote, and
  9740. Systemd-bootTarget).
  9741. Tests usually use the following:
  9742. <itemizedlist>
  9743. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  9744. The target's IP address.
  9745. </para></listitem>
  9746. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  9747. The host's IP address, which is
  9748. usually used by the DNF test
  9749. suite.
  9750. </para></listitem>
  9751. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  9752. The single, most used method.
  9753. This command is a wrapper for:
  9754. <filename>ssh root@host "cmd"</filename>.
  9755. The command returns a tuple:
  9756. (status, output), which are what
  9757. their names imply - the return code
  9758. of "cmd" and whatever output
  9759. it produces.
  9760. The optional timeout argument
  9761. represents the number of seconds the
  9762. test should wait for "cmd" to
  9763. return.
  9764. If the argument is "None", the
  9765. test uses the default instance's
  9766. timeout period, which is 300
  9767. seconds.
  9768. If the argument is "0", the test
  9769. runs until the command returns.
  9770. </para></listitem>
  9771. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  9772. <filename>scp localpath root@ip:remotepath</filename>.
  9773. </para></listitem>
  9774. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  9775. <filename>scp root@host:remotepath localpath</filename>.
  9776. </para></listitem>
  9777. </itemizedlist></para></listitem>
  9778. </itemizedlist></para></listitem>
  9779. </itemizedlist>
  9780. </para>
  9781. </section>
  9782. <section id='qemu-image-writing-tests-instance-attributes'>
  9783. <title>Instance Attributes</title>
  9784. <para>
  9785. A single instance attribute exists, which is
  9786. <filename>target</filename>.
  9787. The <filename>target</filename> instance attribute is
  9788. identical to the class attribute of the same name, which
  9789. is described in the previous section.
  9790. This attribute exists as both an instance and class
  9791. attribute so tests can use
  9792. <filename>self.target.run(cmd)</filename> in instance
  9793. methods instead of
  9794. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  9795. </para>
  9796. </section>
  9797. </section>
  9798. <section id='installing-packages-in-the-dut-without-the-package-manager'>
  9799. <title>Installing Packages in the DUT Without the Package Manager</title>
  9800. <para>
  9801. When a test requires a package built by BitBake, it is possible
  9802. to install that package.
  9803. Installing the package does not require a package manager be
  9804. installed in the device under test (DUT).
  9805. It does, however, require an SSH connection and the target must
  9806. be using the <filename>sshcontrol</filename> class.
  9807. <note>
  9808. This method uses <filename>scp</filename> to copy files
  9809. from the host to the target, which causes permissions and
  9810. special attributes to be lost.
  9811. </note>
  9812. </para>
  9813. <para>
  9814. A JSON file is used to define the packages needed by a test.
  9815. This file must be in the same path as the file used to define
  9816. the tests.
  9817. Furthermore, the filename must map directly to the test
  9818. module name with a <filename>.json</filename> extension.
  9819. </para>
  9820. <para>
  9821. The JSON file must include an object with the test name as
  9822. keys of an object or an array.
  9823. This object (or array of objects) uses the following data:
  9824. <itemizedlist>
  9825. <listitem><para>"pkg" - A mandatory string that is the
  9826. name of the package to be installed.
  9827. </para></listitem>
  9828. <listitem><para>"rm" - An optional boolean, which defaults
  9829. to "false", that specifies to remove the package after
  9830. the test.
  9831. </para></listitem>
  9832. <listitem><para>"extract" - An optional boolean, which
  9833. defaults to "false", that specifies if the package must
  9834. be extracted from the package format.
  9835. When set to "true", the package is not automatically
  9836. installed into the DUT.
  9837. </para></listitem>
  9838. </itemizedlist>
  9839. </para>
  9840. <para>
  9841. Following is an example JSON file that handles test "foo"
  9842. installing package "bar" and test "foobar" installing
  9843. packages "foo" and "bar".
  9844. Once the test is complete, the packages are removed from the
  9845. DUT.
  9846. <literallayout class='monospaced'>
  9847. {
  9848. "foo": {
  9849. "pkg": "bar"
  9850. },
  9851. "foobar": [
  9852. {
  9853. "pkg": "foo",
  9854. "rm": true
  9855. },
  9856. {
  9857. "pkg": "bar",
  9858. "rm": true
  9859. }
  9860. ]
  9861. }
  9862. </literallayout>
  9863. </para>
  9864. </section>
  9865. </section>
  9866. <section id="platdev-gdb-remotedebug">
  9867. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  9868. <para>
  9869. GDB allows you to examine running programs, which in turn helps you to understand and fix problems.
  9870. It also allows you to perform post-mortem style analysis of program crashes.
  9871. GDB is available as a package within the Yocto Project and is
  9872. installed in SDK images by default.
  9873. See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter
  9874. in the Yocto Project Reference Manual for a description of these images.
  9875. You can find information on GDB at <ulink url="http://sourceware.org/gdb/"/>.
  9876. </para>
  9877. <tip>
  9878. For best results, install debug (<filename>-dbg</filename>) packages
  9879. for the applications you are going to debug.
  9880. Doing so makes extra debug symbols available that give you more
  9881. meaningful output.
  9882. </tip>
  9883. <para>
  9884. Sometimes, due to memory or disk space constraints, it is not possible
  9885. to use GDB directly on the remote target to debug applications.
  9886. These constraints arise because GDB needs to load the debugging information and the
  9887. binaries of the process being debugged.
  9888. Additionally, GDB needs to perform many computations to locate information such as function
  9889. names, variable names and values, stack traces and so forth - even before starting the
  9890. debugging process.
  9891. These extra computations place more load on the target system and can alter the
  9892. characteristics of the program being debugged.
  9893. </para>
  9894. <para>
  9895. To help get past the previously mentioned constraints, you can use
  9896. gdbserver, which runs on the remote target and does not load any
  9897. debugging information from the debugged process.
  9898. Instead, a GDB instance processes the debugging information that is run on a
  9899. remote computer - the host GDB.
  9900. The host GDB then sends control commands to gdbserver to make it stop or start the debugged
  9901. program, as well as read or write memory regions of that debugged program.
  9902. All the debugging information loaded and processed as well
  9903. as all the heavy debugging is done by the host GDB.
  9904. Offloading these processes gives the gdbserver running on the target a chance to remain
  9905. small and fast.
  9906. </para>
  9907. <para>
  9908. Because the host GDB is responsible for loading the debugging information and
  9909. for doing the necessary processing to make actual debugging happen,
  9910. you have to make sure the host can access the unstripped binaries complete
  9911. with their debugging information and also be sure the target is compiled with no optimizations.
  9912. The host GDB must also have local access to all the libraries used by the
  9913. debugged program.
  9914. Because gdbserver does not need any local debugging information, the binaries on
  9915. the remote target can remain stripped.
  9916. However, the binaries must also be compiled without optimization
  9917. so they match the host's binaries.
  9918. </para>
  9919. <para>
  9920. To remain consistent with GDB documentation and terminology, the binary being debugged
  9921. on the remote target machine is referred to as the "inferior" binary.
  9922. For documentation on GDB see the
  9923. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  9924. </para>
  9925. <para>
  9926. The following steps show you how to debug using the GNU project
  9927. debugger.
  9928. <orderedlist>
  9929. <listitem><para>
  9930. <emphasis>Configure your build system to construct the
  9931. companion debug filesystem:</emphasis></para>
  9932. <para>In your <filename>local.conf</filename> file, set
  9933. the following:
  9934. <literallayout class='monospaced'>
  9935. IMAGE_GEN_DEBUGFS = "1"
  9936. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  9937. </literallayout>
  9938. These options cause the OpenEmbedded build system
  9939. to generate a special companion filesystem fragment,
  9940. which contains the matching source and debug symbols to
  9941. your deployable filesystem.
  9942. The build system does this by looking at what is in the
  9943. deployed filesystem, and pulling the corresponding
  9944. <filename>-dbg</filename> packages.</para>
  9945. <para>The companion debug filesystem is not a complete
  9946. filesystem, but only contains the debug fragments.
  9947. This filesystem must be combined with the full filesystem
  9948. for debugging.
  9949. Subsequent steps in this procedure show how to combine
  9950. the partial filesystem with the full filesystem.
  9951. </para></listitem>
  9952. <listitem><para>
  9953. <emphasis>Configure the system to include gdbserver in
  9954. the target filesystem:</emphasis></para>
  9955. <para>Make the following addition in either your
  9956. <filename>local.conf</filename> file or in an image
  9957. recipe:
  9958. <literallayout class='monospaced'>
  9959. IMAGE_INSTALL_append = “ gdbserver"
  9960. </literallayout>
  9961. The change makes sure the <filename>gdbserver</filename>
  9962. package is included.
  9963. </para></listitem>
  9964. <listitem><para>
  9965. <emphasis>Build the environment:</emphasis></para>
  9966. <para>Use the following command to construct the image and
  9967. the companion Debug Filesystem:
  9968. <literallayout class='monospaced'>
  9969. $ bitbake <replaceable>image</replaceable>
  9970. </literallayout>
  9971. Build the cross GDB component and make it available
  9972. for debugging.
  9973. Build the SDK that matches the image.
  9974. Building the SDK is best for a production build
  9975. that can be used later for debugging, especially
  9976. during long term maintenance:
  9977. <literallayout class='monospaced'>
  9978. $ bitbake -c populate_sdk <replaceable>image</replaceable>
  9979. </literallayout></para>
  9980. <para>Alternatively, you can build the minimal
  9981. toolchain components that match the target.
  9982. Doing so creates a smaller than typical SDK and only
  9983. contains a minimal set of components with which to
  9984. build simple test applications, as well as run the
  9985. debugger:
  9986. <literallayout class='monospaced'>
  9987. $ bitbake meta-toolchain
  9988. </literallayout></para>
  9989. <para>A final method is to build Gdb itself within
  9990. the build system:
  9991. <literallayout class='monospaced'>
  9992. $ bitbake gdb-cross-<replaceable>architecture</replaceable>
  9993. </literallayout>
  9994. Doing so produces a temporary copy of
  9995. <filename>cross-gdb</filename> you can use for
  9996. debugging during development.
  9997. While this is the quickest approach, the two previous
  9998. methods in this step are better when considering
  9999. long-term maintenance strategies.
  10000. <note>
  10001. If you run
  10002. <filename>bitbake gdb-cross</filename>, the
  10003. OpenEmbedded build system suggests the actual
  10004. image (e.g. <filename>gdb-cross-i586</filename>).
  10005. The suggestion is usually the actual name you want
  10006. to use.
  10007. </note>
  10008. </para></listitem>
  10009. <listitem><para>
  10010. <emphasis>Set up the</emphasis>&nbsp;<filename>debugfs</filename></para>
  10011. <para>Run the following commands to set up the
  10012. <filename>debugfs</filename>:
  10013. <literallayout class='monospaced'>
  10014. $ mkdir debugfs
  10015. $ cd debugfs
  10016. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2
  10017. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2
  10018. </literallayout>
  10019. </para></listitem>
  10020. <listitem><para>
  10021. <emphasis>Set up GDB</emphasis></para>
  10022. <para>Install the SDK (if you built one) and then
  10023. source the correct environment file.
  10024. Sourcing the environment file puts the SDK in your
  10025. <filename>PATH</filename> environment variable.</para>
  10026. <para>If you are using the build system, Gdb is
  10027. located in
  10028. <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb
  10029. </para></listitem>
  10030. <listitem><para>
  10031. <emphasis>Boot the target:</emphasis></para>
  10032. <para>For information on how to run QEMU, see the
  10033. <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>.
  10034. <note>
  10035. Be sure to verify that your host can access the
  10036. target via TCP.
  10037. </note>
  10038. </para></listitem>
  10039. <listitem><para>
  10040. <emphasis>Debug a program:</emphasis></para>
  10041. <para>Debugging a program involves running gdbserver
  10042. on the target and then running Gdb on the host.
  10043. The example in this step debugs
  10044. <filename>gzip</filename>:
  10045. <literallayout class='monospaced'>
  10046. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  10047. </literallayout>
  10048. For additional gdbserver options, see the
  10049. <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>.
  10050. </para>
  10051. <para>After running gdbserver on the target, you need
  10052. to run Gdb on the host and configure it and connect to
  10053. the target.
  10054. Use these commands:
  10055. <literallayout class='monospaced'>
  10056. $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable>
  10057. $ <replaceable>arch</replaceable>-gdb
  10058. (gdb) set sysroot debugfs
  10059. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  10060. (gdb) target remote <replaceable>IP-of-target</replaceable>:1234
  10061. </literallayout>
  10062. At this point, everything should automatically load
  10063. (i.e. matching binaries, symbols and headers).
  10064. <note>
  10065. The Gdb <filename>set</filename> commands in the
  10066. previous example can be placed into the users
  10067. <filename>~/.gdbinit</filename> file.
  10068. Upon starting, Gdb automatically runs whatever
  10069. commands are in that file.
  10070. </note>
  10071. </para></listitem>
  10072. <listitem><para>
  10073. <emphasis>Deploying without a full image
  10074. rebuild:</emphasis></para>
  10075. <para>In many cases, during development you want a
  10076. quick method to deploy a new binary to the target and
  10077. debug it, without waiting for a full image build.
  10078. </para>
  10079. <para>One approach to solving this situation is to
  10080. just build the component you want to debug.
  10081. Once you have built the component, copy the
  10082. executable directly to both the target and the
  10083. host <filename>debugfs</filename>.</para>
  10084. <para>If the binary is processed through the debug
  10085. splitting in OpenEmbedded, you should also
  10086. copy the debug items (i.e. <filename>.debug</filename>
  10087. contents and corresponding
  10088. <filename>/usr/src/debug</filename> files)
  10089. from the work directory.
  10090. Here is an example:
  10091. <literallayout class='monospaced'>
  10092. $ bitbake bash
  10093. $ bitbake -c devshell bash
  10094. $ cd ..
  10095. $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash
  10096. $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs
  10097. </literallayout>
  10098. </para></listitem>
  10099. </orderedlist>
  10100. </para>
  10101. </section>
  10102. <!--
  10103. <section id='platdev-gdb-remotedebug-setup'>
  10104. <title>Set Up the Cross-Development Debugging Environment</title>
  10105. <para>
  10106. Before you can initiate a remote debugging session, you need
  10107. to be sure you have set up the cross-development environment,
  10108. toolchain, and sysroot.
  10109. The <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-intro'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>
  10110. describes this process.
  10111. </para>
  10112. </section>
  10113. <section id="platdev-gdb-remotedebug-launch-gdbserver">
  10114. <title>Launch gdbserver on the Target</title>
  10115. <para>
  10116. Make sure gdbserver is installed on the target.
  10117. If it is not, install the package
  10118. <filename>gdbserver</filename>, which needs the
  10119. <filename>libthread-db1</filename> package.
  10120. </para>
  10121. <para>
  10122. Here is an example, that when entered from the host,
  10123. connects to the target and launches gdbserver in order to
  10124. "debug" a binary named <filename>helloworld</filename>:
  10125. <literallayout class='monospaced'>
  10126. $ gdbserver localhost:2345 /usr/bin/helloworld
  10127. </literallayout>
  10128. gdbserver should now be listening on port 2345 for debugging
  10129. commands coming from a remote GDB process that is running on
  10130. the host computer.
  10131. Communication between gdbserver and the host GDB are done
  10132. using TCP.
  10133. To use other communication protocols, please refer to the
  10134. <ulink url='http://www.gnu.org/software/gdb/'>Gdbserver documentation</ulink>.
  10135. </para>
  10136. </section>
  10137. <section id="platdev-gdb-remotedebug-launch-gdb">
  10138. <title>Launch GDB on the Host Computer</title>
  10139. <para>
  10140. Running GDB on the host computer takes a number of stages, which
  10141. this section describes.
  10142. </para>
  10143. <section id="platdev-gdb-remotedebug-launch-gdb-buildcross">
  10144. <title>Build the Cross-GDB Package</title>
  10145. <para>
  10146. A suitable GDB cross-binary is required that runs on your
  10147. host computer but also knows about the the ABI of the
  10148. remote target.
  10149. You can get this binary from the
  10150. <link linkend='cross-development-toolchain'>Cross-Development Toolchain</link>.
  10151. Here is an example where the toolchain has been installed
  10152. in the default directory
  10153. <filename>/opt/poky/&DISTRO;</filename>:
  10154. <literallayout class='monospaced'>
  10155. /opt/poky/&DISTRO;/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb
  10156. </literallayout>
  10157. where <filename>arm</filename> is the target architecture
  10158. and <filename>linux-gnueabi</filename> is the target ABI.
  10159. </para>
  10160. <para>
  10161. Alternatively, you can use BitBake to build the
  10162. <filename>gdb-cross</filename> binary.
  10163. Here is an example:
  10164. <literallayout class='monospaced'>
  10165. $ bitbake gdb-cross
  10166. </literallayout>
  10167. Once the binary is built, you can find it here:
  10168. <literallayout class='monospaced'>
  10169. tmp/sysroots/<replaceable>host-arch</replaceable>/usr/bin/<replaceable>target-platform</replaceable>/<replaceable>target-abi</replaceable>-gdb
  10170. </literallayout>
  10171. </para>
  10172. </section>
  10173. <section id='create-the-gdb-initialization-file'>
  10174. <title>Create the GDB Initialization File and Point to Your Root Filesystem</title>
  10175. <para>
  10176. Aside from the GDB cross-binary, you also need a GDB
  10177. initialization file in the same top directory in which
  10178. your binary resides.
  10179. When you start GDB on your host development system, GDB
  10180. finds this initialization file and executes all the
  10181. commands within.
  10182. For information on the <filename>.gdbinit</filename>, see
  10183. "<ulink url='http://sourceware.org/gdb/onlinedocs/gdb/'>Debugging with GDB</ulink>",
  10184. which is maintained by
  10185. <ulink url='http://www.sourceware.org'>sourceware.org</ulink>.
  10186. </para>
  10187. <para>
  10188. You need to add a statement in the
  10189. <filename>~/.gdbinit</filename> file that points to your
  10190. root filesystem.
  10191. Here is an example that points to the root filesystem for
  10192. an ARM-based target device:
  10193. <literallayout class='monospaced'>
  10194. set sysroot ~/sysroot_arm
  10195. </literallayout>
  10196. </para>
  10197. </section>
  10198. <section id="platdev-gdb-remotedebug-launch-gdb-launchhost">
  10199. <title>Launch the Host GDB</title>
  10200. <para>
  10201. Before launching the host GDB, you need to be sure
  10202. you have sourced the cross-debugging environment script,
  10203. which if you installed the root filesystem in the default
  10204. location is at <filename>/opt/poky/&DISTRO;</filename>
  10205. and begins with the string "environment-setup".
  10206. For more information, see the
  10207. <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's
  10208. Guide</ulink>.
  10209. </para>
  10210. <para>
  10211. Finally, switch to the directory where the binary resides
  10212. and run the <filename>cross-gdb</filename> binary.
  10213. Provide the binary file you are going to debug.
  10214. For example, the following command continues with the
  10215. example used in the previous section by loading
  10216. the <filename>helloworld</filename> binary as well as the
  10217. debugging information:
  10218. <literallayout class='monospaced'>
  10219. $ arm-poky-linux-gnuabi-gdb helloworld
  10220. </literallayout>
  10221. The commands in your <filename>.gdbinit</filename> execute
  10222. and the GDB prompt appears.
  10223. </para>
  10224. </section>
  10225. </section>
  10226. <section id='platdev-gdb-connect-to-the-remote-gdb-server'>
  10227. <title>Connect to the Remote GDB Server</title>
  10228. <para>
  10229. From the target, you need to connect to the remote GDB
  10230. server that is running on the host.
  10231. You need to specify the remote host and port.
  10232. Here is the command continuing with the example:
  10233. <literallayout class='monospaced'>
  10234. target remote 192.168.7.2:2345
  10235. </literallayout>
  10236. </para>
  10237. </section>
  10238. <section id="platdev-gdb-remotedebug-launch-gdb-using">
  10239. <title>Use the Debugger</title>
  10240. <para>
  10241. You can now proceed with debugging as normal - as if you were debugging
  10242. on the local machine.
  10243. For example, to instruct GDB to break in the "main" function and then
  10244. continue with execution of the inferior binary use the following commands
  10245. from within GDB:
  10246. <literallayout class='monospaced'>
  10247. (gdb) break main
  10248. (gdb) continue
  10249. </literallayout>
  10250. </para>
  10251. <para>
  10252. For more information about using GDB, see the project's online documentation at
  10253. <ulink url="http://sourceware.org/gdb/download/onlinedocs/"/>.
  10254. </para>
  10255. </section>
  10256. </section>
  10257. -->
  10258. <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>
  10259. <title>Debugging with the GNU Project Debugger (GDB) on the Target</title>
  10260. <para>
  10261. The previous section addressed using GDB remotely for debugging
  10262. purposes, which is the most usual case due to the inherent
  10263. hardware limitations on many embedded devices.
  10264. However, debugging in the target hardware itself is also possible
  10265. with more powerful devices.
  10266. This section describes what you need to do in order to support
  10267. using GDB to debug on the target hardware.
  10268. </para>
  10269. <para>
  10270. To support this kind of debugging, you need do the following:
  10271. <itemizedlist>
  10272. <listitem><para>
  10273. Ensure that GDB is on the target.
  10274. You can do this by adding "gdb" to
  10275. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  10276. <literallayout class='monospaced'>
  10277. IMAGE_INSTALL_append = " gdb"
  10278. </literallayout>
  10279. Alternatively, you can add "tools-debug" to
  10280. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  10281. <literallayout class='monospaced'>
  10282. IMAGE_FEATURES_append = " tools-debug"
  10283. </literallayout>
  10284. </para></listitem>
  10285. <listitem><para>
  10286. Ensure that debug symbols are present.
  10287. You can make sure these symbols are present by installing
  10288. <filename>-dbg</filename>:
  10289. <literallayout class='monospaced'>
  10290. IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg"
  10291. </literallayout>
  10292. Alternatively, you can do the following to include all the
  10293. debug symbols:
  10294. <literallayout class='monospaced'>
  10295. IMAGE_FEATURES_append = " dbg-pkgs"
  10296. </literallayout>
  10297. </para></listitem>
  10298. </itemizedlist>
  10299. <note>
  10300. To improve the debug information accuracy, you can reduce the
  10301. level of optimization used by the compiler.
  10302. For example, when adding the following line to your
  10303. <filename>local.conf</filename> file, you will reduce
  10304. optimization from
  10305. <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink>
  10306. of "-O2" to
  10307. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink>
  10308. of "-O -fno-omit-frame-pointer":
  10309. <literallayout class='monospaced'>
  10310. DEBUG_BUILD = "1"
  10311. </literallayout>
  10312. Consider that this will reduce the application's performance
  10313. and is recommended only for debugging purposes.
  10314. </note>
  10315. </para>
  10316. </section>
  10317. <section id='debugging-parallel-make-races'>
  10318. <title>Debugging Parallel Make Races</title>
  10319. <para>
  10320. A parallel <filename>make</filename> race occurs when the build
  10321. consists of several parts that are run simultaneously and
  10322. a situation occurs when the output or result of one
  10323. part is not ready for use with a different part of the build that
  10324. depends on that output.
  10325. Parallel make races are annoying and can sometimes be difficult
  10326. to reproduce and fix.
  10327. However, some simple tips and tricks exist that can help
  10328. you debug and fix them.
  10329. This section presents a real-world example of an error encountered
  10330. on the Yocto Project autobuilder and the process used to fix it.
  10331. <note>
  10332. If you cannot properly fix a <filename>make</filename> race
  10333. condition, you can work around it by clearing either the
  10334. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  10335. or
  10336. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  10337. variables.
  10338. </note>
  10339. </para>
  10340. <section id='the-failure'>
  10341. <title>The Failure</title>
  10342. <para>
  10343. For this example, assume that you are building an image that
  10344. depends on the "neard" package.
  10345. And, during the build, BitBake runs into problems and
  10346. creates the following output.
  10347. <note>
  10348. This example log file has longer lines artificially
  10349. broken to make the listing easier to read.
  10350. </note>
  10351. If you examine the output or the log file, you see the
  10352. failure during <filename>make</filename>:
  10353. <literallayout class='monospaced'>
  10354. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  10355. | DEBUG: Executing shell function do_compile
  10356. | NOTE: make -j 16
  10357. | make --no-print-directory all-am
  10358. | /bin/mkdir -p include/near
  10359. | /bin/mkdir -p include/near
  10360. | /bin/mkdir -p include/near
  10361. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10362. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  10363. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10364. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  10365. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10366. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  10367. | /bin/mkdir -p include/near
  10368. | /bin/mkdir -p include/near
  10369. | /bin/mkdir -p include/near
  10370. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10371. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  10372. | /bin/mkdir -p include/near
  10373. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10374. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  10375. | /bin/mkdir -p include/near
  10376. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10377. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  10378. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10379. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  10380. | /bin/mkdir -p include/near
  10381. | /bin/mkdir -p include/near
  10382. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10383. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  10384. | /bin/mkdir -p include/near
  10385. | /bin/mkdir -p include/near
  10386. | /bin/mkdir -p include/near
  10387. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10388. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  10389. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10390. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  10391. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10392. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  10393. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10394. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  10395. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10396. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  10397. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  10398. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  10399. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  10400. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  10401. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  10402. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  10403. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  10404. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  10405. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  10406. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  10407. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  10408. -o tools/snep-send.o tools/snep-send.c
  10409. | In file included from tools/snep-send.c:16:0:
  10410. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  10411. | #include &lt;near/dbus.h&gt;
  10412. | ^
  10413. | compilation terminated.
  10414. | make[1]: *** [tools/snep-send.o] Error 1
  10415. | make[1]: *** Waiting for unfinished jobs....
  10416. | make: *** [all] Error 2
  10417. | ERROR: oe_runmake failed
  10418. </literallayout>
  10419. </para>
  10420. </section>
  10421. <section id='reproducing-the-error'>
  10422. <title>Reproducing the Error</title>
  10423. <para>
  10424. Because race conditions are intermittent, they do not
  10425. manifest themselves every time you do the build.
  10426. In fact, most times the build will complete without problems
  10427. even though the potential race condition exists.
  10428. Thus, once the error surfaces, you need a way to reproduce it.
  10429. </para>
  10430. <para>
  10431. In this example, compiling the "neard" package is causing the
  10432. problem.
  10433. So the first thing to do is build "neard" locally.
  10434. Before you start the build, set the
  10435. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  10436. variable in your <filename>local.conf</filename> file to
  10437. a high number (e.g. "-j 20").
  10438. Using a high value for <filename>PARALLEL_MAKE</filename>
  10439. increases the chances of the race condition showing up:
  10440. <literallayout class='monospaced'>
  10441. $ bitbake neard
  10442. </literallayout>
  10443. </para>
  10444. <para>
  10445. Once the local build for "neard" completes, start a
  10446. <filename>devshell</filename> build:
  10447. <literallayout class='monospaced'>
  10448. $ bitbake neard -c devshell
  10449. </literallayout>
  10450. For information on how to use a
  10451. <filename>devshell</filename>, see the
  10452. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  10453. section.
  10454. </para>
  10455. <para>
  10456. In the <filename>devshell</filename>, do the following:
  10457. <literallayout class='monospaced'>
  10458. $ make clean
  10459. $ make tools/snep-send.o
  10460. </literallayout>
  10461. The <filename>devshell</filename> commands cause the failure
  10462. to clearly be visible.
  10463. In this case, a missing dependency exists for the "neard"
  10464. Makefile target.
  10465. Here is some abbreviated, sample output with the
  10466. missing dependency clearly visible at the end:
  10467. <literallayout class='monospaced'>
  10468. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  10469. .
  10470. .
  10471. .
  10472. tools/snep-send.c
  10473. In file included from tools/snep-send.c:16:0:
  10474. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  10475. #include &lt;near/dbus.h&gt;
  10476. ^
  10477. compilation terminated.
  10478. make: *** [tools/snep-send.o] Error 1
  10479. $
  10480. </literallayout>
  10481. </para>
  10482. </section>
  10483. <section id='creating-a-patch-for-the-fix'>
  10484. <title>Creating a Patch for the Fix</title>
  10485. <para>
  10486. Because there is a missing dependency for the Makefile
  10487. target, you need to patch the
  10488. <filename>Makefile.am</filename> file, which is generated
  10489. from <filename>Makefile.in</filename>.
  10490. You can use Quilt to create the patch:
  10491. <literallayout class='monospaced'>
  10492. $ quilt new parallelmake.patch
  10493. Patch patches/parallelmake.patch is now on top
  10494. $ quilt add Makefile.am
  10495. File Makefile.am added to patch patches/parallelmake.patch
  10496. </literallayout>
  10497. For more information on using Quilt, see the
  10498. "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
  10499. section.
  10500. </para>
  10501. <para>
  10502. At this point you need to make the edits to
  10503. <filename>Makefile.am</filename> to add the missing
  10504. dependency.
  10505. For our example, you have to add the following line
  10506. to the file:
  10507. <literallayout class='monospaced'>
  10508. tools/snep-send.$(OBJEXT): include/near/dbus.h
  10509. </literallayout>
  10510. </para>
  10511. <para>
  10512. Once you have edited the file, use the
  10513. <filename>refresh</filename> command to create the patch:
  10514. <literallayout class='monospaced'>
  10515. $ quilt refresh
  10516. Refreshed patch patches/parallelmake.patch
  10517. </literallayout>
  10518. Once the patch file exists, you need to add it back to the
  10519. originating recipe folder.
  10520. Here is an example assuming a top-level
  10521. <link linkend='source-directory'>Source Directory</link>
  10522. named <filename>poky</filename>:
  10523. <literallayout class='monospaced'>
  10524. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  10525. </literallayout>
  10526. The final thing you need to do to implement the fix in the
  10527. build is to update the "neard" recipe (i.e.
  10528. <filename>neard-0.14.bb</filename>) so that the
  10529. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  10530. statement includes the patch file.
  10531. The recipe file is in the folder above the patch.
  10532. Here is what the edited <filename>SRC_URI</filename>
  10533. statement would look like:
  10534. <literallayout class='monospaced'>
  10535. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  10536. file://neard.in \
  10537. file://neard.service.in \
  10538. file://parallelmake.patch \
  10539. "
  10540. </literallayout>
  10541. </para>
  10542. <para>
  10543. With the patch complete and moved to the correct folder and
  10544. the <filename>SRC_URI</filename> statement updated, you can
  10545. exit the <filename>devshell</filename>:
  10546. <literallayout class='monospaced'>
  10547. $ exit
  10548. </literallayout>
  10549. </para>
  10550. </section>
  10551. <section id='testing-the-build'>
  10552. <title>Testing the Build</title>
  10553. <para>
  10554. With everything in place, you can get back to trying the
  10555. build again locally:
  10556. <literallayout class='monospaced'>
  10557. $ bitbake neard
  10558. </literallayout>
  10559. This build should succeed.
  10560. </para>
  10561. <para>
  10562. Now you can open up a <filename>devshell</filename> again
  10563. and repeat the clean and make operations as follows:
  10564. <literallayout class='monospaced'>
  10565. $ bitbake neard -c devshell
  10566. $ make clean
  10567. $ make tools/snep-send.o
  10568. </literallayout>
  10569. The build should work without issue.
  10570. </para>
  10571. <para>
  10572. As with all solved problems, if they originated upstream, you
  10573. need to submit the fix for the recipe in OE-Core and upstream
  10574. so that the problem is taken care of at its source.
  10575. See the
  10576. "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>"
  10577. section for more information.
  10578. </para>
  10579. </section>
  10580. </section>
  10581. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  10582. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  10583. <para>
  10584. One of the concerns for a development organization using open source
  10585. software is how to maintain compliance with various open source
  10586. licensing during the lifecycle of the product.
  10587. While this section does not provide legal advice or
  10588. comprehensively cover all scenarios, it does
  10589. present methods that you can use to
  10590. assist you in meeting the compliance requirements during a software
  10591. release.
  10592. </para>
  10593. <para>
  10594. With hundreds of different open source licenses that the Yocto
  10595. Project tracks, it is difficult to know the requirements of each
  10596. and every license.
  10597. However, the requirements of the major FLOSS licenses can begin
  10598. to be covered by
  10599. assuming that three main areas of concern exist:
  10600. <itemizedlist>
  10601. <listitem><para>Source code must be provided.</para></listitem>
  10602. <listitem><para>License text for the software must be
  10603. provided.</para></listitem>
  10604. <listitem><para>Compilation scripts and modifications to the
  10605. source code must be provided.
  10606. </para></listitem>
  10607. </itemizedlist>
  10608. There are other requirements beyond the scope of these
  10609. three and the methods described in this section
  10610. (e.g. the mechanism through which source code is distributed).
  10611. </para>
  10612. <para>
  10613. As different organizations have different methods of complying with
  10614. open source licensing, this section is not meant to imply that
  10615. there is only one single way to meet your compliance obligations,
  10616. but rather to describe one method of achieving compliance.
  10617. The remainder of this section describes methods supported to meet the
  10618. previously mentioned three requirements.
  10619. Once you take steps to meet these requirements,
  10620. and prior to releasing images, sources, and the build system,
  10621. you should audit all artifacts to ensure completeness.
  10622. <note>
  10623. The Yocto Project generates a license manifest during
  10624. image creation that is located
  10625. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  10626. to assist with any audits.
  10627. </note>
  10628. </para>
  10629. <section id='providing-the-source-code'>
  10630. <title>Providing the Source Code</title>
  10631. <para>
  10632. Compliance activities should begin before you generate the
  10633. final image.
  10634. The first thing you should look at is the requirement that
  10635. tops the list for most compliance groups - providing
  10636. the source.
  10637. The Yocto Project has a few ways of meeting this
  10638. requirement.
  10639. </para>
  10640. <para>
  10641. One of the easiest ways to meet this requirement is
  10642. to provide the entire
  10643. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  10644. used by the build.
  10645. This method, however, has a few issues.
  10646. The most obvious is the size of the directory since it includes
  10647. all sources used in the build and not just the source used in
  10648. the released image.
  10649. It will include toolchain source, and other artifacts, which
  10650. you would not generally release.
  10651. However, the more serious issue for most companies is accidental
  10652. release of proprietary software.
  10653. The Yocto Project provides an
  10654. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  10655. class to help avoid some of these concerns.
  10656. </para>
  10657. <para>
  10658. Before you employ <filename>DL_DIR</filename> or the
  10659. <filename>archiver</filename> class, you need to decide how
  10660. you choose to provide source.
  10661. The source <filename>archiver</filename> class can generate
  10662. tarballs and SRPMs and can create them with various levels of
  10663. compliance in mind.
  10664. </para>
  10665. <para>
  10666. One way of doing this (but certainly not the only way) is to
  10667. release just the source as a tarball.
  10668. You can do this by adding the following to the
  10669. <filename>local.conf</filename> file found in the
  10670. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  10671. <literallayout class='monospaced'>
  10672. INHERIT += "archiver"
  10673. ARCHIVER_MODE[src] = "original"
  10674. </literallayout>
  10675. During the creation of your image, the source from all
  10676. recipes that deploy packages to the image is placed within
  10677. subdirectories of
  10678. <filename>DEPLOY_DIR/sources</filename> based on the
  10679. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  10680. for each recipe.
  10681. Releasing the entire directory enables you to comply with
  10682. requirements concerning providing the unmodified source.
  10683. It is important to note that the size of the directory can
  10684. get large.
  10685. </para>
  10686. <para>
  10687. A way to help mitigate the size issue is to only release
  10688. tarballs for licenses that require the release of
  10689. source.
  10690. Let us assume you are only concerned with GPL code as
  10691. identified by running the following script:
  10692. <literallayout class='monospaced'>
  10693. # Script to archive a subset of packages matching specific license(s)
  10694. # Source and license files are copied into sub folders of package folder
  10695. # Must be run from build folder
  10696. #!/bin/bash
  10697. src_release_dir="source-release"
  10698. mkdir -p $src_release_dir
  10699. for a in tmp/deploy/sources/*; do
  10700. for d in $a/*; do
  10701. # Get package name from path
  10702. p=`basename $d`
  10703. p=${p%-*}
  10704. p=${p%-*}
  10705. # Only archive GPL packages (update *GPL* regex for your license check)
  10706. numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
  10707. if [ $numfiles -gt 1 ]; then
  10708. echo Archiving $p
  10709. mkdir -p $src_release_dir/$p/source
  10710. cp $d/* $src_release_dir/$p/source 2> /dev/null
  10711. mkdir -p $src_release_dir/$p/license
  10712. cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
  10713. fi
  10714. done
  10715. done </literallayout>
  10716. At this point, you could create a tarball from the
  10717. <filename>gpl_source_release</filename> directory and
  10718. provide that to the end user.
  10719. This method would be a step toward achieving compliance
  10720. with section 3a of GPLv2 and with section 6 of GPLv3.
  10721. </para>
  10722. </section>
  10723. <section id='providing-license-text'>
  10724. <title>Providing License Text</title>
  10725. <para>
  10726. One requirement that is often overlooked is inclusion
  10727. of license text.
  10728. This requirement also needs to be dealt with prior to
  10729. generating the final image.
  10730. Some licenses require the license text to accompany
  10731. the binary.
  10732. You can achieve this by adding the following to your
  10733. <filename>local.conf</filename> file:
  10734. <literallayout class='monospaced'>
  10735. COPY_LIC_MANIFEST = "1"
  10736. COPY_LIC_DIRS = "1"
  10737. LICENSE_CREATE_PACKAGE = "1"
  10738. </literallayout>
  10739. Adding these statements to the configuration file ensures
  10740. that the licenses collected during package generation
  10741. are included on your image.
  10742. <note>
  10743. <para>Setting all three variables to "1" results in the
  10744. image having two copies of the same license file.
  10745. One copy resides in
  10746. <filename>/usr/share/common-licenses</filename> and
  10747. the other resides in
  10748. <filename>/usr/share/license</filename>.</para>
  10749. <para>The reason for this behavior is because
  10750. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink>
  10751. and
  10752. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink>
  10753. add a copy of the license when the image is built but do
  10754. not offer a path for adding licenses for newly installed
  10755. packages to an image.
  10756. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink>
  10757. adds a separate package and an upgrade path for adding
  10758. licenses to an image.</para>
  10759. </note>
  10760. </para>
  10761. <para>
  10762. As the source <filename>archiver</filename> class has already
  10763. archived the original
  10764. unmodified source that contains the license files,
  10765. you would have already met the requirements for inclusion
  10766. of the license information with source as defined by the GPL
  10767. and other open source licenses.
  10768. </para>
  10769. </section>
  10770. <section id='providing-compilation-scripts-and-source-code-modifications'>
  10771. <title>Providing Compilation Scripts and Source Code Modifications</title>
  10772. <para>
  10773. At this point, we have addressed all we need to
  10774. prior to generating the image.
  10775. The next two requirements are addressed during the final
  10776. packaging of the release.
  10777. </para>
  10778. <para>
  10779. By releasing the version of the OpenEmbedded build system
  10780. and the layers used during the build, you will be providing both
  10781. compilation scripts and the source code modifications in one
  10782. step.
  10783. </para>
  10784. <para>
  10785. If the deployment team has a
  10786. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  10787. and a distro layer, and those those layers are used to patch,
  10788. compile, package, or modify (in any way) any open source
  10789. software included in your released images, you
  10790. might be required to release those layers under section 3 of
  10791. GPLv2 or section 1 of GPLv3.
  10792. One way of doing that is with a clean
  10793. checkout of the version of the Yocto Project and layers used
  10794. during your build.
  10795. Here is an example:
  10796. <literallayout class='monospaced'>
  10797. # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo
  10798. $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky
  10799. $ cd poky
  10800. # We built using the release_branch for our layers
  10801. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  10802. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  10803. # clean up the .git repos
  10804. $ find . -name ".git" -type d -exec rm -rf {} \;
  10805. </literallayout>
  10806. One thing a development organization might want to consider
  10807. for end-user convenience is to modify
  10808. <filename>meta-poky/conf/bblayers.conf.sample</filename> to
  10809. ensure that when the end user utilizes the released build
  10810. system to build an image, the development organization's
  10811. layers are included in the <filename>bblayers.conf</filename>
  10812. file automatically:
  10813. <literallayout class='monospaced'>
  10814. # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
  10815. # changes incompatibly
  10816. LCONF_VERSION = "6"
  10817. BBPATH = "${TOPDIR}"
  10818. BBFILES ?= ""
  10819. BBLAYERS ?= " \
  10820. ##OEROOT##/meta \
  10821. ##OEROOT##/meta-poky \
  10822. ##OEROOT##/meta-yocto-bsp \
  10823. ##OEROOT##/meta-mylayer \
  10824. "
  10825. </literallayout>
  10826. Creating and providing an archive of the
  10827. <link linkend='metadata'>Metadata</link> layers
  10828. (recipes, configuration files, and so forth)
  10829. enables you to meet your
  10830. requirements to include the scripts to control compilation
  10831. as well as any modifications to the original source.
  10832. </para>
  10833. </section>
  10834. </section>
  10835. <section id='using-the-error-reporting-tool'>
  10836. <title>Using the Error Reporting Tool</title>
  10837. <para>
  10838. The error reporting tool allows you to
  10839. submit errors encountered during builds to a central database.
  10840. Outside of the build environment, you can use a web interface to
  10841. browse errors, view statistics, and query for errors.
  10842. The tool works using a client-server system where the client
  10843. portion is integrated with the installed Yocto Project
  10844. <link linkend='source-directory'>Source Directory</link>
  10845. (e.g. <filename>poky</filename>).
  10846. The server receives the information collected and saves it in a
  10847. database.
  10848. </para>
  10849. <para>
  10850. A live instance of the error reporting server exists at
  10851. <ulink url='http://errors.yoctoproject.org'></ulink>.
  10852. This server exists so that when you want to get help with
  10853. build failures, you can submit all of the information on the
  10854. failure easily and then point to the URL in your bug report
  10855. or send an email to the mailing list.
  10856. <note>
  10857. If you send error reports to this server, the reports become
  10858. publicly visible.
  10859. </note>
  10860. </para>
  10861. <section id='enabling-and-using-the-tool'>
  10862. <title>Enabling and Using the Tool</title>
  10863. <para>
  10864. By default, the error reporting tool is disabled.
  10865. You can enable it by inheriting the
  10866. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  10867. class by adding the following statement to the end of
  10868. your <filename>local.conf</filename> file in your
  10869. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  10870. <literallayout class='monospaced'>
  10871. INHERIT += "report-error"
  10872. </literallayout>
  10873. </para>
  10874. <para>
  10875. By default, the error reporting feature stores information in
  10876. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  10877. However, you can specify a directory to use by adding the following
  10878. to your <filename>local.conf</filename> file:
  10879. <literallayout class='monospaced'>
  10880. ERR_REPORT_DIR = "path"
  10881. </literallayout>
  10882. Enabling error reporting causes the build process to collect
  10883. the errors and store them in a file as previously described.
  10884. When the build system encounters an error, it includes a
  10885. command as part of the console output.
  10886. You can run the command to send the error file to the server.
  10887. For example, the following command sends the errors to an
  10888. upstream server:
  10889. <literallayout class='monospaced'>
  10890. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  10891. </literallayout>
  10892. In the previous example, the errors are sent to a public
  10893. database available at
  10894. <ulink url='http://errors.yoctoproject.org'></ulink>, which is
  10895. used by the entire community.
  10896. If you specify a particular server, you can send the errors
  10897. to a different database.
  10898. Use the following command for more information on available
  10899. options:
  10900. <literallayout class='monospaced'>
  10901. $ send-error-report --help
  10902. </literallayout>
  10903. </para>
  10904. <para>
  10905. When sending the error file, you are prompted to review the
  10906. data being sent as well as to provide a name and optional
  10907. email address.
  10908. Once you satisfy these prompts, the command returns a link
  10909. from the server that corresponds to your entry in the database.
  10910. For example, here is a typical link:
  10911. <literallayout class='monospaced'>
  10912. http://errors.yoctoproject.org/Errors/Details/9522/
  10913. </literallayout>
  10914. Following the link takes you to a web interface where you can
  10915. browse, query the errors, and view statistics.
  10916. </para>
  10917. </section>
  10918. <section id='disabling-the-tool'>
  10919. <title>Disabling the Tool</title>
  10920. <para>
  10921. To disable the error reporting feature, simply remove or comment
  10922. out the following statement from the end of your
  10923. <filename>local.conf</filename> file in your
  10924. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  10925. <literallayout class='monospaced'>
  10926. INHERIT += "report-error"
  10927. </literallayout>
  10928. </para>
  10929. </section>
  10930. <section id='setting-up-your-own-error-reporting-server'>
  10931. <title>Setting Up Your Own Error Reporting Server</title>
  10932. <para>
  10933. If you want to set up your own error reporting server, you
  10934. can obtain the code from the Git repository at
  10935. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  10936. Instructions on how to set it up are in the README document.
  10937. </para>
  10938. </section>
  10939. </section>
  10940. </chapter>
  10941. <!--
  10942. vim: expandtab tw=80 ts=4
  10943. -->