dev-manual-common-tasks.xml 650 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538
  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. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> into
  18. multiple layers.
  19. Layers allow you to isolate different types of customizations from
  20. each other.
  21. You might find it tempting to keep everything in one layer when
  22. working on a single project.
  23. However, the more modular your Metadata, the easier
  24. it is to cope with future changes.
  25. </para>
  26. <para>
  27. To illustrate how layers are used to keep things modular, consider
  28. machine customizations.
  29. These types of customizations typically reside in a special layer,
  30. rather than a general layer, called a Board Support Package (BSP)
  31. Layer.
  32. Furthermore, the machine customizations should be isolated from
  33. recipes and Metadata that support a new GUI environment,
  34. for example.
  35. This situation gives you a couple of layers: one for the machine
  36. configurations, and one for the GUI environment.
  37. It is important to understand, however, that the BSP layer can
  38. still make machine-specific additions to recipes within the GUI
  39. environment layer without polluting the GUI layer itself
  40. with those machine-specific changes.
  41. You can accomplish this through a recipe that is a BitBake append
  42. (<filename>.bbappend</filename>) file, which is described later
  43. in this section.
  44. <note>
  45. For general information on BSP layer structure, see the
  46. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp'>Board Support Packages (BSP) - Developer's Guide</ulink>.
  47. </note>
  48. </para>
  49. <para>
  50. </para>
  51. <section id='yocto-project-layers'>
  52. <title>Layers</title>
  53. <para>
  54. The <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  55. contains both general layers and BSP
  56. layers right out of the box.
  57. You can easily identify layers that ship with a
  58. Yocto Project release in the Source Directory by their
  59. folder names.
  60. Folders that represent layers typically have names that begin with
  61. the string <filename>meta-</filename>.
  62. <note>
  63. It is not a requirement that a layer name begin with the
  64. prefix <filename>meta-</filename>, but it is a commonly
  65. accepted standard in the Yocto Project community.
  66. </note>
  67. For example, when you set up the Source Directory structure,
  68. you will see several layers:
  69. <filename>meta</filename>,
  70. <filename>meta-skeleton</filename>,
  71. <filename>meta-selftest</filename>,
  72. <filename>meta-poky</filename>, and
  73. <filename>meta-yocto-bsp</filename>.
  74. Each of these folders represents a distinct layer.
  75. </para>
  76. <para>
  77. As another example, if you set up a local copy of the
  78. <filename>meta-intel</filename> Git repository
  79. and then explore the folder of that general layer,
  80. you will discover many Intel-specific BSP layers inside.
  81. For more information on BSP layers, see the
  82. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  83. section in the Yocto Project Board Support Package (BSP)
  84. Developer's Guide.
  85. </para>
  86. </section>
  87. <section id='creating-your-own-layer'>
  88. <title>Creating Your Own Layer</title>
  89. <para>
  90. It is very easy to create your own layers to use with the
  91. OpenEmbedded build system.
  92. The Yocto Project ships with scripts that speed up creating
  93. general layers and BSP layers.
  94. This section describes the steps you perform by hand to create
  95. a layer so that you can better understand them.
  96. For information about the layer-creation scripts, see the
  97. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'>Creating a New BSP Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  98. section in the Yocto Project Board Support Package (BSP)
  99. Developer's Guide and the
  100. "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>"
  101. section further down in this manual.
  102. </para>
  103. <para>
  104. Follow these general steps to create your layer without the aid of a script:
  105. <orderedlist>
  106. <listitem><para><emphasis>Check Existing Layers:</emphasis>
  107. Before creating a new layer, you should be sure someone
  108. has not already created a layer containing the Metadata
  109. you need.
  110. You can see the
  111. <ulink url='http://layers.openembedded.org/layerindex/layers/'><filename>OpenEmbedded Metadata Index</filename></ulink>
  112. for a list of layers from the OpenEmbedded community
  113. that can be used in the Yocto Project.
  114. </para></listitem>
  115. <listitem><para><emphasis>Create a Directory:</emphasis>
  116. Create the directory for your layer.
  117. While not strictly required, prepend the name of the
  118. folder with the string <filename>meta-</filename>.
  119. For example:
  120. <literallayout class='monospaced'>
  121. meta-mylayer
  122. meta-GUI_xyz
  123. meta-mymachine
  124. </literallayout>
  125. </para></listitem>
  126. <listitem><para><emphasis>Create a Layer Configuration
  127. File:</emphasis>
  128. Inside your new layer folder, you need to create a
  129. <filename>conf/layer.conf</filename> file.
  130. It is easiest to take an existing layer configuration
  131. file and copy that to your layer's
  132. <filename>conf</filename> directory and then modify the
  133. file as needed.</para>
  134. <para>The
  135. <filename>meta-yocto-bsp/conf/layer.conf</filename> file
  136. demonstrates the required syntax:
  137. <literallayout class='monospaced'>
  138. # We have a conf and classes directory, add to BBPATH
  139. BBPATH .= ":${LAYERDIR}"
  140. # We have recipes-* directories, add to BBFILES
  141. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  142. ${LAYERDIR}/recipes-*/*/*.bbappend"
  143. BBFILE_COLLECTIONS += "yoctobsp"
  144. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  145. BBFILE_PRIORITY_yoctobsp = "5"
  146. LAYERVERSION_yoctobsp = "3"
  147. </literallayout></para>
  148. <para>Here is an explanation of the example:
  149. <itemizedlist>
  150. <listitem><para>The configuration and
  151. classes directory is appended to
  152. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>.
  153. <note>
  154. All non-distro layers, which include all BSP
  155. layers, are expected to append the layer
  156. directory to the
  157. <filename>BBPATH</filename>.
  158. On the other hand, distro layers, such as
  159. <filename>meta-poky</filename>, can choose
  160. to enforce their own precedence over
  161. <filename>BBPATH</filename>.
  162. For an example of that syntax, see the
  163. <filename>layer.conf</filename> file for
  164. the <filename>meta-poky</filename> layer.
  165. </note></para></listitem>
  166. <listitem><para>The recipes for the layers are
  167. appended to
  168. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'>BBFILES</ulink></filename>.
  169. </para></listitem>
  170. <listitem><para>The
  171. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</ulink></filename>
  172. variable is then appended with the layer name.
  173. </para></listitem>
  174. <listitem><para>The
  175. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'>BBFILE_PATTERN</ulink></filename>
  176. variable is set to a regular expression and is
  177. used to match files from
  178. <filename>BBFILES</filename> into a particular
  179. layer.
  180. In this case,
  181. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  182. is used to make <filename>BBFILE_PATTERN</filename> match within the
  183. layer's path.</para></listitem>
  184. <listitem><para>The
  185. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'>BBFILE_PRIORITY</ulink></filename>
  186. variable then assigns a priority to the layer.
  187. Applying priorities is useful in situations
  188. where the same recipe might appear in multiple
  189. layers and allows you to choose the layer
  190. that takes precedence.</para></listitem>
  191. <listitem><para>The
  192. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'>LAYERVERSION</ulink></filename>
  193. variable optionally specifies the version of a
  194. layer as a single number.</para></listitem>
  195. </itemizedlist></para>
  196. <para>Note the use of the
  197. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  198. variable, which expands to the directory of the current
  199. layer.</para>
  200. <para>Through the use of the <filename>BBPATH</filename>
  201. variable, BitBake locates class files
  202. (<filename>.bbclass</filename>),
  203. configuration files, and files that are included
  204. with <filename>include</filename> and
  205. <filename>require</filename> statements.
  206. For these cases, BitBake uses the first file that
  207. matches the name found in <filename>BBPATH</filename>.
  208. This is similar to the way the <filename>PATH</filename>
  209. variable is used for binaries.
  210. It is recommended, therefore, that you use unique
  211. class and configuration
  212. filenames in your custom layer.</para></listitem>
  213. <listitem><para><emphasis>Add Content:</emphasis> Depending
  214. on the type of layer, add the content.
  215. If the layer adds support for a machine, add the machine
  216. configuration in a <filename>conf/machine/</filename>
  217. file within the layer.
  218. If the layer adds distro policy, add the distro
  219. configuration in a <filename>conf/distro/</filename>
  220. file within the layer.
  221. If the layer introduces new recipes, put the recipes
  222. you need in <filename>recipes-*</filename>
  223. subdirectories within the layer.
  224. <note>In order to be compliant with the Yocto Project,
  225. a layer must contain a
  226. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout-readme'>README file.</ulink>
  227. </note>
  228. </para></listitem>
  229. <listitem><para>
  230. <emphasis>Optionally Test for Compatibility:</emphasis>
  231. If you want permission to use the Yocto Project
  232. Compatibility logo with your layer or application that
  233. uses your layer, perform the steps to apply for
  234. compatibility.
  235. See the
  236. "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>"
  237. section for more information.
  238. </para></listitem>
  239. </orderedlist>
  240. </para>
  241. </section>
  242. <section id='best-practices-to-follow-when-creating-layers'>
  243. <title>Following Best Practices When Creating Layers</title>
  244. <para>
  245. To create layers that are easier to maintain and that will
  246. not impact builds for other machines, you should consider the
  247. information in the following list:
  248. <itemizedlist>
  249. <listitem><para>
  250. <emphasis>Avoid "Overlaying" Entire Recipes from Other Layers in Your Configuration:</emphasis>
  251. In other words, do not copy an entire recipe into your
  252. layer and then modify it.
  253. Rather, use an append file
  254. (<filename>.bbappend</filename>) to override only those
  255. parts of the original recipe you need to modify.
  256. </para></listitem>
  257. <listitem><para>
  258. <emphasis>Avoid Duplicating Include Files:</emphasis>
  259. Use append files (<filename>.bbappend</filename>)
  260. for each recipe that uses an include file.
  261. Or, if you are introducing a new recipe that requires
  262. the included file, use the path relative to the
  263. original layer directory to refer to the file.
  264. For example, use
  265. <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename>
  266. instead of
  267. <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>.
  268. If you're finding you have to overlay the include file,
  269. it could indicate a deficiency in the include file in
  270. the layer to which it originally belongs.
  271. If this is the case, you should try to address that
  272. deficiency instead of overlaying the include file.
  273. For example, you could address this by getting the
  274. maintainer of the include file to add a variable or
  275. variables to make it easy to override the parts needing
  276. to be overridden.
  277. </para></listitem>
  278. <listitem><para>
  279. <emphasis>Structure Your Layers:</emphasis>
  280. Proper use of overrides within append files and
  281. placement of machine-specific files within your layer
  282. can ensure that a build is not using the wrong Metadata
  283. and negatively impacting a build for a different
  284. machine.
  285. Following are some examples:
  286. <itemizedlist>
  287. <listitem><para>
  288. <emphasis>Modify Variables to Support a
  289. Different Machine:</emphasis>
  290. Suppose you have a layer named
  291. <filename>meta-one</filename> that adds support
  292. for building machine "one".
  293. To do so, you use an append file named
  294. <filename>base-files.bbappend</filename> and
  295. create a dependency on "foo" by altering the
  296. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  297. variable:
  298. <literallayout class='monospaced'>
  299. DEPENDS = "foo"
  300. </literallayout>
  301. The dependency is created during any build that
  302. includes the layer
  303. <filename>meta-one</filename>.
  304. However, you might not want this dependency
  305. for all machines.
  306. For example, suppose you are building for
  307. machine "two" but your
  308. <filename>bblayers.conf</filename> file has the
  309. <filename>meta-one</filename> layer included.
  310. During the build, the
  311. <filename>base-files</filename> for machine
  312. "two" will also have the dependency on
  313. <filename>foo</filename>.</para>
  314. <para>To make sure your changes apply only when
  315. building machine "one", use a machine override
  316. with the <filename>DEPENDS</filename> statement:
  317. <literallayout class='monospaced'>
  318. DEPENDS_one = "foo"
  319. </literallayout>
  320. You should follow the same strategy when using
  321. <filename>_append</filename> and
  322. <filename>_prepend</filename> operations:
  323. <literallayout class='monospaced'>
  324. DEPENDS_append_one = " foo"
  325. DEPENDS_prepend_one = "foo "
  326. </literallayout>
  327. As an actual example, here's a line from the recipe
  328. for gnutls, which adds dependencies on
  329. "argp-standalone" when building with the musl C
  330. library:
  331. <literallayout class='monospaced'>
  332. DEPENDS_append_libc-musl = " argp-standalone"
  333. </literallayout>
  334. <note>
  335. Avoiding "+=" and "=+" and using
  336. machine-specific
  337. <filename>_append</filename>
  338. and <filename>_prepend</filename> operations
  339. is recommended as well.
  340. </note>
  341. </para></listitem>
  342. <listitem><para>
  343. <emphasis>Place Machine-Specific Files in
  344. Machine-Specific Locations:</emphasis>
  345. When you have a base recipe, such as
  346. <filename>base-files.bb</filename>, that
  347. contains a
  348. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  349. statement to a file, you can use an append file
  350. to cause the build to use your own version of
  351. the file.
  352. For example, an append file in your layer at
  353. <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename>
  354. could extend
  355. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  356. using
  357. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  358. as follows:
  359. <literallayout class='monospaced'>
  360. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  361. </literallayout>
  362. The build for machine "one" will pick up your
  363. machine-specific file as long as you have the
  364. file in
  365. <filename>meta-one/recipes-core/base-files/base-files/</filename>.
  366. However, if you are building for a different
  367. machine and the
  368. <filename>bblayers.conf</filename> file includes
  369. the <filename>meta-one</filename> layer and
  370. the location of your machine-specific file is
  371. the first location where that file is found
  372. according to <filename>FILESPATH</filename>,
  373. builds for all machines will also use that
  374. machine-specific file.</para>
  375. <para>You can make sure that a machine-specific
  376. file is used for a particular machine by putting
  377. the file in a subdirectory specific to the
  378. machine.
  379. For example, rather than placing the file in
  380. <filename>meta-one/recipes-core/base-files/base-files/</filename>
  381. as shown above, put it in
  382. <filename>meta-one/recipes-core/base-files/base-files/one/</filename>.
  383. Not only does this make sure the file is used
  384. only when building for machine "one", but the
  385. build process locates the file more quickly.</para>
  386. <para>In summary, you need to place all files
  387. referenced from <filename>SRC_URI</filename>
  388. in a machine-specific subdirectory within the
  389. layer in order to restrict those files to
  390. machine-specific builds.
  391. </para></listitem>
  392. </itemizedlist>
  393. </para></listitem>
  394. <listitem><para>
  395. <emphasis>Perform Steps to Apply for Yocto Project Compatibility:</emphasis>
  396. If you want permission to use the
  397. Yocto Project Compatibility logo with your layer
  398. or application that uses your layer, perform the
  399. steps to apply for compatibility.
  400. See the
  401. "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>"
  402. section for more information.
  403. </para></listitem>
  404. <listitem><para>
  405. <emphasis>Follow the Layer Naming Convention:</emphasis>
  406. Store custom layers in a Git repository that use the
  407. <filename>meta-<replaceable>layer_name</replaceable></filename>
  408. format.
  409. </para></listitem>
  410. <listitem><para>
  411. <emphasis>Group Your Layers Locally:</emphasis>
  412. Clone your repository alongside other cloned
  413. <filename>meta</filename> directories from the
  414. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  415. </para></listitem>
  416. </itemizedlist>
  417. </para>
  418. </section>
  419. <section id='making-sure-your-layer-is-compatible-with-yocto-project'>
  420. <title>Making Sure Your Layer is Compatible With Yocto Project</title>
  421. <para>
  422. When you create a layer used with the Yocto Project, it is
  423. advantageous to make sure that the layer interacts well with
  424. existing Yocto Project layers (i.e. the layer is compatible
  425. with the Yocto Project).
  426. Ensuring compatibility makes the layer easy to be consumed
  427. by others in the Yocto Project community and could allow you
  428. permission to use the Yocto Project Compatible Logo.
  429. <note>
  430. Only Yocto Project member organizations are permitted to
  431. use the Yocto Project Compatible Logo.
  432. The logo is not available for general use.
  433. For information on how to become a Yocto Project member
  434. organization, see the
  435. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>.
  436. </note>
  437. </para>
  438. <para>
  439. The Yocto Project Compatibility Program consists of a layer
  440. application process that requests permission to use the Yocto
  441. Project Compatibility Logo for your layer and application.
  442. The process consists of two parts:
  443. <orderedlist>
  444. <listitem><para>
  445. Successfully passing a script
  446. (<filename>yocto-check-layer</filename>) that
  447. when run against your layer, tests it against
  448. constraints based on experiences of how layers have
  449. worked in the real world and where pitfalls have been
  450. found.
  451. Getting a "PASS" result from the script is required for
  452. successful compatibility registration.
  453. </para></listitem>
  454. <listitem><para>
  455. Completion of an application acceptance form, which
  456. you can find at
  457. <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>.
  458. </para></listitem>
  459. </orderedlist>
  460. </para>
  461. <para>
  462. To be granted permission to use the logo, you need to satisfy
  463. the following:
  464. <itemizedlist>
  465. <listitem><para>
  466. Be able to check the box indicating that you
  467. got a "PASS" when running the script against your
  468. layer.
  469. </para></listitem>
  470. <listitem><para>
  471. Answer "Yes" to the questions on the form or have an
  472. acceptable explanation for any questions answered "No".
  473. </para></listitem>
  474. <listitem><para>
  475. You need to be a Yocto Project Member Organization.
  476. </para></listitem>
  477. </itemizedlist>
  478. </para>
  479. <para>
  480. The remainder of this section presents information on the
  481. registration form and on the
  482. <filename>yocto-check-layer</filename> script.
  483. </para>
  484. <section id='yocto-project-compatible-program-application'>
  485. <title>Yocto Project Compatible Program Application</title>
  486. <para>
  487. Use the form to apply for your layer's approval.
  488. Upon successful application, you can use the Yocto
  489. Project Compatibility Logo with your layer and the
  490. application that uses your layer.
  491. </para>
  492. <para>
  493. To access the form, use this link:
  494. <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>.
  495. Follow the instructions on the form to complete your
  496. application.
  497. </para>
  498. <para>
  499. The application consists of the following sections:
  500. <itemizedlist>
  501. <listitem><para>
  502. <emphasis>Contact Information:</emphasis>
  503. Provide your contact information as the fields
  504. require.
  505. Along with your information, provide the
  506. released versions of the Yocto Project for which
  507. your layer is compatible.
  508. </para></listitem>
  509. <listitem><para>
  510. <emphasis>Acceptance Criteria:</emphasis>
  511. Provide "Yes" or "No" answers for each of the
  512. items in the checklist.
  513. Space exists at the bottom of the form for any
  514. explanations for items for which you answered "No".
  515. </para></listitem>
  516. <listitem><para>
  517. <emphasis>Recommendations:</emphasis>
  518. Provide answers for the questions regarding Linux
  519. kernel use and build success.
  520. </para></listitem>
  521. </itemizedlist>
  522. </para>
  523. </section>
  524. <section id='yocto-check-layer-script'>
  525. <title><filename>yocto-check-layer</filename> Script</title>
  526. <para>
  527. The <filename>yocto-check-layer</filename> script
  528. provides you a way to assess how compatible your layer is
  529. with the Yocto Project.
  530. You should run this script prior to using the form to
  531. apply for compatibility as described in the previous
  532. section.
  533. You need to achieve a "PASS" result in order to have
  534. your application form successfully processed.
  535. </para>
  536. <para>
  537. The script divides tests into three areas: COMMON, BSD,
  538. and DISTRO.
  539. For example, given a distribution layer (DISTRO), the
  540. layer must pass both the COMMON and DISTRO related tests.
  541. Furthermore, if your layer is a BSP layer, the layer must
  542. pass the COMMON and BSP set of tests.
  543. </para>
  544. <para>
  545. To execute the script, enter the following commands from
  546. your build directory:
  547. <literallayout class='monospaced'>
  548. $ source oe-init-build-env
  549. $ yocto-check-layer <replaceable>your_layer_directory</replaceable>
  550. </literallayout>
  551. Be sure to provide the actual directory for your layer
  552. as part of the command.
  553. </para>
  554. <para>
  555. Entering the command causes the script to determine the
  556. type of layer and then to execute a set of specific
  557. tests against the layer.
  558. The following list overviews the test:
  559. <itemizedlist>
  560. <listitem><para>
  561. <filename>common.test_readme</filename>:
  562. Tests if a <filename>README</filename> file
  563. exists in the layer and the file is not empty.
  564. </para></listitem>
  565. <listitem><para>
  566. <filename>common.test_parse</filename>:
  567. Tests to make sure that BitBake can parse the
  568. files without error (i.e.
  569. <filename>bitbake -p</filename>).
  570. </para></listitem>
  571. <listitem><para>
  572. <filename>common.test_show_environment</filename>:
  573. Tests that the global or per-recipe environment
  574. is in order without errors (i.e.
  575. <filename>bitbake -e</filename>).
  576. </para></listitem>
  577. <listitem><para>
  578. <filename>common.test_signatures</filename>:
  579. Tests to be sure that BSP and DISTRO layers do not
  580. come with recipes that change signatures.
  581. </para></listitem>
  582. <listitem><para>
  583. <filename>bsp.test_bsp_defines_machines</filename>:
  584. Tests if a BSP layer has machine configurations.
  585. </para></listitem>
  586. <listitem><para>
  587. <filename>bsp.test_bsp_no_set_machine</filename>:
  588. Tests to ensure a BSP layer does not set the
  589. machine when the layer is added.
  590. </para></listitem>
  591. <listitem><para>
  592. <filename>distro.test_distro_defines_distros</filename>:
  593. Tests if a DISTRO layer has distro configurations.
  594. </para></listitem>
  595. <listitem><para>
  596. <filename>distro.test_distro_no_set_distro</filename>:
  597. Tests to ensure a DISTRO layer does not set the
  598. distribution when the layer is added.
  599. </para></listitem>
  600. </itemizedlist>
  601. </para>
  602. </section>
  603. </section>
  604. <section id='enabling-your-layer'>
  605. <title>Enabling Your Layer</title>
  606. <para>
  607. Before the OpenEmbedded build system can use your new layer,
  608. you need to enable it.
  609. To enable your layer, simply add your layer's path to the
  610. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename>
  611. variable in your <filename>conf/bblayers.conf</filename> file,
  612. which is found in the
  613. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  614. The following example shows how to enable a layer named
  615. <filename>meta-mylayer</filename>:
  616. <literallayout class='monospaced'>
  617. LCONF_VERSION = "6"
  618. BBPATH = "${TOPDIR}"
  619. BBFILES ?= ""
  620. BBLAYERS ?= " \
  621. $HOME/poky/meta \
  622. $HOME/poky/meta-poky \
  623. $HOME/poky/meta-yocto-bsp \
  624. $HOME/poky/meta-mylayer \
  625. "
  626. </literallayout>
  627. </para>
  628. <para>
  629. BitBake parses each <filename>conf/layer.conf</filename> file
  630. as specified in the <filename>BBLAYERS</filename> variable
  631. within the <filename>conf/bblayers.conf</filename> file.
  632. During the processing of each
  633. <filename>conf/layer.conf</filename> file, BitBake adds the
  634. recipes, classes and configurations contained within the
  635. particular layer to the source directory.
  636. </para>
  637. </section>
  638. <section id='using-bbappend-files'>
  639. <title>Using .bbappend Files in Your Layer</title>
  640. <para>
  641. A recipe that appends Metadata to another recipe is called a
  642. BitBake append file.
  643. A BitBake append file uses the <filename>.bbappend</filename>
  644. file type suffix, while the corresponding recipe to which
  645. Metadata is being appended uses the <filename>.bb</filename>
  646. file type suffix.
  647. </para>
  648. <para>
  649. You can use a <filename>.bbappend</filename> file in your
  650. layer to make additions or changes to the content of another
  651. layer's recipe without having to copy the other layer's
  652. recipe into your layer.
  653. Your <filename>.bbappend</filename> file resides in your layer,
  654. while the main <filename>.bb</filename> recipe file to
  655. which you are appending Metadata resides in a different layer.
  656. </para>
  657. <para>
  658. Being able to append information to an existing recipe not only
  659. avoids duplication, but also automatically applies recipe
  660. changes from a different layer into your layer.
  661. If you were copying recipes, you would have to manually merge
  662. changes as they occur.
  663. </para>
  664. <para>
  665. When you create an append file, you must use the same root
  666. name as the corresponding recipe file.
  667. For example, the append file
  668. <filename>someapp_&DISTRO;.bbappend</filename> must apply to
  669. <filename>someapp_&DISTRO;.bb</filename>.
  670. This means the original recipe and append file names are
  671. version number-specific.
  672. If the corresponding recipe is renamed to update to a newer
  673. version, you must also rename and possibly update
  674. the corresponding <filename>.bbappend</filename> as well.
  675. During the build process, BitBake displays an error on starting
  676. if it detects a <filename>.bbappend</filename> file that does
  677. not have a corresponding recipe with a matching name.
  678. See the
  679. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink>
  680. variable for information on how to handle this error.
  681. </para>
  682. <para>
  683. As an example, consider the main formfactor recipe and a
  684. corresponding formfactor append file both from the
  685. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  686. Here is the main formfactor recipe, which is named
  687. <filename>formfactor_0.0.bb</filename> and located in the
  688. "meta" layer at
  689. <filename>meta/recipes-bsp/formfactor</filename>:
  690. <literallayout class='monospaced'>
  691. SUMMARY = "Device formfactor information"
  692. SECTION = "base"
  693. LICENSE = "MIT"
  694. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  695. PR = "r45"
  696. SRC_URI = "file://config file://machconfig"
  697. S = "${WORKDIR}"
  698. PACKAGE_ARCH = "${MACHINE_ARCH}"
  699. INHIBIT_DEFAULT_DEPS = "1"
  700. do_install() {
  701. # Install file only if it has contents
  702. install -d ${D}${sysconfdir}/formfactor/
  703. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  704. if [ -s "${S}/machconfig" ]; then
  705. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  706. fi
  707. } </literallayout>
  708. In the main recipe, note the
  709. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  710. variable, which tells the OpenEmbedded build system where to
  711. find files during the build.
  712. </para>
  713. <para>
  714. Following is the append file, which is named
  715. <filename>formfactor_0.0.bbappend</filename> and is from the
  716. Raspberry Pi BSP Layer named
  717. <filename>meta-raspberrypi</filename>.
  718. The file is in the layer at
  719. <filename>recipes-bsp/formfactor</filename>:
  720. <literallayout class='monospaced'>
  721. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  722. </literallayout>
  723. </para>
  724. <para>
  725. By default, the build system uses the
  726. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  727. variable to locate files.
  728. This append file extends the locations by setting the
  729. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  730. variable.
  731. Setting this variable in the <filename>.bbappend</filename>
  732. file is the most reliable and recommended method for adding
  733. directories to the search path used by the build system
  734. to find files.
  735. </para>
  736. <para>
  737. The statement in this example extends the directories to
  738. include
  739. <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>,
  740. which resolves to a directory named
  741. <filename>formfactor</filename> in the same directory
  742. in which the append file resides (i.e.
  743. <filename>meta-raspberrypi/recipes-bsp/formfactor</filename>.
  744. This implies that you must have the supporting directory
  745. structure set up that will contain any files or patches you
  746. will be including from the layer.
  747. </para>
  748. <para>
  749. Using the immediate expansion assignment operator
  750. <filename>:=</filename> is important because of the reference
  751. to <filename>THISDIR</filename>.
  752. The trailing colon character is important as it ensures that
  753. items in the list remain colon-separated.
  754. <note>
  755. <para>
  756. BitBake automatically defines the
  757. <filename>THISDIR</filename> variable.
  758. You should never set this variable yourself.
  759. Using "_prepend" as part of the
  760. <filename>FILESEXTRAPATHS</filename> ensures your path
  761. will be searched prior to other paths in the final
  762. list.
  763. </para>
  764. <para>
  765. Also, not all append files add extra files.
  766. Many append files simply exist to add build options
  767. (e.g. <filename>systemd</filename>).
  768. For these cases, your append file would not even
  769. use the <filename>FILESEXTRAPATHS</filename> statement.
  770. </para>
  771. </note>
  772. </para>
  773. </section>
  774. <section id='prioritizing-your-layer'>
  775. <title>Prioritizing Your Layer</title>
  776. <para>
  777. Each layer is assigned a priority value.
  778. Priority values control which layer takes precedence if there
  779. are recipe files with the same name in multiple layers.
  780. For these cases, the recipe file from the layer with a higher
  781. priority number takes precedence.
  782. Priority values also affect the order in which multiple
  783. <filename>.bbappend</filename> files for the same recipe are
  784. applied.
  785. You can either specify the priority manually, or allow the
  786. build system to calculate it based on the layer's dependencies.
  787. </para>
  788. <para>
  789. To specify the layer's priority manually, use the
  790. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  791. variable.
  792. For example:
  793. <literallayout class='monospaced'>
  794. BBFILE_PRIORITY_mylayer = "1"
  795. </literallayout>
  796. </para>
  797. <note>
  798. <para>It is possible for a recipe with a lower version number
  799. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  800. in a layer that has a higher priority to take precedence.</para>
  801. <para>Also, the layer priority does not currently affect the
  802. precedence order of <filename>.conf</filename>
  803. or <filename>.bbclass</filename> files.
  804. Future versions of BitBake might address this.</para>
  805. </note>
  806. </section>
  807. <section id='managing-layers'>
  808. <title>Managing Layers</title>
  809. <para>
  810. You can use the BitBake layer management tool to provide a view
  811. into the structure of recipes across a multi-layer project.
  812. Being able to generate output that reports on configured layers
  813. with their paths and priorities and on
  814. <filename>.bbappend</filename> files and their applicable
  815. recipes can help to reveal potential problems.
  816. </para>
  817. <para>
  818. Use the following form when running the layer management tool.
  819. <literallayout class='monospaced'>
  820. $ bitbake-layers <replaceable>command</replaceable> [<replaceable>arguments</replaceable>]
  821. </literallayout>
  822. The following list describes the available commands:
  823. <itemizedlist>
  824. <listitem><para><filename><emphasis>help:</emphasis></filename>
  825. Displays general help or help on a specified command.
  826. </para></listitem>
  827. <listitem><para><filename><emphasis>show-layers:</emphasis></filename>
  828. Shows the current configured layers.
  829. </para></listitem>
  830. <listitem><para><filename><emphasis>show-recipes:</emphasis></filename>
  831. Lists available recipes and the layers that provide them.
  832. </para></listitem>
  833. <listitem><para><filename><emphasis>show-overlayed:</emphasis></filename>
  834. Lists overlayed recipes.
  835. A recipe is overlayed when a recipe with the same name
  836. exists in another layer that has a higher layer
  837. priority.
  838. </para></listitem>
  839. <listitem><para><filename><emphasis>show-appends:</emphasis></filename>
  840. Lists <filename>.bbappend</filename> files and the
  841. recipe files to which they apply.
  842. </para></listitem>
  843. <listitem><para><filename><emphasis>show-cross-depends:</emphasis></filename>
  844. Lists dependency relationships between recipes that
  845. cross layer boundaries.
  846. </para></listitem>
  847. <listitem><para><filename><emphasis>add-layer:</emphasis></filename>
  848. Adds a layer to <filename>bblayers.conf</filename>.
  849. </para></listitem>
  850. <listitem><para><filename><emphasis>remove-layer:</emphasis></filename>
  851. Removes a layer from <filename>bblayers.conf</filename>
  852. </para></listitem>
  853. <listitem><para><filename><emphasis>flatten:</emphasis></filename>
  854. Flattens the layer configuration into a separate output
  855. directory.
  856. Flattening your layer configuration builds a "flattened"
  857. directory that contains the contents of all layers,
  858. with any overlayed recipes removed and any
  859. <filename>.bbappend</filename> files appended to the
  860. corresponding recipes.
  861. You might have to perform some manual cleanup of the
  862. flattened layer as follows:
  863. <itemizedlist>
  864. <listitem><para>Non-recipe files (such as patches)
  865. are overwritten.
  866. The flatten command shows a warning for these
  867. files.
  868. </para></listitem>
  869. <listitem><para>Anything beyond the normal layer
  870. setup has been added to the
  871. <filename>layer.conf</filename> file.
  872. Only the lowest priority layer's
  873. <filename>layer.conf</filename> is used.
  874. </para></listitem>
  875. <listitem><para>Overridden and appended items from
  876. <filename>.bbappend</filename> files need to be
  877. cleaned up.
  878. The contents of each
  879. <filename>.bbappend</filename> end up in the
  880. flattened recipe.
  881. However, if there are appended or changed
  882. variable values, you need to tidy these up
  883. yourself.
  884. Consider the following example.
  885. Here, the <filename>bitbake-layers</filename>
  886. command adds the line
  887. <filename>#### bbappended ...</filename> so that
  888. you know where the following lines originate:
  889. <literallayout class='monospaced'>
  890. ...
  891. DESCRIPTION = "A useful utility"
  892. ...
  893. EXTRA_OECONF = "--enable-something"
  894. ...
  895. #### bbappended from meta-anotherlayer ####
  896. DESCRIPTION = "Customized utility"
  897. EXTRA_OECONF += "--enable-somethingelse"
  898. </literallayout>
  899. Ideally, you would tidy up these utilities as
  900. follows:
  901. <literallayout class='monospaced'>
  902. ...
  903. DESCRIPTION = "Customized utility"
  904. ...
  905. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  906. ...
  907. </literallayout>
  908. </para></listitem>
  909. </itemizedlist>
  910. </para></listitem>
  911. <listitem><para>
  912. <emphasis><filename>layerindex-fetch</filename>:</emphasis>
  913. Fetches a layer from a layer index, along with its
  914. dependent layers, and adds the layers to the
  915. <filename>conf/bblayers.conf</filename> file.
  916. </para></listitem>
  917. <listitem><para>
  918. <emphasis><filename>layerindex-show-depends</filename>:</emphasis>
  919. Finds layer dependencies from the layer index.
  920. </para></listitem>
  921. <listitem><para>
  922. <emphasis><filename>create-layer</filename>:</emphasis>
  923. Creates a basic layer.
  924. </para></listitem>
  925. </itemizedlist>
  926. </para>
  927. </section>
  928. <section id='creating-a-general-layer-using-the-bitbake-layers-script'>
  929. <title>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</title>
  930. <para>
  931. The <filename>bitbake-layers</filename> script with the
  932. <filename>create-layer</filename> subcommand simplifies
  933. creating a new general layer.
  934. <note>
  935. For information on BSP layers, see the
  936. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  937. section in the Yocto Project Board Specific (BSP)
  938. Developer's Guide.
  939. </note>
  940. The default mode of the script's operation with this
  941. subcommand is to create a layer with the following:
  942. <itemizedlist>
  943. <listitem><para>A layer priority of 6.
  944. </para></listitem>
  945. <listitem><para>A <filename>conf</filename>
  946. subdirectory that contains a
  947. <filename>layer.conf</filename> file.
  948. </para></listitem>
  949. <listitem><para>
  950. A <filename>recipes-example</filename> subdirectory
  951. that contains a further subdirectory named
  952. <filename>example</filename>, which contains
  953. an <filename>example.bb</filename> recipe file.
  954. </para></listitem>
  955. <listitem><para>A <filename >COPYING.MIT</filename>,
  956. which is the license statement for the layer.
  957. The script assumes you want to use the MIT license,
  958. which is typical for most layers, for the contents of
  959. the layer itself.
  960. </para></listitem>
  961. <listitem><para>
  962. A <filename>README</filename> file, which is a file
  963. describing the contents of your new layer.
  964. </para></listitem>
  965. </itemizedlist>
  966. </para>
  967. <para>
  968. In its simplest form, you can use the following command form
  969. to create a layer.
  970. The command creates a layer whose name corresponds to
  971. <replaceable>your_layer_name</replaceable> in the current
  972. directory:
  973. <literallayout class='monospaced'>
  974. $ bitbake-layers create-layer <replaceable>your_layer_name</replaceable>
  975. </literallayout>
  976. </para>
  977. <para>
  978. If you want to set the priority of the layer to other than the
  979. default value of "6", you can either use the
  980. <filename>&dash;&dash;priority</filename> option or you can
  981. edit the
  982. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  983. value in the <filename>conf/layer.conf</filename> after the
  984. script creates it.
  985. Furthermore, if you want to give the example recipe file
  986. some name other than the default, you can
  987. use the
  988. <filename>&dash;&dash;example-recipe-name</filename> option.
  989. </para>
  990. <para>
  991. The easiest way to see how the
  992. <filename>bitbake-layers create-layer</filename> command
  993. works is to experiment with the script.
  994. You can also read the usage information by entering the
  995. following:
  996. <literallayout class='monospaced'>
  997. $ bitbake-layers create-layer --help
  998. NOTE: Starting bitbake server...
  999. usage: bitbake-layers create-layer [-h] [--priority PRIORITY]
  1000. [--example-recipe-name EXAMPLERECIPE]
  1001. layerdir
  1002. Create a basic layer
  1003. positional arguments:
  1004. layerdir Layer directory to create
  1005. optional arguments:
  1006. -h, --help show this help message and exit
  1007. --priority PRIORITY, -p PRIORITY
  1008. Layer directory to create
  1009. --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE
  1010. Filename of the example recipe
  1011. </literallayout>
  1012. </para>
  1013. <para>
  1014. Once you create your general layer, you must add it to your
  1015. <filename>bblayers.conf</filename> file.
  1016. You can add your layer by using the
  1017. <filename>bitbake-layers add-layer</filename> command:
  1018. <literallayout class='monospaced'>
  1019. $ bitbake-layers add-layer <replaceable>your_layer_name</replaceable>
  1020. </literallayout>
  1021. Here is an example where a layer named
  1022. <filename>meta-scottrif</filename> is added and then the
  1023. layers are shown using the
  1024. <filename>bitbake-layers show-layers</filename> command:
  1025. <literallayout class='monospaced'>
  1026. $ bitbake-layers add-layer meta-scottrif
  1027. NOTE: Starting bitbake server...
  1028. Loading cache: 100% |############################################| Time: 0:00:00
  1029. Loaded 1275 entries from dependency cache.
  1030. Parsing recipes: 100% |##########################################| Time: 0:00:00
  1031. Parsing of 819 .bb files complete (817 cached, 2 parsed). 1276 targets, 44 skipped, 0 masked, 0 errors.
  1032. $ bitbake-layers show-layers
  1033. NOTE: Starting bitbake server...
  1034. layer path priority
  1035. ==========================================================================
  1036. meta /home/scottrif/poky/meta 5
  1037. meta-poky /home/scottrif/poky/meta-poky 5
  1038. meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5
  1039. meta-mylayer /home/scottrif/meta-mylayer 6
  1040. workspace /home/scottrif/poky/build/workspace 99
  1041. meta-scottrif /home/scottrif/poky/build/meta-scottrif 6
  1042. </literallayout>
  1043. Adding the layer to this file enables the build system to
  1044. locate the layer during the build.
  1045. </para>
  1046. </section>
  1047. </section>
  1048. <section id='usingpoky-extend-customimage'>
  1049. <title>Customizing Images</title>
  1050. <para>
  1051. You can customize images to satisfy particular requirements.
  1052. This section describes several methods and provides guidelines for each.
  1053. </para>
  1054. <section id='usingpoky-extend-customimage-localconf'>
  1055. <title>Customizing Images Using <filename>local.conf</filename></title>
  1056. <para>
  1057. Probably the easiest way to customize an image is to add a
  1058. package by way of the <filename>local.conf</filename>
  1059. configuration file.
  1060. Because it is limited to local use, this method generally only
  1061. allows you to add packages and is not as flexible as creating
  1062. your own customized image.
  1063. When you add packages using local variables this way, you need
  1064. to realize that these variable changes are in effect for every
  1065. build and consequently affect all images, which might not
  1066. be what you require.
  1067. </para>
  1068. <para>
  1069. To add a package to your image using the local configuration
  1070. file, use the
  1071. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1072. variable with the <filename>_append</filename> operator:
  1073. <literallayout class='monospaced'>
  1074. IMAGE_INSTALL_append = " strace"
  1075. </literallayout>
  1076. Use of the syntax is important - specifically, the space between
  1077. the quote and the package name, which is
  1078. <filename>strace</filename> in this example.
  1079. This space is required since the <filename>_append</filename>
  1080. operator does not add the space.
  1081. </para>
  1082. <para>
  1083. Furthermore, you must use <filename>_append</filename> instead
  1084. of the <filename>+=</filename> operator if you want to avoid
  1085. ordering issues.
  1086. The reason for this is because doing so unconditionally appends
  1087. to the variable and avoids ordering problems due to the
  1088. variable being set in image recipes and
  1089. <filename>.bbclass</filename> files with operators like
  1090. <filename>?=</filename>.
  1091. Using <filename>_append</filename> ensures the operation takes
  1092. affect.
  1093. </para>
  1094. <para>
  1095. As shown in its simplest use,
  1096. <filename>IMAGE_INSTALL_append</filename> affects all images.
  1097. It is possible to extend the syntax so that the variable
  1098. applies to a specific image only.
  1099. Here is an example:
  1100. <literallayout class='monospaced'>
  1101. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  1102. </literallayout>
  1103. This example adds <filename>strace</filename> to the
  1104. <filename>core-image-minimal</filename> image only.
  1105. </para>
  1106. <para>
  1107. You can add packages using a similar approach through the
  1108. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename>
  1109. variable.
  1110. If you use this variable, only
  1111. <filename>core-image-*</filename> images are affected.
  1112. </para>
  1113. </section>
  1114. <section id='usingpoky-extend-customimage-imagefeatures'>
  1115. <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and
  1116. <filename>EXTRA_IMAGE_FEATURES</filename></title>
  1117. <para>
  1118. Another method for customizing your image is to enable or
  1119. disable high-level image features by using the
  1120. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  1121. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  1122. variables.
  1123. Although the functions for both variables are nearly equivalent,
  1124. best practices dictate using <filename>IMAGE_FEATURES</filename>
  1125. from within a recipe and using
  1126. <filename>EXTRA_IMAGE_FEATURES</filename> from within
  1127. your <filename>local.conf</filename> file, which is found in the
  1128. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1129. </para>
  1130. <para>
  1131. To understand how these features work, the best reference is
  1132. <filename>meta/classes/core-image.bbclass</filename>.
  1133. This class lists out the available
  1134. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  1135. of which most map to package groups while some, such as
  1136. <filename>debug-tweaks</filename> and
  1137. <filename>read-only-rootfs</filename>, resolve as general
  1138. configuration settings.
  1139. </para>
  1140. <para>
  1141. In summary, the file looks at the contents of the
  1142. <filename>IMAGE_FEATURES</filename> variable and then maps
  1143. or configures the feature accordingly.
  1144. Based on this information, the build system automatically
  1145. adds the appropriate packages or configurations to the
  1146. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  1147. variable.
  1148. Effectively, you are enabling extra features by extending the
  1149. class or creating a custom class for use with specialized image
  1150. <filename>.bb</filename> files.
  1151. </para>
  1152. <para>
  1153. Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable
  1154. from within your local configuration file.
  1155. Using a separate area from which to enable features with
  1156. this variable helps you avoid overwriting the features in the
  1157. image recipe that are enabled with
  1158. <filename>IMAGE_FEATURES</filename>.
  1159. The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added
  1160. to <filename>IMAGE_FEATURES</filename> within
  1161. <filename>meta/conf/bitbake.conf</filename>.
  1162. </para>
  1163. <para>
  1164. To illustrate how you can use these variables to modify your
  1165. image, consider an example that selects the SSH server.
  1166. The Yocto Project ships with two SSH servers you can use
  1167. with your images: Dropbear and OpenSSH.
  1168. Dropbear is a minimal SSH server appropriate for
  1169. resource-constrained environments, while OpenSSH is a
  1170. well-known standard SSH server implementation.
  1171. By default, the <filename>core-image-sato</filename> image
  1172. is configured to use Dropbear.
  1173. The <filename>core-image-full-cmdline</filename> and
  1174. <filename>core-image-lsb</filename> images both
  1175. include OpenSSH.
  1176. The <filename>core-image-minimal</filename> image does not
  1177. contain an SSH server.
  1178. </para>
  1179. <para>
  1180. You can customize your image and change these defaults.
  1181. Edit the <filename>IMAGE_FEATURES</filename> variable
  1182. in your recipe or use the
  1183. <filename>EXTRA_IMAGE_FEATURES</filename> in your
  1184. <filename>local.conf</filename> file so that it configures the
  1185. image you are working with to include
  1186. <filename>ssh-server-dropbear</filename> or
  1187. <filename>ssh-server-openssh</filename>.
  1188. </para>
  1189. <note>
  1190. See the
  1191. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  1192. section in the Yocto Project Reference Manual for a complete
  1193. list of image features that ship with the Yocto Project.
  1194. </note>
  1195. </section>
  1196. <section id='usingpoky-extend-customimage-custombb'>
  1197. <title>Customizing Images Using Custom .bb Files</title>
  1198. <para>
  1199. You can also customize an image by creating a custom recipe
  1200. that defines additional software as part of the image.
  1201. The following example shows the form for the two lines you need:
  1202. <literallayout class='monospaced'>
  1203. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  1204. inherit core-image
  1205. </literallayout>
  1206. </para>
  1207. <para>
  1208. Defining the software using a custom recipe gives you total
  1209. control over the contents of the image.
  1210. It is important to use the correct names of packages in the
  1211. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1212. variable.
  1213. You must use the OpenEmbedded notation and not the Debian notation for the names
  1214. (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>).
  1215. </para>
  1216. <para>
  1217. The other method for creating a custom image is to base it on an existing image.
  1218. For example, if you want to create an image based on <filename>core-image-sato</filename>
  1219. but add the additional package <filename>strace</filename> to the image,
  1220. copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a
  1221. new <filename>.bb</filename> and add the following line to the end of the copy:
  1222. <literallayout class='monospaced'>
  1223. IMAGE_INSTALL += "strace"
  1224. </literallayout>
  1225. </para>
  1226. </section>
  1227. <section id='usingpoky-extend-customimage-customtasks'>
  1228. <title>Customizing Images Using Custom Package Groups</title>
  1229. <para>
  1230. For complex custom images, the best approach for customizing
  1231. an image is to create a custom package group recipe that is
  1232. used to build the image or images.
  1233. A good example of a package group recipe is
  1234. <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>.
  1235. </para>
  1236. <para>
  1237. If you examine that recipe, you see that the
  1238. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename>
  1239. variable lists the package group packages to produce.
  1240. The <filename>inherit packagegroup</filename> statement
  1241. sets appropriate default values and automatically adds
  1242. <filename>-dev</filename>, <filename>-dbg</filename>, and
  1243. <filename>-ptest</filename> complementary packages for each
  1244. package specified in the <filename>PACKAGES</filename>
  1245. statement.
  1246. <note>
  1247. The <filename>inherit packages</filename> should be
  1248. located near the top of the recipe, certainly before
  1249. the <filename>PACKAGES</filename> statement.
  1250. </note>
  1251. </para>
  1252. <para>
  1253. For each package you specify in <filename>PACKAGES</filename>,
  1254. you can use
  1255. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename>
  1256. and
  1257. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename>
  1258. entries to provide a list of packages the parent task package
  1259. should contain.
  1260. You can see examples of these further down in the
  1261. <filename>packagegroup-base.bb</filename> recipe.
  1262. </para>
  1263. <para>
  1264. Here is a short, fabricated example showing the same basic
  1265. pieces:
  1266. <literallayout class='monospaced'>
  1267. DESCRIPTION = "My Custom Package Groups"
  1268. inherit packagegroup
  1269. PACKAGES = "\
  1270. packagegroup-custom-apps \
  1271. packagegroup-custom-tools \
  1272. "
  1273. RDEPENDS_packagegroup-custom-apps = "\
  1274. dropbear \
  1275. portmap \
  1276. psplash"
  1277. RDEPENDS_packagegroup-custom-tools = "\
  1278. oprofile \
  1279. oprofileui-server \
  1280. lttng-tools"
  1281. RRECOMMENDS_packagegroup-custom-tools = "\
  1282. kernel-module-oprofile"
  1283. </literallayout>
  1284. </para>
  1285. <para>
  1286. In the previous example, two package group packages are created with their dependencies and their
  1287. recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and
  1288. <filename>packagegroup-custom-tools</filename>.
  1289. To build an image using these package group packages, you need to add
  1290. <filename>packagegroup-custom-apps</filename> and/or
  1291. <filename>packagegroup-custom-tools</filename> to
  1292. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>.
  1293. For other forms of image dependencies see the other areas of this section.
  1294. </para>
  1295. </section>
  1296. <section id='usingpoky-extend-customimage-image-name'>
  1297. <title>Customizing an Image Hostname</title>
  1298. <para>
  1299. By default, the configured hostname (i.e.
  1300. <filename>/etc/hostname</filename>) in an image is the
  1301. same as the machine name.
  1302. For example, if
  1303. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  1304. equals "qemux86", the configured hostname written to
  1305. <filename>/etc/hostname</filename> is "qemux86".
  1306. </para>
  1307. <para>
  1308. You can customize this name by altering the value of the
  1309. "hostname" variable in the
  1310. <filename>base-files</filename> recipe using either
  1311. an append file or a configuration file.
  1312. Use the following in an append file:
  1313. <literallayout class='monospaced'>
  1314. hostname="myhostname"
  1315. </literallayout>
  1316. Use the following in a configuration file:
  1317. <literallayout class='monospaced'>
  1318. hostname_pn-base-files = "myhostname"
  1319. </literallayout>
  1320. </para>
  1321. <para>
  1322. Changing the default value of the variable "hostname" can be
  1323. useful in certain situations.
  1324. For example, suppose you need to do extensive testing on an
  1325. image and you would like to easily identify the image
  1326. under test from existing images with typical default
  1327. hostnames.
  1328. In this situation, you could change the default hostname to
  1329. "testme", which results in all the images using the name
  1330. "testme".
  1331. Once testing is complete and you do not need to rebuild the
  1332. image for test any longer, you can easily reset the default
  1333. hostname.
  1334. </para>
  1335. <para>
  1336. Another point of interest is that if you unset the variable,
  1337. the image will have no default hostname in the filesystem.
  1338. Here is an example that unsets the variable in a
  1339. configuration file:
  1340. <literallayout class='monospaced'>
  1341. hostname_pn-base-files = ""
  1342. </literallayout>
  1343. Having no default hostname in the filesystem is suitable for
  1344. environments that use dynamic hostnames such as virtual
  1345. machines.
  1346. </para>
  1347. </section>
  1348. </section>
  1349. <section id='new-recipe-writing-a-new-recipe'>
  1350. <title>Writing a New Recipe</title>
  1351. <para>
  1352. Recipes (<filename>.bb</filename> files) are fundamental components
  1353. in the Yocto Project environment.
  1354. Each software component built by the OpenEmbedded build system
  1355. requires a recipe to define the component.
  1356. This section describes how to create, write, and test a new
  1357. recipe.
  1358. <note>
  1359. For information on variables that are useful for recipes and
  1360. for information about recipe naming issues, see the
  1361. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>"
  1362. section of the Yocto Project Reference Manual.
  1363. </note>
  1364. </para>
  1365. <section id='new-recipe-overview'>
  1366. <title>Overview</title>
  1367. <para>
  1368. The following figure shows the basic process for creating a
  1369. new recipe.
  1370. The remainder of the section provides details for the steps.
  1371. <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" />
  1372. </para>
  1373. </section>
  1374. <section id='new-recipe-locate-or-automatically-create-a-base-recipe'>
  1375. <title>Locate or Automatically Create a Base Recipe</title>
  1376. <para>
  1377. You can always write a recipe from scratch.
  1378. However, three choices exist that can help you quickly get a
  1379. start on a new recipe:
  1380. <itemizedlist>
  1381. <listitem><para>
  1382. <emphasis><filename>devtool add</filename>:</emphasis>
  1383. A command that assists in creating a recipe and
  1384. an environment conducive to development.
  1385. </para></listitem>
  1386. <listitem><para>
  1387. <emphasis><filename>recipetool create</filename>:</emphasis>
  1388. A command provided by the Yocto Project that automates
  1389. creation of a base recipe based on the source
  1390. files.
  1391. </para></listitem>
  1392. <listitem><para>
  1393. <emphasis>Existing Recipes:</emphasis>
  1394. Location and modification of an existing recipe that is
  1395. similar in function to the recipe you need.
  1396. </para></listitem>
  1397. </itemizedlist>
  1398. <note>
  1399. For information on recipe syntax, see the
  1400. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#recipe-syntax'>Recipe Syntax</ulink>"
  1401. section in the Yocto Project Overview Manual.
  1402. </note>
  1403. </para>
  1404. <section id='new-recipe-creating-the-base-recipe-using-devtool'>
  1405. <title>Creating the Base Recipe Using <filename>devtool add</filename></title>
  1406. <para>
  1407. The <filename>devtool add</filename> command uses the same
  1408. logic for auto-creating the recipe as
  1409. <filename>recipetool create</filename>, which is listed
  1410. below.
  1411. Additionally, however, <filename>devtool add</filename>
  1412. sets up an environment that makes it easy for you to
  1413. patch the source and to make changes to the recipe as
  1414. is often necessary when adding a recipe to build a new
  1415. piece of software to be included in a build.
  1416. </para>
  1417. <para>
  1418. You can find a complete description of the
  1419. <filename>devtool add</filename> command in the
  1420. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-a-closer-look-at-devtool-add'>A Closer Look at <filename>devtool</filename> add</ulink>"
  1421. section in the Yocto Project Application Development
  1422. and the Extensible Software Development Kit (eSDK) manual.
  1423. </para>
  1424. </section>
  1425. <section id='new-recipe-creating-the-base-recipe-using-recipetool'>
  1426. <title>Creating the Base Recipe Using <filename>recipetool create</filename></title>
  1427. <para>
  1428. <filename>recipetool create</filename> automates creation
  1429. of a base recipe given a set of source code files.
  1430. As long as you can extract or point to the source files,
  1431. the tool will construct a recipe and automatically
  1432. configure all pre-build information into the recipe.
  1433. For example, suppose you have an application that builds
  1434. using Autotools.
  1435. Creating the base recipe using
  1436. <filename>recipetool</filename> results in a recipe
  1437. that has the pre-build dependencies, license requirements,
  1438. and checksums configured.
  1439. </para>
  1440. <para>
  1441. To run the tool, you just need to be in your
  1442. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1443. and have sourced the build environment setup script
  1444. (i.e.
  1445. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>).
  1446. Here is the basic <filename>recipetool</filename> syntax:
  1447. <note>
  1448. Running <filename>recipetool -h</filename> or
  1449. <filename>recipetool create -h</filename> produces the
  1450. Python-generated help, which presented differently
  1451. than what follows here.
  1452. </note>
  1453. <literallayout class='monospaced'>
  1454. recipetool -h
  1455. recipetool create [-h]
  1456. recipetool [-d] [-q] [--color auto | always | never ] create -o <replaceable>OUTFILE</replaceable> [-m] [-x <replaceable>EXTERNALSRC</replaceable>] <replaceable>source</replaceable>
  1457. -d Enables debug output.
  1458. -q Outputs only errors (quiet mode).
  1459. --color Colorizes the output automatically, always, or never.
  1460. -h Displays Python generated syntax for recipetool.
  1461. create Causes recipetool to create a base recipe. The create
  1462. command is further defined with these options:
  1463. -o <replaceable>OUTFILE</replaceable> Specifies the full path and filename for the generated
  1464. recipe.
  1465. -m Causes the recipe to be machine-specific rather than
  1466. architecture-specific (default).
  1467. -x <replaceable>EXTERNALSRC</replaceable> Fetches and extracts source files from <replaceable>source</replaceable>
  1468. and places them in <replaceable>EXTERNALSRC</replaceable>.
  1469. <replaceable>source</replaceable> must be a URL.
  1470. -h Displays Python-generated syntax for create.
  1471. <replaceable>source</replaceable> Specifies the source code on which to base the
  1472. recipe.
  1473. </literallayout>
  1474. </para>
  1475. <para>
  1476. Running <filename>recipetool create -o</filename>&nbsp;<replaceable>OUTFILE</replaceable>
  1477. creates the base recipe and locates it properly in the
  1478. layer that contains your source files.
  1479. Following are some syntax examples:
  1480. </para>
  1481. <para>
  1482. Use this syntax to generate a recipe based on <replaceable>source</replaceable>.
  1483. Once generated, the recipe resides in the existing source
  1484. code layer:
  1485. <literallayout class='monospaced'>
  1486. recipetool create -o <replaceable>OUTFILE</replaceable>&nbsp;<replaceable>source</replaceable>
  1487. </literallayout>
  1488. Use this syntax to generate a recipe using code that you
  1489. extract from <replaceable>source</replaceable>.
  1490. The extracted code is placed in its own layer defined
  1491. by <replaceable>EXTERNALSRC</replaceable>.
  1492. <literallayout class='monospaced'>
  1493. recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable>
  1494. </literallayout>
  1495. Use this syntax to generate a recipe based on <replaceable>source</replaceable>.
  1496. The options direct <filename>recipetool</filename> to
  1497. generate debugging information.
  1498. Once generated, the recipe resides in the existing source
  1499. code layer:
  1500. <literallayout class='monospaced'>
  1501. recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable>
  1502. </literallayout>
  1503. </para>
  1504. </section>
  1505. <section id='new-recipe-locating-and-using-a-similar-recipe'>
  1506. <title>Locating and Using a Similar Recipe</title>
  1507. <para>
  1508. Before writing a recipe from scratch, it is often useful to
  1509. discover whether someone else has already written one that
  1510. meets (or comes close to meeting) your needs.
  1511. The Yocto Project and OpenEmbedded communities maintain many
  1512. recipes that might be candidates for what you are doing.
  1513. You can find a good central index of these recipes in the
  1514. <ulink url='http://layers.openembedded.org'>OpenEmbedded metadata index</ulink>.
  1515. </para>
  1516. <para>
  1517. Working from an existing recipe or a skeleton recipe is the
  1518. best way to get started.
  1519. Here are some points on both methods:
  1520. <itemizedlist>
  1521. <listitem><para><emphasis>Locate and modify a recipe that
  1522. is close to what you want to do:</emphasis>
  1523. This method works when you are familiar with the
  1524. current recipe space.
  1525. The method does not work so well for those new to
  1526. the Yocto Project or writing recipes.</para>
  1527. <para>Some risks associated with this method are
  1528. using a recipe that has areas totally unrelated to
  1529. what you are trying to accomplish with your recipe,
  1530. not recognizing areas of the recipe that you might
  1531. have to add from scratch, and so forth.
  1532. All these risks stem from unfamiliarity with the
  1533. existing recipe space.</para></listitem>
  1534. <listitem><para><emphasis>Use and modify the following
  1535. skeleton recipe:</emphasis>
  1536. If for some reason you do not want to use
  1537. <filename>recipetool</filename> and you cannot
  1538. find an existing recipe that is close to meeting
  1539. your needs, you can use the following structure to
  1540. provide the fundamental areas of a new recipe.
  1541. <literallayout class='monospaced'>
  1542. DESCRIPTION = ""
  1543. HOMEPAGE = ""
  1544. LICENSE = ""
  1545. SECTION = ""
  1546. DEPENDS = ""
  1547. LIC_FILES_CHKSUM = ""
  1548. SRC_URI = ""
  1549. </literallayout>
  1550. </para></listitem>
  1551. </itemizedlist>
  1552. </para>
  1553. </section>
  1554. </section>
  1555. <section id='new-recipe-storing-and-naming-the-recipe'>
  1556. <title>Storing and Naming the Recipe</title>
  1557. <para>
  1558. Once you have your base recipe, you should put it in your
  1559. own layer and name it appropriately.
  1560. Locating it correctly ensures that the OpenEmbedded build
  1561. system can find it when you use BitBake to process the
  1562. recipe.
  1563. </para>
  1564. <itemizedlist>
  1565. <listitem><para><emphasis>Storing Your Recipe:</emphasis>
  1566. The OpenEmbedded build system locates your recipe
  1567. through the layer's <filename>conf/layer.conf</filename>
  1568. file and the
  1569. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>
  1570. variable.
  1571. This variable sets up a path from which the build system can
  1572. locate recipes.
  1573. Here is the typical use:
  1574. <literallayout class='monospaced'>
  1575. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  1576. ${LAYERDIR}/recipes-*/*/*.bbappend"
  1577. </literallayout>
  1578. Consequently, you need to be sure you locate your new recipe
  1579. inside your layer such that it can be found.</para>
  1580. <para>You can find more information on how layers are
  1581. structured in the
  1582. "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
  1583. section.</para></listitem>
  1584. <listitem><para><emphasis>Naming Your Recipe:</emphasis>
  1585. When you name your recipe, you need to follow this naming
  1586. convention:
  1587. <literallayout class='monospaced'>
  1588. <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb
  1589. </literallayout>
  1590. Use lower-cased characters and do not include the reserved
  1591. suffixes <filename>-native</filename>,
  1592. <filename>-cross</filename>, <filename>-initial</filename>,
  1593. or <filename>-dev</filename> casually (i.e. do not use them
  1594. as part of your recipe name unless the string applies).
  1595. Here are some examples:
  1596. <literallayout class='monospaced'>
  1597. cups_1.7.0.bb
  1598. gawk_4.0.2.bb
  1599. irssi_0.8.16-rc1.bb
  1600. </literallayout></para></listitem>
  1601. </itemizedlist>
  1602. </section>
  1603. <section id='new-recipe-running-a-build-on-the-recipe'>
  1604. <title>Running a Build on the Recipe</title>
  1605. <para>
  1606. Creating a new recipe is usually an iterative process that
  1607. requires using BitBake to process the recipe multiple times in
  1608. order to progressively discover and add information to the
  1609. recipe file.
  1610. </para>
  1611. <para>
  1612. Assuming you have sourced the build environment setup script (i.e.
  1613. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  1614. and you are in the
  1615. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  1616. use BitBake to process your recipe.
  1617. All you need to provide is the
  1618. <filename><replaceable>basename</replaceable></filename> of the recipe as described
  1619. in the previous section:
  1620. <literallayout class='monospaced'>
  1621. $ bitbake <replaceable>basename</replaceable>
  1622. </literallayout>
  1623. </para>
  1624. <para>
  1625. During the build, the OpenEmbedded build system creates a
  1626. temporary work directory for each recipe
  1627. (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>)
  1628. where it keeps extracted source files, log files, intermediate
  1629. compilation and packaging files, and so forth.
  1630. </para>
  1631. <para>
  1632. The path to the per-recipe temporary work directory depends
  1633. on the context in which it is being built.
  1634. The quickest way to find this path is to have BitBake return it
  1635. by running the following:
  1636. <literallayout class='monospaced'>
  1637. $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR=
  1638. </literallayout>
  1639. As an example, assume a Source Directory top-level folder named
  1640. <filename>poky</filename>, a default Build Directory at
  1641. <filename>poky/build</filename>, and a
  1642. <filename>qemux86-poky-linux</filename> machine target system.
  1643. Furthermore, suppose your recipe is named
  1644. <filename>foo_1.3.0.bb</filename>.
  1645. In this case, the work directory the build system uses to
  1646. build the package would be as follows:
  1647. <literallayout class='monospaced'>
  1648. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1649. </literallayout>
  1650. Inside this directory you can find sub-directories such as
  1651. <filename>image</filename>, <filename>packages-split</filename>,
  1652. and <filename>temp</filename>.
  1653. After the build, you can examine these to determine how well
  1654. the build went.
  1655. <note>
  1656. You can find log files for each task in the recipe's
  1657. <filename>temp</filename> directory (e.g.
  1658. <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>).
  1659. Log files are named <filename>log.<replaceable>taskname</replaceable></filename>
  1660. (e.g. <filename>log.do_configure</filename>,
  1661. <filename>log.do_fetch</filename>, and
  1662. <filename>log.do_compile</filename>).
  1663. </note>
  1664. </para>
  1665. <para>
  1666. You can find more information about the build process in
  1667. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#overview-development-environment'>The Yocto Project Development Environment</ulink>"
  1668. chapter of the Yocto Project Overview Manual.
  1669. </para>
  1670. </section>
  1671. <section id='new-recipe-fetching-code'>
  1672. <title>Fetching Code</title>
  1673. <para>
  1674. The first thing your recipe must do is specify how to fetch
  1675. the source files.
  1676. Fetching is controlled mainly through the
  1677. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1678. variable.
  1679. Your recipe must have a <filename>SRC_URI</filename> variable
  1680. that points to where the source is located.
  1681. For a graphical representation of source locations, see the
  1682. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#sources-dev-environment'>Sources</ulink>"
  1683. section in the Yocto Project Overview Manual.
  1684. </para>
  1685. <para>
  1686. The
  1687. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1688. task uses the prefix of each entry in the
  1689. <filename>SRC_URI</filename> variable value to determine which
  1690. fetcher to use to get your source files.
  1691. It is the <filename>SRC_URI</filename> variable that triggers
  1692. the fetcher.
  1693. The
  1694. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1695. task uses the variable after source is fetched to apply
  1696. patches.
  1697. The OpenEmbedded build system uses
  1698. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink>
  1699. for scanning directory locations for local files in
  1700. <filename>SRC_URI</filename>.
  1701. </para>
  1702. <para>
  1703. The <filename>SRC_URI</filename> variable in your recipe must
  1704. define each unique location for your source files.
  1705. It is good practice to not hard-code pathnames in an URL used
  1706. in <filename>SRC_URI</filename>.
  1707. Rather than hard-code these paths, use
  1708. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1709. which causes the fetch process to use the version specified in
  1710. the recipe filename.
  1711. Specifying the version in this manner means that upgrading the
  1712. recipe to a future version is as simple as renaming the recipe
  1713. to match the new version.
  1714. </para>
  1715. <para>
  1716. Here is a simple example from the
  1717. <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename>
  1718. recipe where the source comes from a single tarball.
  1719. Notice the use of the
  1720. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1721. variable:
  1722. <literallayout class='monospaced'>
  1723. SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2"
  1724. </literallayout>
  1725. </para>
  1726. <para>
  1727. Files mentioned in <filename>SRC_URI</filename> whose names end
  1728. in a typical archive extension (e.g. <filename>.tar</filename>,
  1729. <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>,
  1730. <filename>.zip</filename>, and so forth), are automatically
  1731. extracted during the
  1732. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1733. task.
  1734. For another example that specifies these types of files, see
  1735. the
  1736. "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>"
  1737. section.
  1738. </para>
  1739. <para>
  1740. Another way of specifying source is from an SCM.
  1741. For Git repositories, you must specify
  1742. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  1743. and you should specify
  1744. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1745. to include the revision with
  1746. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  1747. Here is an example from the recipe
  1748. <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>:
  1749. <literallayout class='monospaced'>
  1750. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1751. PR = "r6"
  1752. PV = "1.0.5+git${SRCPV}"
  1753. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1754. file://ldflags.patch"
  1755. </literallayout>
  1756. </para>
  1757. <para>
  1758. If your <filename>SRC_URI</filename> statement includes
  1759. URLs pointing to individual files fetched from a remote server
  1760. other than a version control system, BitBake attempts to
  1761. verify the files against checksums defined in your recipe to
  1762. ensure they have not been tampered with or otherwise modified
  1763. since the recipe was written.
  1764. Two checksums are used:
  1765. <filename>SRC_URI[md5sum]</filename> and
  1766. <filename>SRC_URI[sha256sum]</filename>.
  1767. </para>
  1768. <para>
  1769. If your <filename>SRC_URI</filename> variable points to
  1770. more than a single URL (excluding SCM URLs), you need to
  1771. provide the <filename>md5</filename> and
  1772. <filename>sha256</filename> checksums for each URL.
  1773. For these cases, you provide a name for each URL as part of
  1774. the <filename>SRC_URI</filename> and then reference that name
  1775. in the subsequent checksum statements.
  1776. Here is an example:
  1777. <literallayout class='monospaced'>
  1778. SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \
  1779. ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch"
  1780. SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
  1781. SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
  1782. SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92"
  1783. SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
  1784. </literallayout>
  1785. </para>
  1786. <para>
  1787. Proper values for <filename>md5</filename> and
  1788. <filename>sha256</filename> checksums might be available
  1789. with other signatures on the download page for the upstream
  1790. source (e.g. <filename>md5</filename>,
  1791. <filename>sha1</filename>, <filename>sha256</filename>,
  1792. <filename>GPG</filename>, and so forth).
  1793. Because the OpenEmbedded build system only deals with
  1794. <filename>sha256sum</filename> and <filename>md5sum</filename>,
  1795. you should verify all the signatures you find by hand.
  1796. </para>
  1797. <para>
  1798. If no <filename>SRC_URI</filename> checksums are specified
  1799. when you attempt to build the recipe, or you provide an
  1800. incorrect checksum, the build will produce an error for each
  1801. missing or incorrect checksum.
  1802. As part of the error message, the build system provides
  1803. the checksum string corresponding to the fetched file.
  1804. Once you have the correct checksums, you can copy and paste
  1805. them into your recipe and then run the build again to continue.
  1806. <note>
  1807. As mentioned, if the upstream source provides signatures
  1808. for verifying the downloaded source code, you should
  1809. verify those manually before setting the checksum values
  1810. in the recipe and continuing with the build.
  1811. </note>
  1812. </para>
  1813. <para>
  1814. This final example is a bit more complicated and is from the
  1815. <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename>
  1816. recipe.
  1817. The example's <filename>SRC_URI</filename> statement identifies
  1818. multiple files as the source files for the recipe: a tarball, a
  1819. patch file, a desktop file, and an icon.
  1820. <literallayout class='monospaced'>
  1821. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1822. file://xwc.patch \
  1823. file://rxvt.desktop \
  1824. file://rxvt.png"
  1825. </literallayout>
  1826. </para>
  1827. <para>
  1828. When you specify local files using the
  1829. <filename>file://</filename> URI protocol, the build system
  1830. fetches files from the local machine.
  1831. The path is relative to the
  1832. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1833. variable and searches specific directories in a certain order:
  1834. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>,
  1835. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>,
  1836. and <filename>files</filename>.
  1837. The directories are assumed to be subdirectories of the
  1838. directory in which the recipe or append file resides.
  1839. For another example that specifies these types of files, see the
  1840. "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>"
  1841. section.
  1842. </para>
  1843. <para>
  1844. The previous example also specifies a patch file.
  1845. Patch files are files whose names usually end in
  1846. <filename>.patch</filename> or <filename>.diff</filename> but
  1847. can end with compressed suffixes such as
  1848. <filename>diff.gz</filename> and
  1849. <filename>patch.bz2</filename>, for example.
  1850. The build system automatically applies patches as described
  1851. in the
  1852. "<link linkend='new-recipe-patching-code'>Patching Code</link>" section.
  1853. </para>
  1854. </section>
  1855. <section id='new-recipe-unpacking-code'>
  1856. <title>Unpacking Code</title>
  1857. <para>
  1858. During the build, the
  1859. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1860. task unpacks the source with
  1861. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>
  1862. pointing to where it is unpacked.
  1863. </para>
  1864. <para>
  1865. If you are fetching your source files from an upstream source
  1866. archived tarball and the tarball's internal structure matches
  1867. the common convention of a top-level subdirectory named
  1868. <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>,
  1869. then you do not need to set <filename>S</filename>.
  1870. However, if <filename>SRC_URI</filename> specifies to fetch
  1871. source from an archive that does not use this convention,
  1872. or from an SCM like Git or Subversion, your recipe needs to
  1873. define <filename>S</filename>.
  1874. </para>
  1875. <para>
  1876. If processing your recipe using BitBake successfully unpacks
  1877. the source files, you need to be sure that the directory
  1878. pointed to by <filename>${S}</filename> matches the structure
  1879. of the source.
  1880. </para>
  1881. </section>
  1882. <section id='new-recipe-patching-code'>
  1883. <title>Patching Code</title>
  1884. <para>
  1885. Sometimes it is necessary to patch code after it has been
  1886. fetched.
  1887. Any files mentioned in <filename>SRC_URI</filename> whose
  1888. names end in <filename>.patch</filename> or
  1889. <filename>.diff</filename> or compressed versions of these
  1890. suffixes (e.g. <filename>diff.gz</filename> are treated as
  1891. patches.
  1892. The
  1893. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1894. task automatically applies these patches.
  1895. </para>
  1896. <para>
  1897. The build system should be able to apply patches with the "-p1"
  1898. option (i.e. one directory level in the path will be stripped
  1899. off).
  1900. If your patch needs to have more directory levels stripped off,
  1901. specify the number of levels using the "striplevel" option in
  1902. the <filename>SRC_URI</filename> entry for the patch.
  1903. Alternatively, if your patch needs to be applied in a specific
  1904. subdirectory that is not specified in the patch file, use the
  1905. "patchdir" option in the entry.
  1906. </para>
  1907. <para>
  1908. As with all local files referenced in
  1909. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1910. using <filename>file://</filename>, you should place
  1911. patch files in a directory next to the recipe either
  1912. named the same as the base name of the recipe
  1913. (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  1914. and
  1915. <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>)
  1916. or "files".
  1917. </para>
  1918. </section>
  1919. <section id='new-recipe-licensing'>
  1920. <title>Licensing</title>
  1921. <para>
  1922. Your recipe needs to have both the
  1923. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  1924. and
  1925. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  1926. variables:
  1927. <itemizedlist>
  1928. <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis>
  1929. This variable specifies the license for the software.
  1930. If you do not know the license under which the software
  1931. you are building is distributed, you should go to the
  1932. source code and look for that information.
  1933. Typical files containing this information include
  1934. <filename>COPYING</filename>,
  1935. <filename>LICENSE</filename>, and
  1936. <filename>README</filename> files.
  1937. You could also find the information near the top of
  1938. a source file.
  1939. For example, given a piece of software licensed under
  1940. the GNU General Public License version 2, you would
  1941. set <filename>LICENSE</filename> as follows:
  1942. <literallayout class='monospaced'>
  1943. LICENSE = "GPLv2"
  1944. </literallayout></para>
  1945. <para>The licenses you specify within
  1946. <filename>LICENSE</filename> can have any name as long
  1947. as you do not use spaces, since spaces are used as
  1948. separators between license names.
  1949. For standard licenses, use the names of the files in
  1950. <filename>meta/files/common-licenses/</filename>
  1951. or the <filename>SPDXLICENSEMAP</filename> flag names
  1952. defined in <filename>meta/conf/licenses.conf</filename>.
  1953. </para></listitem>
  1954. <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis>
  1955. The OpenEmbedded build system uses this variable to
  1956. make sure the license text has not changed.
  1957. If it has, the build produces an error and it affords
  1958. you the chance to figure it out and correct the problem.
  1959. </para>
  1960. <para>You need to specify all applicable licensing
  1961. files for the software.
  1962. At the end of the configuration step, the build process
  1963. will compare the checksums of the files to be sure
  1964. the text has not changed.
  1965. Any differences result in an error with the message
  1966. containing the current checksum.
  1967. For more explanation and examples of how to set the
  1968. <filename>LIC_FILES_CHKSUM</filename> variable, see the
  1969. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  1970. section in the Yocto Project Overview Manual.</para>
  1971. <para>To determine the correct checksum string, you
  1972. can list the appropriate files in the
  1973. <filename>LIC_FILES_CHKSUM</filename> variable with
  1974. incorrect md5 strings, attempt to build the software,
  1975. and then note the resulting error messages that will
  1976. report the correct md5 strings.
  1977. See the
  1978. "<link linkend='new-recipe-fetching-code'>Fetching Code</link>"
  1979. section for additional information.
  1980. </para>
  1981. <para>
  1982. Here is an example that assumes the software has a
  1983. <filename>COPYING</filename> file:
  1984. <literallayout class='monospaced'>
  1985. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  1986. </literallayout>
  1987. When you try to build the software, the build system
  1988. will produce an error and give you the correct string
  1989. that you can substitute into the recipe file for a
  1990. subsequent build.
  1991. </para></listitem>
  1992. </itemizedlist>
  1993. </para>
  1994. <!--
  1995. <para>
  1996. For trying this out I created a new recipe named
  1997. <filename>htop_1.0.2.bb</filename> and put it in
  1998. <filename>poky/meta/recipes-extended/htop</filename>.
  1999. There are two license type statements in my very simple
  2000. recipe:
  2001. <literallayout class='monospaced'>
  2002. LICENSE = ""
  2003. LIC_FILES_CHKSUM = ""
  2004. SRC_URI[md5sum] = ""
  2005. SRC_URI[sha256sum] = ""
  2006. </literallayout>
  2007. Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>.
  2008. Next, you delete or comment out the two <filename>SRC_URI</filename>
  2009. lines at the end and then attempt to build the software with
  2010. <filename>bitbake htop</filename>.
  2011. Doing so causes BitBake to report some errors and and give
  2012. you the actual strings you need for the last two
  2013. <filename>SRC_URI</filename> lines.
  2014. Prior to this, you have to dig around in the home page of the
  2015. source for <filename>htop</filename> and determine that the
  2016. software is released under GPLv2.
  2017. You can provide that in the <filename>LICENSE</filename>
  2018. statement.
  2019. Now you edit your recipe to have those two strings for
  2020. the <filename>SRC_URI</filename> statements:
  2021. <literallayout class='monospaced'>
  2022. LICENSE = "GPLv2"
  2023. LIC_FILES_CHKSUM = ""
  2024. SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz"
  2025. SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e"
  2026. SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1"
  2027. </literallayout>
  2028. At this point, you can build the software again using the
  2029. <filename>bitbake htop</filename> command.
  2030. There is just a set of errors now associated with the
  2031. empty <filename>LIC_FILES_CHKSUM</filename> variable now.
  2032. </para>
  2033. -->
  2034. </section>
  2035. <section id='new-dependencies'>
  2036. <title>Dependencies</title>
  2037. <para>
  2038. Most software packages have a short list of other packages
  2039. that they require, which are called dependencies.
  2040. These dependencies fall into two main categories: build-time
  2041. dependencies, which are required when the software is built;
  2042. and runtime dependencies, which are required to be installed
  2043. on the target in order for the software to run.
  2044. </para>
  2045. <para>
  2046. Within a recipe, you specify build-time dependencies using the
  2047. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2048. variable.
  2049. Although nuances exist, items specified in
  2050. <filename>DEPENDS</filename> should be names of other recipes.
  2051. It is important that you specify all build-time dependencies
  2052. explicitly.
  2053. If you do not, due to the parallel nature of BitBake's
  2054. execution, you can end up with a race condition where the
  2055. dependency is present for one task of a recipe (e.g.
  2056. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>)
  2057. and then gone when the next task runs (e.g.
  2058. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>).
  2059. </para>
  2060. <para>
  2061. Another consideration is that configure scripts might
  2062. automatically check for optional dependencies and enable
  2063. corresponding functionality if those dependencies are found.
  2064. This behavior means that to ensure deterministic results and
  2065. thus avoid more race conditions, you need to either explicitly
  2066. specify these dependencies as well, or tell the configure
  2067. script explicitly to disable the functionality.
  2068. If you wish to make a recipe that is more generally useful
  2069. (e.g. publish the recipe in a layer for others to use),
  2070. instead of hard-disabling the functionality, you can use the
  2071. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink>
  2072. variable to allow functionality and the corresponding
  2073. dependencies to be enabled and disabled easily by other
  2074. users of the recipe.
  2075. </para>
  2076. <para>
  2077. Similar to build-time dependencies, you specify runtime
  2078. dependencies through a variable -
  2079. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  2080. which is package-specific.
  2081. All variables that are package-specific need to have the name
  2082. of the package added to the end as an override.
  2083. Since the main package for a recipe has the same name as the
  2084. recipe, and the recipe's name can be found through the
  2085. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2086. variable, then you specify the dependencies for the main
  2087. package by setting <filename>RDEPENDS_${PN}</filename>.
  2088. If the package were named <filename>${PN}-tools</filename>,
  2089. then you would set <filename>RDEPENDS_${PN}-tools</filename>,
  2090. and so forth.
  2091. </para>
  2092. <para>
  2093. Some runtime dependencies will be set automatically at
  2094. packaging time.
  2095. These dependencies include any shared library dependencies
  2096. (i.e. if a package "example" contains "libexample" and
  2097. another package "mypackage" contains a binary that links to
  2098. "libexample" then the OpenEmbedded build system will
  2099. automatically add a runtime dependency to "mypackage" on
  2100. "example").
  2101. See the
  2102. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  2103. in the Yocto Project Overview Manual for further details.
  2104. </para>
  2105. </section>
  2106. <section id='new-recipe-configuring-the-recipe'>
  2107. <title>Configuring the Recipe</title>
  2108. <para>
  2109. Most software provides some means of setting build-time
  2110. configuration options before compilation.
  2111. Typically, setting these options is accomplished by running a
  2112. configure script with some options, or by modifying a build
  2113. configuration file.
  2114. <note>
  2115. As of Yocto Project Release 1.7, some of the core recipes
  2116. that package binary configuration scripts now disable the
  2117. scripts due to the scripts previously requiring error-prone
  2118. path substitution.
  2119. The OpenEmbedded build system uses
  2120. <filename>pkg-config</filename> now, which is much more
  2121. robust.
  2122. You can find a list of the <filename>*-config</filename>
  2123. scripts that are disabled list in the
  2124. "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>"
  2125. section in the Yocto Project Reference Manual.
  2126. </note>
  2127. </para>
  2128. <para>
  2129. A major part of build-time configuration is about checking for
  2130. build-time dependencies and possibly enabling optional
  2131. functionality as a result.
  2132. You need to specify any build-time dependencies for the
  2133. software you are building in your recipe's
  2134. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2135. value, in terms of other recipes that satisfy those
  2136. dependencies.
  2137. You can often find build-time or runtime
  2138. dependencies described in the software's documentation.
  2139. </para>
  2140. <para>
  2141. The following list provides configuration items of note based
  2142. on how your software is built:
  2143. <itemizedlist>
  2144. <listitem><para><emphasis>Autotools:</emphasis>
  2145. If your source files have a
  2146. <filename>configure.ac</filename> file, then your
  2147. software is built using Autotools.
  2148. If this is the case, you just need to worry about
  2149. modifying the configuration.</para>
  2150. <para>When using Autotools, your recipe needs to inherit
  2151. the
  2152. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2153. class and your recipe does not have to contain a
  2154. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2155. task.
  2156. However, you might still want to make some adjustments.
  2157. For example, you can set
  2158. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  2159. or
  2160. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2161. to pass any needed configure options that are specific
  2162. to the recipe.</para></listitem>
  2163. <listitem><para><emphasis>CMake:</emphasis>
  2164. If your source files have a
  2165. <filename>CMakeLists.txt</filename> file, then your
  2166. software is built using CMake.
  2167. If this is the case, you just need to worry about
  2168. modifying the configuration.</para>
  2169. <para>When you use CMake, your recipe needs to inherit
  2170. the
  2171. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2172. class and your recipe does not have to contain a
  2173. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2174. task.
  2175. You can make some adjustments by setting
  2176. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
  2177. to pass any needed configure options that are specific
  2178. to the recipe.</para></listitem>
  2179. <listitem><para><emphasis>Other:</emphasis>
  2180. If your source files do not have a
  2181. <filename>configure.ac</filename> or
  2182. <filename>CMakeLists.txt</filename> file, then your
  2183. software is built using some method other than Autotools
  2184. or CMake.
  2185. If this is the case, you normally need to provide a
  2186. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2187. task in your recipe
  2188. unless, of course, there is nothing to configure.
  2189. </para>
  2190. <para>Even if your software is not being built by
  2191. Autotools or CMake, you still might not need to deal
  2192. with any configuration issues.
  2193. You need to determine if configuration is even a required step.
  2194. You might need to modify a Makefile or some configuration file
  2195. used for the build to specify necessary build options.
  2196. Or, perhaps you might need to run a provided, custom
  2197. configure script with the appropriate options.</para>
  2198. <para>For the case involving a custom configure
  2199. script, you would run
  2200. <filename>./configure --help</filename> and look for
  2201. the options you need to set.</para></listitem>
  2202. </itemizedlist>
  2203. </para>
  2204. <para>
  2205. Once configuration succeeds, it is always good practice to
  2206. look at the <filename>log.do_configure</filename> file to
  2207. ensure that the appropriate options have been enabled and no
  2208. additional build-time dependencies need to be added to
  2209. <filename>DEPENDS</filename>.
  2210. For example, if the configure script reports that it found
  2211. something not mentioned in <filename>DEPENDS</filename>, or
  2212. that it did not find something that it needed for some
  2213. desired optional functionality, then you would need to add
  2214. those to <filename>DEPENDS</filename>.
  2215. Looking at the log might also reveal items being checked for,
  2216. enabled, or both that you do not want, or items not being found
  2217. that are in <filename>DEPENDS</filename>, in which case
  2218. you would need to look at passing extra options to the
  2219. configure script as needed.
  2220. For reference information on configure options specific to the
  2221. software you are building, you can consult the output of the
  2222. <filename>./configure --help</filename> command within
  2223. <filename>${S}</filename> or consult the software's upstream
  2224. documentation.
  2225. </para>
  2226. </section>
  2227. <section id='new-recipe-using-headers-to-interface-with-devices'>
  2228. <title>Using Headers to Interface with Devices</title>
  2229. <para>
  2230. If your recipe builds an application that needs to
  2231. communicate with some device or needs an API into a custom
  2232. kernel, you will need to provide appropriate header files.
  2233. Under no circumstances should you ever modify the existing
  2234. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>
  2235. file.
  2236. These headers are used to build <filename>libc</filename> and
  2237. must not be compromised with custom or machine-specific
  2238. header information.
  2239. If you customize <filename>libc</filename> through modified
  2240. headers all other applications that use
  2241. <filename>libc</filename> thus become affected.
  2242. <note><title>Warning</title>
  2243. Never copy and customize the <filename>libc</filename>
  2244. header file (i.e.
  2245. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>).
  2246. </note>
  2247. The correct way to interface to a device or custom kernel is
  2248. to use a separate package that provides the additional headers
  2249. for the driver or other unique interfaces.
  2250. When doing so, your application also becomes responsible for
  2251. creating a dependency on that specific provider.
  2252. </para>
  2253. <para>
  2254. Consider the following:
  2255. <itemizedlist>
  2256. <listitem><para>
  2257. Never modify
  2258. <filename>linux-libc-headers.inc</filename>.
  2259. Consider that file to be part of the
  2260. <filename>libc</filename> system, and not something
  2261. you use to access the kernel directly.
  2262. You should access <filename>libc</filename> through
  2263. specific <filename>libc</filename> calls.
  2264. </para></listitem>
  2265. <listitem><para>
  2266. Applications that must talk directly to devices
  2267. should either provide necessary headers themselves,
  2268. or establish a dependency on a special headers package
  2269. that is specific to that driver.
  2270. </para></listitem>
  2271. </itemizedlist>
  2272. </para>
  2273. <para>
  2274. For example, suppose you want to modify an existing header
  2275. that adds I/O control or network support.
  2276. If the modifications are used by a small number programs,
  2277. providing a unique version of a header is easy and has little
  2278. impact.
  2279. When doing so, bear in mind the guidelines in the previous
  2280. list.
  2281. <note>
  2282. If for some reason your changes need to modify the behavior
  2283. of the <filename>libc</filename>, and subsequently all
  2284. other applications on the system, use a
  2285. <filename>.bbappend</filename> to modify the
  2286. <filename>linux-kernel-headers.inc</filename> file.
  2287. However, take care to not make the changes
  2288. machine specific.
  2289. </note>
  2290. </para>
  2291. <para>
  2292. Consider a case where your kernel is older and you need
  2293. an older <filename>libc</filename> ABI.
  2294. The headers installed by your recipe should still be a
  2295. standard mainline kernel, not your own custom one.
  2296. </para>
  2297. <para>
  2298. When you use custom kernel headers you need to get them from
  2299. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>,
  2300. which is the directory with kernel headers that are
  2301. required to build out-of-tree modules.
  2302. Your recipe will also need the following:
  2303. <literallayout class='monospaced'>
  2304. do_configure[depends] += "virtual/kernel:do_shared_workdir"
  2305. </literallayout>
  2306. </para>
  2307. </section>
  2308. <section id='new-recipe-compilation'>
  2309. <title>Compilation</title>
  2310. <para>
  2311. During a build, the <filename>do_compile</filename> task
  2312. happens after source is fetched, unpacked, and configured.
  2313. If the recipe passes through <filename>do_compile</filename>
  2314. successfully, nothing needs to be done.
  2315. </para>
  2316. <para>
  2317. However, if the compile step fails, you need to diagnose the
  2318. failure.
  2319. Here are some common issues that cause failures.
  2320. <note>
  2321. For cases where improper paths are detected for
  2322. configuration files or for when libraries/headers cannot
  2323. be found, be sure you are using the more robust
  2324. <filename>pkg-config</filename>.
  2325. See the note in section
  2326. "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>"
  2327. for additional information.
  2328. </note>
  2329. <itemizedlist>
  2330. <listitem><para><emphasis>Parallel build failures:</emphasis>
  2331. These failures manifest themselves as intermittent
  2332. errors, or errors reporting that a file or directory
  2333. that should be created by some other part of the build
  2334. process could not be found.
  2335. This type of failure can occur even if, upon inspection,
  2336. the file or directory does exist after the build has
  2337. failed, because that part of the build process happened
  2338. in the wrong order.</para>
  2339. <para>To fix the problem, you need to either satisfy
  2340. the missing dependency in the Makefile or whatever
  2341. script produced the Makefile, or (as a workaround)
  2342. set
  2343. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  2344. to an empty string:
  2345. <literallayout class='monospaced'>
  2346. PARALLEL_MAKE = ""
  2347. </literallayout></para>
  2348. <para>
  2349. For information on parallel Makefile issues, see the
  2350. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  2351. section.
  2352. </para></listitem>
  2353. <listitem><para><emphasis>Improper host path usage:</emphasis>
  2354. This failure applies to recipes building for the target
  2355. or <filename>nativesdk</filename> only.
  2356. The failure occurs when the compilation process uses
  2357. improper headers, libraries, or other files from the
  2358. host system when cross-compiling for the target.
  2359. </para>
  2360. <para>To fix the problem, examine the
  2361. <filename>log.do_compile</filename> file to identify
  2362. the host paths being used (e.g.
  2363. <filename>/usr/include</filename>,
  2364. <filename>/usr/lib</filename>, and so forth) and then
  2365. either add configure options, apply a patch, or do both.
  2366. </para></listitem>
  2367. <listitem><para><emphasis>Failure to find required
  2368. libraries/headers:</emphasis>
  2369. If a build-time dependency is missing because it has
  2370. not been declared in
  2371. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  2372. or because the dependency exists but the path used by
  2373. the build process to find the file is incorrect and the
  2374. configure step did not detect it, the compilation
  2375. process could fail.
  2376. For either of these failures, the compilation process
  2377. notes that files could not be found.
  2378. In these cases, you need to go back and add additional
  2379. options to the configure script as well as possibly
  2380. add additional build-time dependencies to
  2381. <filename>DEPENDS</filename>.</para>
  2382. <para>Occasionally, it is necessary to apply a patch
  2383. to the source to ensure the correct paths are used.
  2384. If you need to specify paths to find files staged
  2385. into the sysroot from other recipes, use the variables
  2386. that the OpenEmbedded build system provides
  2387. (e.g.
  2388. <filename>STAGING_BINDIR</filename>,
  2389. <filename>STAGING_INCDIR</filename>,
  2390. <filename>STAGING_DATADIR</filename>, and so forth).
  2391. <!--
  2392. (e.g.
  2393. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>,
  2394. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>,
  2395. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>,
  2396. and so forth).
  2397. -->
  2398. </para></listitem>
  2399. </itemizedlist>
  2400. </para>
  2401. </section>
  2402. <section id='new-recipe-installing'>
  2403. <title>Installing</title>
  2404. <para>
  2405. During <filename>do_install</filename>, the task copies the
  2406. built files along with their hierarchy to locations that
  2407. would mirror their locations on the target device.
  2408. The installation process copies files from the
  2409. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  2410. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>,
  2411. and
  2412. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  2413. directories to the
  2414. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2415. directory to create the structure as it should appear on the
  2416. target system.
  2417. </para>
  2418. <para>
  2419. How your software is built affects what you must do to be
  2420. sure your software is installed correctly.
  2421. The following list describes what you must do for installation
  2422. depending on the type of build system used by the software
  2423. being built:
  2424. <itemizedlist>
  2425. <listitem><para><emphasis>Autotools and CMake:</emphasis>
  2426. If the software your recipe is building uses Autotools
  2427. or CMake, the OpenEmbedded build
  2428. system understands how to install the software.
  2429. Consequently, you do not have to have a
  2430. <filename>do_install</filename> task as part of your
  2431. recipe.
  2432. You just need to make sure the install portion of the
  2433. build completes with no issues.
  2434. However, if you wish to install additional files not
  2435. already being installed by
  2436. <filename>make install</filename>, you should do this
  2437. using a <filename>do_install_append</filename> function
  2438. using the install command as described in
  2439. the "Manual" bulleted item later in this list.
  2440. </para></listitem>
  2441. <listitem><para><emphasis>Other (using
  2442. <filename>make install</filename>):</emphasis>
  2443. You need to define a
  2444. <filename>do_install</filename> function in your
  2445. recipe.
  2446. The function should call
  2447. <filename>oe_runmake install</filename> and will likely
  2448. need to pass in the destination directory as well.
  2449. How you pass that path is dependent on how the
  2450. <filename>Makefile</filename> being run is written
  2451. (e.g. <filename>DESTDIR=${D}</filename>,
  2452. <filename>PREFIX=${D}</filename>,
  2453. <filename>INSTALLROOT=${D}</filename>, and so forth).
  2454. </para>
  2455. <para>For an example recipe using
  2456. <filename>make install</filename>, see the
  2457. "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>"
  2458. section.</para></listitem>
  2459. <listitem><para><emphasis>Manual:</emphasis>
  2460. You need to define a
  2461. <filename>do_install</filename> function in your
  2462. recipe.
  2463. The function must first use
  2464. <filename>install -d</filename> to create the
  2465. directories under
  2466. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
  2467. Once the directories exist, your function can use
  2468. <filename>install</filename> to manually install the
  2469. built software into the directories.</para>
  2470. <para>You can find more information on
  2471. <filename>install</filename> at
  2472. <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>.
  2473. </para></listitem>
  2474. </itemizedlist>
  2475. </para>
  2476. <para>
  2477. For the scenarios that do not use Autotools or
  2478. CMake, you need to track the installation
  2479. and diagnose and fix any issues until everything installs
  2480. correctly.
  2481. You need to look in the default location of
  2482. <filename>${D}</filename>, which is
  2483. <filename>${WORKDIR}/image</filename>, to be sure your
  2484. files have been installed correctly.
  2485. </para>
  2486. <note><title>Notes</title>
  2487. <itemizedlist>
  2488. <listitem><para>
  2489. During the installation process, you might need to
  2490. modify some of the installed files to suit the target
  2491. layout.
  2492. For example, you might need to replace hard-coded paths
  2493. in an initscript with values of variables provided by
  2494. the build system, such as replacing
  2495. <filename>/usr/bin/</filename> with
  2496. <filename>${bindir}</filename>.
  2497. If you do perform such modifications during
  2498. <filename>do_install</filename>, be sure to modify the
  2499. destination file after copying rather than before
  2500. copying.
  2501. Modifying after copying ensures that the build system
  2502. can re-execute <filename>do_install</filename> if
  2503. needed.
  2504. </para></listitem>
  2505. <listitem><para>
  2506. <filename>oe_runmake install</filename>, which can be
  2507. run directly or can be run indirectly by the
  2508. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2509. and
  2510. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2511. classes, runs <filename>make install</filename> in
  2512. parallel.
  2513. Sometimes, a Makefile can have missing dependencies
  2514. between targets that can result in race conditions.
  2515. If you experience intermittent failures during
  2516. <filename>do_install</filename>, you might be able to
  2517. work around them by disabling parallel Makefile
  2518. installs by adding the following to the recipe:
  2519. <literallayout class='monospaced'>
  2520. PARALLEL_MAKEINST = ""
  2521. </literallayout>
  2522. See
  2523. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  2524. for additional information.
  2525. </para></listitem>
  2526. </itemizedlist>
  2527. </note>
  2528. </section>
  2529. <section id='new-recipe-enabling-system-services'>
  2530. <title>Enabling System Services</title>
  2531. <para>
  2532. If you want to install a service, which is a process that
  2533. usually starts on boot and runs in the background, then
  2534. you must include some additional definitions in your recipe.
  2535. </para>
  2536. <para>
  2537. If you are adding services and the service initialization
  2538. script or the service file itself is not installed, you must
  2539. provide for that installation in your recipe using a
  2540. <filename>do_install_append</filename> function.
  2541. If your recipe already has a <filename>do_install</filename>
  2542. function, update the function near its end rather than
  2543. adding an additional <filename>do_install_append</filename>
  2544. function.
  2545. </para>
  2546. <para>
  2547. When you create the installation for your services, you need
  2548. to accomplish what is normally done by
  2549. <filename>make install</filename>.
  2550. In other words, make sure your installation arranges the output
  2551. similar to how it is arranged on the target system.
  2552. </para>
  2553. <para>
  2554. The OpenEmbedded build system provides support for starting
  2555. services two different ways:
  2556. <itemizedlist>
  2557. <listitem><para><emphasis>SysVinit:</emphasis>
  2558. SysVinit is a system and service manager that
  2559. manages the init system used to control the very basic
  2560. functions of your system.
  2561. The init program is the first program
  2562. started by the Linux kernel when the system boots.
  2563. Init then controls the startup, running and shutdown
  2564. of all other programs.</para>
  2565. <para>To enable a service using SysVinit, your recipe
  2566. needs to inherit the
  2567. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink>
  2568. class.
  2569. The class helps facilitate safely installing the
  2570. package on the target.</para>
  2571. <para>You will need to set the
  2572. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>,
  2573. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>,
  2574. and
  2575. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink>
  2576. variables within your recipe.</para></listitem>
  2577. <listitem><para><emphasis>systemd:</emphasis>
  2578. System Management Daemon (systemd) was designed to
  2579. replace SysVinit and to provide
  2580. enhanced management of services.
  2581. For more information on systemd, see the systemd
  2582. homepage at
  2583. <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>.
  2584. </para>
  2585. <para>To enable a service using systemd, your recipe
  2586. needs to inherit the
  2587. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink>
  2588. class.
  2589. See the <filename>systemd.bbclass</filename> file
  2590. located in your
  2591. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  2592. section for more information.
  2593. </para></listitem>
  2594. </itemizedlist>
  2595. </para>
  2596. </section>
  2597. <section id='new-recipe-packaging'>
  2598. <title>Packaging</title>
  2599. <para>
  2600. Successful packaging is a combination of automated processes
  2601. performed by the OpenEmbedded build system and some
  2602. specific steps you need to take.
  2603. The following list describes the process:
  2604. <itemizedlist>
  2605. <listitem><para><emphasis>Splitting Files</emphasis>:
  2606. The <filename>do_package</filename> task splits the
  2607. files produced by the recipe into logical components.
  2608. Even software that produces a single binary might
  2609. still have debug symbols, documentation, and other
  2610. logical components that should be split out.
  2611. The <filename>do_package</filename> task ensures
  2612. that files are split up and packaged correctly.
  2613. </para></listitem>
  2614. <listitem><para><emphasis>Running QA Checks</emphasis>:
  2615. The
  2616. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2617. class adds a step to
  2618. the package generation process so that output quality
  2619. assurance checks are generated by the OpenEmbedded
  2620. build system.
  2621. This step performs a range of checks to be sure the
  2622. build's output is free of common problems that show
  2623. up during runtime.
  2624. For information on these checks, see the
  2625. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2626. class and the
  2627. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>"
  2628. chapter in the Yocto Project Reference Manual.
  2629. </para></listitem>
  2630. <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>:
  2631. After you build your software, you need to be sure
  2632. your packages are correct.
  2633. Examine the
  2634. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  2635. directory and make sure files are where you expect
  2636. them to be.
  2637. If you discover problems, you can set
  2638. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>,
  2639. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2640. <filename>do_install(_append)</filename>, and so forth as
  2641. needed.
  2642. </para></listitem>
  2643. <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>:
  2644. If you need to split an application into several
  2645. packages, see the
  2646. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2647. section for an example.
  2648. </para></listitem>
  2649. <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>:
  2650. For an example showing how to install a
  2651. post-installation script, see the
  2652. "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>"
  2653. section.
  2654. </para></listitem>
  2655. <listitem><para><emphasis>Marking Package Architecture</emphasis>:
  2656. Depending on what your recipe is building and how it
  2657. is configured, it might be important to mark the
  2658. packages produced as being specific to a particular
  2659. machine, or to mark them as not being specific to
  2660. a particular machine or architecture at all.</para>
  2661. <para>By default, packages apply to any machine with the
  2662. same architecture as the target machine.
  2663. When a recipe produces packages that are
  2664. machine-specific (e.g. the
  2665. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  2666. value is passed into the configure script or a patch
  2667. is applied only for a particular machine), you should
  2668. mark them as such by adding the following to the
  2669. recipe:
  2670. <literallayout class='monospaced'>
  2671. PACKAGE_ARCH = "${MACHINE_ARCH}"
  2672. </literallayout></para>
  2673. <para>On the other hand, if the recipe produces packages
  2674. that do not contain anything specific to the target
  2675. machine or architecture at all (e.g. recipes
  2676. that simply package script files or configuration
  2677. files), you should use the
  2678. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  2679. class to do this for you by adding this to your
  2680. recipe:
  2681. <literallayout class='monospaced'>
  2682. inherit allarch
  2683. </literallayout>
  2684. Ensuring that the package architecture is correct is
  2685. not critical while you are doing the first few builds
  2686. of your recipe.
  2687. However, it is important in order
  2688. to ensure that your recipe rebuilds (or does not
  2689. rebuild) appropriately in response to changes in
  2690. configuration, and to ensure that you get the
  2691. appropriate packages installed on the target machine,
  2692. particularly if you run separate builds for more
  2693. than one target machine.
  2694. </para></listitem>
  2695. </itemizedlist>
  2696. </para>
  2697. </section>
  2698. <section id='new-sharing-files-between-recipes'>
  2699. <title>Sharing Files Between Recipes</title>
  2700. <para>
  2701. Recipes often need to use files provided by other recipes on
  2702. the build host.
  2703. For example, an application linking to a common library needs
  2704. access to the library itself and its associated headers.
  2705. The way this access is accomplished is by populating a sysroot
  2706. with files.
  2707. Each recipe has two sysroots in its work directory, one for
  2708. target files
  2709. (<filename>recipe-sysroot</filename>) and one for files that
  2710. are native to the build host
  2711. (<filename>recipe-sysroot-native</filename>).
  2712. <note>
  2713. You could find the term "staging" used within the Yocto
  2714. project regarding files populating sysroots (e.g. the
  2715. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink>
  2716. variable).
  2717. </note>
  2718. </para>
  2719. <para>
  2720. Recipes should never populate the sysroot directly (i.e. write
  2721. files into sysroot).
  2722. Instead, files should be installed into standard locations
  2723. during the
  2724. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2725. task within the
  2726. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2727. directory.
  2728. The reason for this limitation is that almost all files that
  2729. populate the sysroot are cataloged in manifests in order to
  2730. ensure the files can be removed later when a recipe is either
  2731. modified or removed.
  2732. Thus, the sysroot is able to remain free from stale files.
  2733. </para>
  2734. <para>
  2735. A subset of the files installed by the
  2736. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2737. task are used by the
  2738. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  2739. task as defined by the the
  2740. <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink>
  2741. variable to automatically populate the sysroot.
  2742. It is possible to modify the list of directories that populate
  2743. the sysroot.
  2744. The following example shows how you could add the
  2745. <filename>/opt</filename> directory to the list of
  2746. directories within a recipe:
  2747. <literallayout class='monospaced'>
  2748. SYSROOT_DIRS += "/opt"
  2749. </literallayout>
  2750. </para>
  2751. <para>
  2752. For a more complete description of the
  2753. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  2754. task and its associated functions, see the
  2755. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-staging'><filename>staging</filename></ulink>
  2756. class.
  2757. </para>
  2758. </section>
  2759. <section id='properly-versioning-pre-release-recipes'>
  2760. <title>Properly Versioning Pre-Release Recipes</title>
  2761. <para>
  2762. Sometimes the name of a recipe can lead to versioning
  2763. problems when the recipe is upgraded to a final release.
  2764. For example, consider the
  2765. <filename>irssi_0.8.16-rc1.bb</filename> recipe file in
  2766. the list of example recipes in the
  2767. "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>"
  2768. section.
  2769. This recipe is at a release candidate stage (i.e.
  2770. "rc1").
  2771. When the recipe is released, the recipe filename becomes
  2772. <filename>irssi_0.8.16.bb</filename>.
  2773. The version change from <filename>0.8.16-rc1</filename>
  2774. to <filename>0.8.16</filename> is seen as a decrease by the
  2775. build system and package managers, so the resulting packages
  2776. will not correctly trigger an upgrade.
  2777. </para>
  2778. <para>
  2779. In order to ensure the versions compare properly, the
  2780. recommended convention is to set
  2781. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2782. within the recipe to
  2783. "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>".
  2784. You can use an additional variable so that you can use the
  2785. current version elsewhere.
  2786. Here is an example:
  2787. <literallayout class='monospaced'>
  2788. REALPV = "0.8.16-rc1"
  2789. PV = "0.8.15+${REALPV}"
  2790. </literallayout>
  2791. </para>
  2792. </section>
  2793. <section id='new-recipe-post-installation-scripts'>
  2794. <title>Post-Installation Scripts</title>
  2795. <para>
  2796. Post-installation scripts run immediately after installing
  2797. a package on the target or during image creation when a
  2798. package is included in an image.
  2799. To add a post-installation script to a package, add a
  2800. <filename>pkg_postinst_</filename><replaceable>PACKAGENAME</replaceable><filename>()</filename> function to
  2801. the recipe file (<filename>.bb</filename>) and replace
  2802. <replaceable>PACKAGENAME</replaceable> with the name of the package
  2803. you want to attach to the <filename>postinst</filename>
  2804. script.
  2805. To apply the post-installation script to the main package
  2806. for the recipe, which is usually what is required, specify
  2807. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2808. in place of <replaceable>PACKAGENAME</replaceable>.
  2809. </para>
  2810. <para>
  2811. A post-installation function has the following structure:
  2812. <literallayout class='monospaced'>
  2813. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  2814. # Commands to carry out
  2815. }
  2816. </literallayout>
  2817. </para>
  2818. <para>
  2819. The script defined in the post-installation function is
  2820. called when the root filesystem is created.
  2821. If the script succeeds, the package is marked as installed.
  2822. If the script fails, the package is marked as unpacked and
  2823. the script is executed when the image boots again.
  2824. <note>
  2825. Any RPM post-installation script that runs on the target
  2826. should return a 0 exit code.
  2827. RPM does not allow non-zero exit codes for these scripts,
  2828. and the RPM package manager will cause the package to fail
  2829. installation on the target.
  2830. </note>
  2831. </para>
  2832. <para>
  2833. Sometimes it is necessary for the execution of a
  2834. post-installation script to be delayed until the first boot.
  2835. For example, the script might need to be executed on the
  2836. device itself.
  2837. To delay script execution until boot time, use the following
  2838. structure in the post-installation script:
  2839. <literallayout class='monospaced'>
  2840. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  2841. if [ x"$D" = "x" ]; then
  2842. # Actions to carry out on the device go here
  2843. else
  2844. exit 1
  2845. fi
  2846. }
  2847. </literallayout>
  2848. </para>
  2849. <para>
  2850. The previous example delays execution until the image boots
  2851. again because the environment variable <filename>D</filename>
  2852. points to the directory containing the image when
  2853. the root filesystem is created at build time but is unset
  2854. when executed on the first boot.
  2855. </para>
  2856. <para>
  2857. If you have recipes that use <filename>pkg_postinst</filename>
  2858. scripts and they require the use of non-standard native
  2859. tools that have dependencies during rootfs construction, you
  2860. need to use the
  2861. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink>
  2862. variable in your recipe to list these tools.
  2863. If you do not use this variable, the tools might be missing and
  2864. execution of the post-installation script is deferred until
  2865. first boot.
  2866. Deferring the script to first boot is undesirable and for
  2867. read-only rootfs impossible.
  2868. </para>
  2869. <note>
  2870. Equivalent support for pre-install, pre-uninstall, and
  2871. post-uninstall scripts exist by way of
  2872. <filename>pkg_preinst</filename>,
  2873. <filename>pkg_prerm</filename>, and
  2874. <filename>pkg_postrm</filename>, respectively.
  2875. These scrips work in exactly the same way as does
  2876. <filename>pkg_postinst</filename> with the exception that they
  2877. run at different times.
  2878. Also, because of when they run, they are not applicable to
  2879. being run at image creation time like
  2880. <filename>pkg_postinst</filename>.
  2881. </note>
  2882. </section>
  2883. <section id='new-recipe-testing'>
  2884. <title>Testing</title>
  2885. <para>
  2886. The final step for completing your recipe is to be sure that
  2887. the software you built runs correctly.
  2888. To accomplish runtime testing, add the build's output
  2889. packages to your image and test them on the target.
  2890. </para>
  2891. <para>
  2892. For information on how to customize your image by adding
  2893. specific packages, see the
  2894. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  2895. section.
  2896. </para>
  2897. </section>
  2898. <section id='new-recipe-testing-examples'>
  2899. <title>Examples</title>
  2900. <para>
  2901. To help summarize how to write a recipe, this section provides
  2902. some examples given various scenarios:
  2903. <itemizedlist>
  2904. <listitem><para>Recipes that use local files</para></listitem>
  2905. <listitem><para>Using an Autotooled package</para></listitem>
  2906. <listitem><para>Using a Makefile-based package</para></listitem>
  2907. <listitem><para>Splitting an application into multiple packages</para></listitem>
  2908. <listitem><para>Adding binaries to an image</para></listitem>
  2909. </itemizedlist>
  2910. </para>
  2911. <section id='new-recipe-single-c-file-package-hello-world'>
  2912. <title>Single .c File Package (Hello World!)</title>
  2913. <para>
  2914. Building an application from a single file that is stored
  2915. locally (e.g. under <filename>files</filename>) requires
  2916. a recipe that has the file listed in the
  2917. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  2918. variable.
  2919. Additionally, you need to manually write the
  2920. <filename>do_compile</filename> and
  2921. <filename>do_install</filename> tasks.
  2922. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  2923. variable defines the directory containing the source code,
  2924. which is set to
  2925. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  2926. in this case - the directory BitBake uses for the build.
  2927. <literallayout class='monospaced'>
  2928. SUMMARY = "Simple helloworld application"
  2929. SECTION = "examples"
  2930. LICENSE = "MIT"
  2931. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  2932. SRC_URI = "file://helloworld.c"
  2933. S = "${WORKDIR}"
  2934. do_compile() {
  2935. ${CC} helloworld.c -o helloworld
  2936. }
  2937. do_install() {
  2938. install -d ${D}${bindir}
  2939. install -m 0755 helloworld ${D}${bindir}
  2940. }
  2941. </literallayout>
  2942. </para>
  2943. <para>
  2944. By default, the <filename>helloworld</filename>,
  2945. <filename>helloworld-dbg</filename>, and
  2946. <filename>helloworld-dev</filename> packages are built.
  2947. For information on how to customize the packaging process,
  2948. see the
  2949. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2950. section.
  2951. </para>
  2952. </section>
  2953. <section id='new-recipe-autotooled-package'>
  2954. <title>Autotooled Package</title>
  2955. <para>
  2956. Applications that use Autotools such as <filename>autoconf</filename> and
  2957. <filename>automake</filename> require a recipe that has a source archive listed in
  2958. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  2959. also inherit the
  2960. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2961. class, which contains the definitions of all the steps
  2962. needed to build an Autotool-based application.
  2963. The result of the build is automatically packaged.
  2964. And, if the application uses NLS for localization, packages with local information are
  2965. generated (one package per language).
  2966. Following is one example: (<filename>hello_2.3.bb</filename>)
  2967. <literallayout class='monospaced'>
  2968. SUMMARY = "GNU Helloworld application"
  2969. SECTION = "examples"
  2970. LICENSE = "GPLv2+"
  2971. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  2972. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  2973. inherit autotools gettext
  2974. </literallayout>
  2975. </para>
  2976. <para>
  2977. The variable
  2978. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  2979. is used to track source license changes as described in the
  2980. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  2981. section in the Yocto Project Overview Manual.
  2982. You can quickly create Autotool-based recipes in a manner similar to the previous example.
  2983. </para>
  2984. </section>
  2985. <section id='new-recipe-makefile-based-package'>
  2986. <title>Makefile-Based Package</title>
  2987. <para>
  2988. Applications that use GNU <filename>make</filename> also require a recipe that has
  2989. the source archive listed in
  2990. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  2991. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  2992. starts the <filename>make</filename> command to compile the application.
  2993. If you need additional <filename>make</filename> options, you should store them in the
  2994. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
  2995. or
  2996. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2997. variables.
  2998. BitBake passes these options into the GNU <filename>make</filename> invocation.
  2999. Note that a <filename>do_install</filename> task is still required.
  3000. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  3001. </para>
  3002. <para>
  3003. Some applications might require extra parameters to be passed to the compiler.
  3004. For example, the application might need an additional header path.
  3005. You can accomplish this by adding to the
  3006. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  3007. The following example shows this:
  3008. <literallayout class='monospaced'>
  3009. CFLAGS_prepend = "-I ${S}/include "
  3010. </literallayout>
  3011. </para>
  3012. <para>
  3013. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  3014. <literallayout class='monospaced'>
  3015. SUMMARY = "Tools for managing memory technology devices"
  3016. SECTION = "base"
  3017. DEPENDS = "zlib lzo e2fsprogs util-linux"
  3018. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  3019. LICENSE = "GPLv2+"
  3020. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  3021. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  3022. # Use the latest version at 26 Oct, 2013
  3023. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  3024. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  3025. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  3026. "
  3027. PV = "1.5.1+git${SRCPV}"
  3028. S = "${WORKDIR}/git"
  3029. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  3030. do_install () {
  3031. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  3032. }
  3033. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  3034. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  3035. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  3036. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  3037. PARALLEL_MAKE = ""
  3038. BBCLASSEXTEND = "native"
  3039. </literallayout>
  3040. </para>
  3041. </section>
  3042. <section id='splitting-an-application-into-multiple-packages'>
  3043. <title>Splitting an Application into Multiple Packages</title>
  3044. <para>
  3045. You can use the variables
  3046. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  3047. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  3048. to split an application into multiple packages.
  3049. </para>
  3050. <para>
  3051. Following is an example that uses the <filename>libxpm</filename> recipe.
  3052. By default, this recipe generates a single package that contains the library along
  3053. with a few binaries.
  3054. You can modify the recipe to split the binaries into separate packages:
  3055. <literallayout class='monospaced'>
  3056. require xorg-lib-common.inc
  3057. SUMMARY = "Xpm: X Pixmap extension library"
  3058. LICENSE = "BSD"
  3059. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  3060. DEPENDS += "libxext libsm libxt"
  3061. PE = "1"
  3062. XORG_PN = "libXpm"
  3063. PACKAGES =+ "sxpm cxpm"
  3064. FILES_cxpm = "${bindir}/cxpm"
  3065. FILES_sxpm = "${bindir}/sxpm"
  3066. </literallayout>
  3067. </para>
  3068. <para>
  3069. In the previous example, we want to ship the <filename>sxpm</filename>
  3070. and <filename>cxpm</filename> binaries in separate packages.
  3071. Since <filename>bindir</filename> would be packaged into the main
  3072. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  3073. package by default, we prepend the <filename>PACKAGES</filename>
  3074. variable so additional package names are added to the start of list.
  3075. This results in the extra <filename>FILES_*</filename>
  3076. variables then containing information that define which files and
  3077. directories go into which packages.
  3078. Files included by earlier packages are skipped by latter packages.
  3079. Thus, the main <filename>PN</filename> package
  3080. does not include the above listed files.
  3081. </para>
  3082. </section>
  3083. <section id='packaging-externally-produced-binaries'>
  3084. <title>Packaging Externally Produced Binaries</title>
  3085. <para>
  3086. Sometimes, you need to add pre-compiled binaries to an
  3087. image.
  3088. For example, suppose that binaries for proprietary code
  3089. exist, which are created by a particular division of a
  3090. company.
  3091. Your part of the company needs to use those binaries as
  3092. part of an image that you are building using the
  3093. OpenEmbedded build system.
  3094. Since you only have the binaries and not the source code,
  3095. you cannot use a typical recipe that expects to fetch the
  3096. source specified in
  3097. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  3098. and then compile it.
  3099. </para>
  3100. <para>
  3101. One method is to package the binaries and then install them
  3102. as part of the image.
  3103. Generally, it is not a good idea to package binaries
  3104. since, among other things, it can hinder the ability to
  3105. reproduce builds and could lead to compatibility problems
  3106. with ABI in the future.
  3107. However, sometimes you have no choice.
  3108. </para>
  3109. <para>
  3110. The easiest solution is to create a recipe that uses
  3111. the
  3112. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  3113. class and to be sure that you are using default locations
  3114. for build artifacts.
  3115. In most cases, the <filename>bin_package</filename> class
  3116. handles "skipping" the configure and compile steps as well
  3117. as sets things up to grab packages from the appropriate
  3118. area.
  3119. In particular, this class sets <filename>noexec</filename>
  3120. on both the
  3121. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3122. and
  3123. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3124. tasks, sets
  3125. <filename>FILES_${PN}</filename> to "/" so that it picks
  3126. up all files, and sets up a
  3127. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3128. task, which effectively copies all files from
  3129. <filename>${S}</filename> to <filename>${D}</filename>.
  3130. The <filename>bin_package</filename> class works well when
  3131. the files extracted into <filename>${S}</filename> are
  3132. already laid out in the way they should be laid out
  3133. on the target.
  3134. For more information on these variables, see the
  3135. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  3136. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  3137. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  3138. and
  3139. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  3140. variables in the Yocto Project Reference Manual's variable
  3141. glossary.
  3142. <note><title>Notes</title>
  3143. <itemizedlist>
  3144. <listitem><para>
  3145. Using
  3146. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3147. is a good idea even for components distributed
  3148. in binary form, and is often necessary for
  3149. shared libraries.
  3150. For a shared library, listing the library
  3151. dependencies in
  3152. <filename>DEPENDS</filename> makes sure that
  3153. the libraries are available in the staging
  3154. sysroot when other recipes link against the
  3155. library, which might be necessary for
  3156. successful linking.
  3157. </para></listitem>
  3158. <listitem><para>
  3159. Using <filename>DEPENDS</filename> also
  3160. allows runtime dependencies between packages
  3161. to be added automatically.
  3162. See the
  3163. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  3164. section in the Yocto Project Overview Manual
  3165. for more information.
  3166. </para></listitem>
  3167. </itemizedlist>
  3168. </note>
  3169. </para>
  3170. <para>
  3171. If you cannot use the <filename>bin_package</filename>
  3172. class, you need to be sure you are doing the following:
  3173. <itemizedlist>
  3174. <listitem><para>
  3175. Create a recipe where the
  3176. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3177. and
  3178. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3179. tasks do nothing:
  3180. It is usually sufficient to just not define these
  3181. tasks in the recipe, because the default
  3182. implementations do nothing unless a Makefile is
  3183. found in
  3184. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>.
  3185. </para>
  3186. <para>If
  3187. <filename>${S}</filename> might contain a Makefile,
  3188. or if you inherit some class that replaces
  3189. <filename>do_configure</filename> and
  3190. <filename>do_compile</filename> with custom
  3191. versions, then you can use the
  3192. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename>
  3193. flag to turn the tasks into no-ops, as follows:
  3194. <literallayout class='monospaced'>
  3195. do_configure[noexec] = "1"
  3196. do_compile[noexec] = "1"
  3197. </literallayout>
  3198. Unlike
  3199. <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>,
  3200. using the flag preserves the dependency chain from
  3201. the
  3202. <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>,
  3203. and
  3204. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3205. tasks to the
  3206. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3207. task.
  3208. </para></listitem>
  3209. <listitem><para>Make sure your
  3210. <filename>do_install</filename> task installs the
  3211. binaries appropriately.
  3212. </para></listitem>
  3213. <listitem><para>Ensure that you set up
  3214. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3215. (usually
  3216. <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>)
  3217. to point to the files you have installed, which of
  3218. course depends on where you have installed them
  3219. and whether those files are in different locations
  3220. than the defaults.
  3221. </para></listitem>
  3222. </itemizedlist>
  3223. </para>
  3224. </section>
  3225. </section>
  3226. <section id="following-recipe-style-guidelines">
  3227. <title>Following Recipe Style Guidelines</title>
  3228. <para>
  3229. When writing recipes, it is good to conform to existing
  3230. style guidelines.
  3231. The
  3232. <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink>
  3233. wiki page provides rough guidelines for preferred recipe style.
  3234. </para>
  3235. <para>
  3236. It is common for existing recipes to deviate a bit from this
  3237. style.
  3238. However, aiming for at least a consistent style is a good idea.
  3239. Some practices, such as omitting spaces around
  3240. <filename>=</filename> operators in assignments or ordering
  3241. recipe components in an erratic way, are widely seen as poor
  3242. style.
  3243. </para>
  3244. </section>
  3245. </section>
  3246. <section id="platdev-newmachine">
  3247. <title>Adding a New Machine</title>
  3248. <para>
  3249. Adding a new machine to the Yocto Project is a straightforward
  3250. process.
  3251. This section describes how to add machines that are similar
  3252. to those that the Yocto Project already supports.
  3253. <note>
  3254. Although well within the capabilities of the Yocto Project,
  3255. adding a totally new architecture might require
  3256. changes to <filename>gcc/glibc</filename> and to the site
  3257. information, which is beyond the scope of this manual.
  3258. </note>
  3259. </para>
  3260. <para>
  3261. For a complete example that shows how to add a new machine,
  3262. see the
  3263. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'>Creating a New BSP Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  3264. section in the Yocto Project Board Support Package (BSP)
  3265. Developer's Guide.
  3266. </para>
  3267. <section id="platdev-newmachine-conffile">
  3268. <title>Adding the Machine Configuration File</title>
  3269. <para>
  3270. To add a new machine, you need to add a new machine
  3271. configuration file to the layer's
  3272. <filename>conf/machine</filename> directory.
  3273. This configuration file provides details about the device
  3274. you are adding.
  3275. </para>
  3276. <para>
  3277. The OpenEmbedded build system uses the root name of the
  3278. machine configuration file to reference the new machine.
  3279. For example, given a machine configuration file named
  3280. <filename>crownbay.conf</filename>, the build system
  3281. recognizes the machine as "crownbay".
  3282. </para>
  3283. <para>
  3284. The most important variables you must set in your machine
  3285. configuration file or include from a lower-level configuration
  3286. file are as follows:
  3287. <itemizedlist>
  3288. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  3289. (e.g. "arm")</para></listitem>
  3290. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  3291. </para></listitem>
  3292. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  3293. (e.g. "apm screen wifi")</para></listitem>
  3294. </itemizedlist>
  3295. </para>
  3296. <para>
  3297. You might also need these variables:
  3298. <itemizedlist>
  3299. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  3300. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  3301. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  3302. (e.g. "zImage")</para></listitem>
  3303. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  3304. (e.g. "tar.gz jffs2")</para></listitem>
  3305. </itemizedlist>
  3306. </para>
  3307. <para>
  3308. You can find full details on these variables in the reference
  3309. section.
  3310. You can leverage existing machine <filename>.conf</filename>
  3311. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  3312. </para>
  3313. </section>
  3314. <section id="platdev-newmachine-kernel">
  3315. <title>Adding a Kernel for the Machine</title>
  3316. <para>
  3317. The OpenEmbedded build system needs to be able to build a kernel
  3318. for the machine.
  3319. You need to either create a new kernel recipe for this machine,
  3320. or extend an existing kernel recipe.
  3321. You can find several kernel recipe examples in the
  3322. Source Directory at
  3323. <filename>meta/recipes-kernel/linux</filename>
  3324. that you can use as references.
  3325. </para>
  3326. <para>
  3327. If you are creating a new kernel recipe, normal recipe-writing
  3328. rules apply for setting up a
  3329. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3330. Thus, you need to specify any necessary patches and set
  3331. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3332. to point at the source code.
  3333. You need to create a <filename>do_configure</filename> task that
  3334. configures the unpacked kernel with a
  3335. <filename>defconfig</filename> file.
  3336. You can do this by using a <filename>make defconfig</filename>
  3337. command or, more commonly, by copying in a suitable
  3338. <filename>defconfig</filename> file and then running
  3339. <filename>make oldconfig</filename>.
  3340. By making use of <filename>inherit kernel</filename> and
  3341. potentially some of the <filename>linux-*.inc</filename> files,
  3342. most other functionality is centralized and the defaults of the
  3343. class normally work well.
  3344. </para>
  3345. <para>
  3346. If you are extending an existing kernel recipe, it is usually
  3347. a matter of adding a suitable <filename>defconfig</filename>
  3348. file.
  3349. The file needs to be added into a location similar to
  3350. <filename>defconfig</filename> files used for other machines
  3351. in a given kernel recipe.
  3352. A possible way to do this is by listing the file in the
  3353. <filename>SRC_URI</filename> and adding the machine to the
  3354. expression in
  3355. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  3356. <literallayout class='monospaced'>
  3357. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  3358. </literallayout>
  3359. For more information on <filename>defconfig</filename> files,
  3360. see the
  3361. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  3362. section in the Yocto Project Linux Kernel Development Manual.
  3363. </para>
  3364. </section>
  3365. <section id="platdev-newmachine-formfactor">
  3366. <title>Adding a Formfactor Configuration File</title>
  3367. <para>
  3368. A formfactor configuration file provides information about the
  3369. target hardware for which the image is being built and information that
  3370. the build system cannot obtain from other sources such as the kernel.
  3371. Some examples of information contained in a formfactor configuration file include
  3372. framebuffer orientation, whether or not the system has a keyboard,
  3373. the positioning of the keyboard in relation to the screen, and
  3374. the screen resolution.
  3375. </para>
  3376. <para>
  3377. The build system uses reasonable defaults in most cases.
  3378. However, if customization is
  3379. necessary, you need to create a <filename>machconfig</filename> file
  3380. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  3381. directory.
  3382. This directory contains directories for specific machines such as
  3383. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  3384. For information about the settings available and the defaults, see the
  3385. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  3386. same area.
  3387. </para>
  3388. <para>
  3389. Following is an example for "qemuarm" machine:
  3390. <literallayout class='monospaced'>
  3391. HAVE_TOUCHSCREEN=1
  3392. HAVE_KEYBOARD=1
  3393. DISPLAY_CAN_ROTATE=0
  3394. DISPLAY_ORIENTATION=0
  3395. #DISPLAY_WIDTH_PIXELS=640
  3396. #DISPLAY_HEIGHT_PIXELS=480
  3397. #DISPLAY_BPP=16
  3398. DISPLAY_DPI=150
  3399. DISPLAY_SUBPIXEL_ORDER=vrgb
  3400. </literallayout>
  3401. </para>
  3402. </section>
  3403. </section>
  3404. <section id='finding-the-temporary-source-code'>
  3405. <title>Finding Temporary Source Code</title>
  3406. <para>
  3407. You might find it helpful during development to modify the
  3408. temporary source code used by recipes to build packages.
  3409. For example, suppose you are developing a patch and you need to
  3410. experiment a bit to figure out your solution.
  3411. After you have initially built the package, you can iteratively
  3412. tweak the source code, which is located in the
  3413. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  3414. and then you can force a re-compile and quickly test your altered
  3415. code.
  3416. Once you settle on a solution, you can then preserve your changes
  3417. in the form of patches.
  3418. </para>
  3419. <para>
  3420. During a build, the unpacked temporary source code used by recipes
  3421. to build packages is available in the Build Directory as
  3422. defined by the
  3423. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  3424. variable.
  3425. Below is the default value for the <filename>S</filename> variable
  3426. as defined in the
  3427. <filename>meta/conf/bitbake.conf</filename> configuration file
  3428. in the
  3429. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  3430. <literallayout class='monospaced'>
  3431. S = "${WORKDIR}/${BP}"
  3432. </literallayout>
  3433. You should be aware that many recipes override the
  3434. <filename>S</filename> variable.
  3435. For example, recipes that fetch their source from Git usually set
  3436. <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
  3437. <note>
  3438. The
  3439. <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  3440. represents the base recipe name, which consists of the name
  3441. and version:
  3442. <literallayout class='monospaced'>
  3443. BP = "${BPN}-${PV}"
  3444. </literallayout>
  3445. </note>
  3446. </para>
  3447. <para>
  3448. The path to the work directory for the recipe
  3449. (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
  3450. is defined as follows:
  3451. <literallayout class='monospaced'>
  3452. ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
  3453. </literallayout>
  3454. The actual directory depends on several things:
  3455. <itemizedlist>
  3456. <listitem><para>
  3457. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  3458. The top-level build output directory.
  3459. </para></listitem>
  3460. <listitem><para>
  3461. <ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
  3462. The target system identifier.
  3463. </para></listitem>
  3464. <listitem><para>
  3465. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  3466. The recipe name.
  3467. </para></listitem>
  3468. <listitem><para>
  3469. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
  3470. The epoch - (if
  3471. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
  3472. is not specified, which is usually the case for most
  3473. recipes, then <filename>EXTENDPE</filename> is blank).
  3474. </para></listitem>
  3475. <listitem><para>
  3476. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  3477. The recipe version.
  3478. </para></listitem>
  3479. <listitem><para>
  3480. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  3481. The recipe revision.
  3482. </para></listitem>
  3483. </itemizedlist>
  3484. </para>
  3485. <para>
  3486. As an example, assume a Source Directory top-level folder
  3487. named <filename>poky</filename>, a default Build Directory at
  3488. <filename>poky/build</filename>, and a
  3489. <filename>qemux86-poky-linux</filename> machine target
  3490. system.
  3491. Furthermore, suppose your recipe is named
  3492. <filename>foo_1.3.0.bb</filename>.
  3493. In this case, the work directory the build system uses to
  3494. build the package would be as follows:
  3495. <literallayout class='monospaced'>
  3496. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  3497. </literallayout>
  3498. </para>
  3499. </section>
  3500. <section id="using-a-quilt-workflow">
  3501. <title>Using Quilt in Your Workflow</title>
  3502. <para>
  3503. <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
  3504. is a powerful tool that allows you to capture source code changes
  3505. without having a clean source tree.
  3506. This section outlines the typical workflow you can use to modify
  3507. source code, test changes, and then preserve the changes in the
  3508. form of a patch all using Quilt.
  3509. <note><title>Tip</title>
  3510. With regard to preserving changes to source files, if you
  3511. clean a recipe or have <filename>rm_work</filename> enabled,
  3512. the
  3513. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink>
  3514. as described in the Yocto Project Application Development
  3515. and the Extensible Software Development Kit (eSDK) manual
  3516. is a safer development flow than the flow that uses Quilt.
  3517. </note>
  3518. </para>
  3519. <para>
  3520. Follow these general steps:
  3521. <orderedlist>
  3522. <listitem><para>
  3523. <emphasis>Find the Source Code:</emphasis>
  3524. Temporary source code used by the OpenEmbedded build system
  3525. is kept in the
  3526. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  3527. See the
  3528. "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
  3529. section to learn how to locate the directory that has the
  3530. temporary source code for a particular package.
  3531. </para></listitem>
  3532. <listitem><para>
  3533. <emphasis>Change Your Working Directory:</emphasis>
  3534. You need to be in the directory that has the temporary
  3535. source code.
  3536. That directory is defined by the
  3537. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  3538. variable.</para></listitem>
  3539. <listitem><para>
  3540. <emphasis>Create a New Patch:</emphasis>
  3541. Before modifying source code, you need to create a new
  3542. patch.
  3543. To create a new patch file, use
  3544. <filename>quilt new</filename> as below:
  3545. <literallayout class='monospaced'>
  3546. $ quilt new my_changes.patch
  3547. </literallayout>
  3548. </para></listitem>
  3549. <listitem><para>
  3550. <emphasis>Notify Quilt and Add Files:</emphasis>
  3551. After creating the patch, you need to notify Quilt about
  3552. the files you plan to edit.
  3553. You notify Quilt by adding the files to the patch you
  3554. just created:
  3555. <literallayout class='monospaced'>
  3556. $ quilt add file1.c file2.c file3.c
  3557. </literallayout>
  3558. </para></listitem>
  3559. <listitem><para>
  3560. <emphasis>Edit the Files:</emphasis>
  3561. Make your changes in the source code to the files you added
  3562. to the patch.
  3563. </para></listitem>
  3564. <listitem><para>
  3565. <emphasis>Test Your Changes:</emphasis>
  3566. Once you have modified the source code, the easiest way to
  3567. test your changes is by calling the
  3568. <filename>do_compile</filename> task as shown in the
  3569. following example:
  3570. <literallayout class='monospaced'>
  3571. $ bitbake -c compile -f <replaceable>package</replaceable>
  3572. </literallayout>
  3573. The <filename>-f</filename> or <filename>--force</filename>
  3574. option forces the specified task to execute.
  3575. If you find problems with your code, you can just keep
  3576. editing and re-testing iteratively until things work
  3577. as expected.
  3578. <note>
  3579. All the modifications you make to the temporary
  3580. source code disappear once you run the
  3581. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
  3582. or
  3583. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
  3584. tasks using BitBake (i.e.
  3585. <filename>bitbake -c clean <replaceable>package</replaceable></filename>
  3586. and
  3587. <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
  3588. Modifications will also disappear if you use the
  3589. <filename>rm_work</filename> feature as described
  3590. in the
  3591. "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
  3592. section of the Yocto Project Quick Start.
  3593. </note>
  3594. </para></listitem>
  3595. <listitem><para>
  3596. <emphasis>Generate the Patch:</emphasis>
  3597. Once your changes work as expected, you need to use Quilt
  3598. to generate the final patch that contains all your
  3599. modifications.
  3600. <literallayout class='monospaced'>
  3601. $ quilt refresh
  3602. </literallayout>
  3603. At this point, the <filename>my_changes.patch</filename>
  3604. file has all your edits made to the
  3605. <filename>file1.c</filename>, <filename>file2.c</filename>,
  3606. and <filename>file3.c</filename> files.</para>
  3607. <para>You can find the resulting patch file in the
  3608. <filename>patches/</filename> subdirectory of the source
  3609. (<filename>S</filename>) directory.
  3610. </para></listitem>
  3611. <listitem><para>
  3612. <emphasis>Copy the Patch File:</emphasis>
  3613. For simplicity, copy the patch file into a directory
  3614. named <filename>files</filename>, which you can create
  3615. in the same directory that holds the recipe
  3616. (<filename>.bb</filename>) file or the append
  3617. (<filename>.bbappend</filename>) file.
  3618. Placing the patch here guarantees that the OpenEmbedded
  3619. build system will find the patch.
  3620. Next, add the patch into the
  3621. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  3622. of the recipe.
  3623. Here is an example:
  3624. <literallayout class='monospaced'>
  3625. SRC_URI += "file://my_changes.patch"
  3626. </literallayout>
  3627. </para></listitem>
  3628. </orderedlist>
  3629. </para>
  3630. </section>
  3631. <section id="platdev-appdev-devshell">
  3632. <title>Using a Development Shell</title>
  3633. <para>
  3634. When debugging certain commands or even when just editing packages,
  3635. <filename>devshell</filename> can be a useful tool.
  3636. When you invoke <filename>devshell</filename>, all tasks up to and
  3637. including
  3638. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3639. are run for the specified target.
  3640. Then, a new terminal is opened and you are placed in
  3641. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  3642. the source directory.
  3643. In the new terminal, all the OpenEmbedded build-related environment variables are
  3644. still defined so you can use commands such as <filename>configure</filename> and
  3645. <filename>make</filename>.
  3646. The commands execute just as if the OpenEmbedded build system were executing them.
  3647. Consequently, working this way can be helpful when debugging a build or preparing
  3648. software to be used with the OpenEmbedded build system.
  3649. </para>
  3650. <para>
  3651. Following is an example that uses <filename>devshell</filename> on a target named
  3652. <filename>matchbox-desktop</filename>:
  3653. <literallayout class='monospaced'>
  3654. $ bitbake matchbox-desktop -c devshell
  3655. </literallayout>
  3656. </para>
  3657. <para>
  3658. This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
  3659. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  3660. variable controls what type of shell is opened.
  3661. </para>
  3662. <para>
  3663. For spawned terminals, the following occurs:
  3664. <itemizedlist>
  3665. <listitem><para>The <filename>PATH</filename> variable includes the
  3666. cross-toolchain.</para></listitem>
  3667. <listitem><para>The <filename>pkgconfig</filename> variables find the correct
  3668. <filename>.pc</filename> files.</para></listitem>
  3669. <listitem><para>The <filename>configure</filename> command finds the
  3670. Yocto Project site files as well as any other necessary files.</para></listitem>
  3671. </itemizedlist>
  3672. </para>
  3673. <para>
  3674. Within this environment, you can run configure or compile
  3675. commands as if they were being run by
  3676. the OpenEmbedded build system itself.
  3677. As noted earlier, the working directory also automatically changes to the
  3678. Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
  3679. </para>
  3680. <para>
  3681. To manually run a specific task using <filename>devshell</filename>,
  3682. run the corresponding <filename>run.*</filename> script in
  3683. the
  3684. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename>
  3685. directory (e.g.,
  3686. <filename>run.do_configure.</filename><replaceable>pid</replaceable>).
  3687. If a task's script does not exist, which would be the case if the task was
  3688. skipped by way of the sstate cache, you can create the task by first running
  3689. it outside of the <filename>devshell</filename>:
  3690. <literallayout class='monospaced'>
  3691. $ bitbake -c <replaceable>task</replaceable>
  3692. </literallayout>
  3693. <note><title>Notes</title>
  3694. <itemizedlist>
  3695. <listitem><para>Execution of a task's <filename>run.*</filename>
  3696. script and BitBake's execution of a task are identical.
  3697. In other words, running the script re-runs the task
  3698. just as it would be run using the
  3699. <filename>bitbake -c</filename> command.
  3700. </para></listitem>
  3701. <listitem><para>Any <filename>run.*</filename> file that does not
  3702. have a <filename>.pid</filename> extension is a
  3703. symbolic link (symlink) to the most recent version of that
  3704. file.
  3705. </para></listitem>
  3706. </itemizedlist>
  3707. </note>
  3708. </para>
  3709. <para>
  3710. Remember, that the <filename>devshell</filename> is a mechanism that allows
  3711. you to get into the BitBake task execution environment.
  3712. And as such, all commands must be called just as BitBake would call them.
  3713. That means you need to provide the appropriate options for
  3714. cross-compilation and so forth as applicable.
  3715. </para>
  3716. <para>
  3717. When you are finished using <filename>devshell</filename>, exit the shell
  3718. or close the terminal window.
  3719. </para>
  3720. <note><title>Notes</title>
  3721. <itemizedlist>
  3722. <listitem><para>
  3723. It is worth remembering that when using <filename>devshell</filename>
  3724. you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
  3725. instead of just using <filename>gcc</filename>.
  3726. The same applies to other applications such as <filename>binutils</filename>,
  3727. <filename>libtool</filename> and so forth.
  3728. BitBake sets up environment variables such as <filename>CC</filename>
  3729. to assist applications, such as <filename>make</filename> to find the correct tools.
  3730. </para></listitem>
  3731. <listitem><para>
  3732. It is also worth noting that <filename>devshell</filename> still works over
  3733. X11 forwarding and similar situations.
  3734. </para></listitem>
  3735. </itemizedlist>
  3736. </note>
  3737. </section>
  3738. <section id="platdev-appdev-devpyshell">
  3739. <title>Using a Development Python Shell</title>
  3740. <para>
  3741. Similar to working within a development shell as described in
  3742. the previous section, you can also spawn and work within an
  3743. interactive Python development shell.
  3744. When debugging certain commands or even when just editing packages,
  3745. <filename>devpyshell</filename> can be a useful tool.
  3746. When you invoke <filename>devpyshell</filename>, all tasks up to and
  3747. including
  3748. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3749. are run for the specified target.
  3750. Then a new terminal is opened.
  3751. Additionally, key Python objects and code are available in the same
  3752. way they are to BitBake tasks, in particular, the data store 'd'.
  3753. So, commands such as the following are useful when exploring the data
  3754. store and running functions:
  3755. <literallayout class='monospaced'>
  3756. pydevshell> d.getVar("STAGING_DIR", True)
  3757. '/media/build1/poky/build/tmp/sysroots'
  3758. pydevshell> d.getVar("STAGING_DIR", False)
  3759. '${TMPDIR}/sysroots'
  3760. pydevshell> d.setVar("FOO", "bar")
  3761. pydevshell> d.getVar("FOO", True)
  3762. 'bar'
  3763. pydevshell> d.delVar("FOO")
  3764. pydevshell> d.getVar("FOO", True)
  3765. pydevshell> bb.build.exec_func("do_unpack", d)
  3766. pydevshell>
  3767. </literallayout>
  3768. The commands execute just as if the OpenEmbedded build system were executing them.
  3769. Consequently, working this way can be helpful when debugging a build or preparing
  3770. software to be used with the OpenEmbedded build system.
  3771. </para>
  3772. <para>
  3773. Following is an example that uses <filename>devpyshell</filename> on a target named
  3774. <filename>matchbox-desktop</filename>:
  3775. <literallayout class='monospaced'>
  3776. $ bitbake matchbox-desktop -c devpyshell
  3777. </literallayout>
  3778. </para>
  3779. <para>
  3780. This command spawns a terminal and places you in an interactive
  3781. Python interpreter within the OpenEmbedded build environment.
  3782. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  3783. variable controls what type of shell is opened.
  3784. </para>
  3785. <para>
  3786. When you are finished using <filename>devpyshell</filename>, you
  3787. can exit the shell either by using Ctrl+d or closing the terminal
  3788. window.
  3789. </para>
  3790. </section>
  3791. <section id='platdev-building-targets-with-multiple-configurations'>
  3792. <title>Building Targets with Multiple Configurations</title>
  3793. <para>
  3794. Bitbake also has functionality that allows you to build
  3795. multiple targets at the same time, where each target uses
  3796. a different configuration.
  3797. </para>
  3798. <para>
  3799. In order to accomplish this, you setup each of the configurations
  3800. you need to use in parallel by placing the configuration files in
  3801. your current build directory alongside the usual
  3802. <filename>local.conf</filename> file.
  3803. </para>
  3804. <para>
  3805. Follow these guidelines to create an environment that supports
  3806. multiple configurations:
  3807. <itemizedlist>
  3808. <listitem><para>
  3809. <emphasis>Create Configuration Files</emphasis>:
  3810. You need to create a single configuration file for each
  3811. configuration for which you want to add support.
  3812. These files would contain lines such as the following:
  3813. <literallayout class='monospaced'>
  3814. MACHINE = "A"
  3815. </literallayout>
  3816. The files would contain any other variables that can
  3817. be set and built in the same directory.
  3818. <note>
  3819. You can change the
  3820. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  3821. to not conflict.
  3822. </note></para>
  3823. <para>
  3824. Furthermore, the configuration file must be located in the
  3825. current build directory in a directory named
  3826. <filename>multiconfig</filename> under the build's
  3827. <filename>conf</filename> directory where
  3828. <filename>local.conf</filename> resides.
  3829. The reason for this restriction is because the
  3830. <filename>BBPATH</filename> variable is not constructed
  3831. until the layers are parsed.
  3832. Consequently, using the configuration file as a
  3833. pre-configuration file is not possible unless it is
  3834. located in the current working directory.
  3835. </para></listitem>
  3836. <listitem><para>
  3837. <emphasis>Add the BitBake Multi-Config Variable to you Local Configuration File</emphasis>:
  3838. Use the
  3839. <filename>BBMULTICONFIG</filename>
  3840. variable in your <filename>conf/local.conf</filename>
  3841. configuration file to specify each separate configuration.
  3842. For example, the following line tells BitBake it should load
  3843. <filename>conf/multiconfig/configA.conf</filename>,
  3844. <filename>conf/multiconfig/configB.conf</filename>, and
  3845. <filename>conf/multiconfig/configC.conf</filename>.
  3846. <literallayout class='monospaced'>
  3847. BBMULTICONFIG = "configA configB configC"
  3848. </literallayout>
  3849. </para></listitem>
  3850. <listitem><para>
  3851. <emphasis>Launch BitBake</emphasis>:
  3852. Use the following BitBake command form to launch the
  3853. build:
  3854. <literallayout class='monospaced'>
  3855. $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ]
  3856. </literallayout>
  3857. Following is an example that supports building a minimal
  3858. image for configuration A alongside a standard
  3859. <filename>core-image-sato</filename>, which takes its
  3860. configuration from <filename>local.conf</filename>:
  3861. <literallayout class='monospaced'>
  3862. $ bitbake multiconfig:configA:core-image-minimal core-image-sato
  3863. </literallayout>
  3864. </para></listitem>
  3865. </itemizedlist>
  3866. </para>
  3867. <para>
  3868. Support for multiple configurations in this current release of
  3869. the Yocto Project (&DISTRO_NAME; &DISTRO;) has some known issues:
  3870. <itemizedlist>
  3871. <listitem><para>
  3872. No inter-multi-configuration dependencies exist.
  3873. </para></listitem>
  3874. <listitem><para>
  3875. Shared State (sstate) optimizations do not exist.
  3876. Consequently, if the build uses the same object twice
  3877. in, for example, two different
  3878. <filename>TMPDIR</filename> directories, the build
  3879. will either load from an existing sstate cache at the
  3880. start or build the object twice.
  3881. </para></listitem>
  3882. </itemizedlist>
  3883. </para>
  3884. </section>
  3885. <section id="platdev-working-with-libraries">
  3886. <title>Working With Libraries</title>
  3887. <para>
  3888. Libraries are an integral part of your system.
  3889. This section describes some common practices you might find
  3890. helpful when working with libraries to build your system:
  3891. <itemizedlist>
  3892. <listitem><para><link linkend='including-static-library-files'>How to include static library files</link>
  3893. </para></listitem>
  3894. <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>
  3895. </para></listitem>
  3896. <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>
  3897. </para></listitem>
  3898. </itemizedlist>
  3899. </para>
  3900. <section id='including-static-library-files'>
  3901. <title>Including Static Library Files</title>
  3902. <para>
  3903. If you are building a library and the library offers static linking, you can control
  3904. which static library files (<filename>*.a</filename> files) get included in the
  3905. built library.
  3906. </para>
  3907. <para>
  3908. The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  3909. and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink>
  3910. variables in the
  3911. <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed
  3912. by the <filename>do_install</filename> task are packaged.
  3913. By default, the <filename>PACKAGES</filename> variable includes
  3914. <filename>${PN}-staticdev</filename>, which represents all static library files.
  3915. <note>
  3916. Some previously released versions of the Yocto Project
  3917. defined the static library files through
  3918. <filename>${PN}-dev</filename>.
  3919. </note>
  3920. Following is part of the BitBake configuration file, where
  3921. you can see how the static library files are defined:
  3922. <literallayout class='monospaced'>
  3923. PACKAGE_BEFORE_PN ?= ""
  3924. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  3925. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  3926. FILES = ""
  3927. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  3928. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  3929. ${base_bindir}/* ${base_sbindir}/* \
  3930. ${base_libdir}/*${SOLIBS} \
  3931. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  3932. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  3933. ${datadir}/pixmaps ${datadir}/applications \
  3934. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  3935. ${libdir}/bonobo/servers"
  3936. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  3937. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  3938. ${datadir}/gnome/help"
  3939. SECTION_${PN}-doc = "doc"
  3940. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  3941. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  3942. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  3943. ${datadir}/aclocal ${base_libdir}/*.o \
  3944. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  3945. SECTION_${PN}-dev = "devel"
  3946. ALLOW_EMPTY_${PN}-dev = "1"
  3947. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  3948. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  3949. SECTION_${PN}-staticdev = "devel"
  3950. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  3951. </literallayout>
  3952. </para>
  3953. </section>
  3954. <section id="combining-multiple-versions-library-files-into-one-image">
  3955. <title>Combining Multiple Versions of Library Files into One Image</title>
  3956. <para>
  3957. The build system offers the ability to build libraries with different
  3958. target optimizations or architecture formats and combine these together
  3959. into one system image.
  3960. You can link different binaries in the image
  3961. against the different libraries as needed for specific use cases.
  3962. This feature is called "Multilib."
  3963. </para>
  3964. <para>
  3965. An example would be where you have most of a system compiled in 32-bit
  3966. mode using 32-bit libraries, but you have something large, like a database
  3967. engine, that needs to be a 64-bit application and uses 64-bit libraries.
  3968. Multilib allows you to get the best of both 32-bit and 64-bit libraries.
  3969. </para>
  3970. <para>
  3971. While the Multilib feature is most commonly used for 32 and 64-bit differences,
  3972. the approach the build system uses facilitates different target optimizations.
  3973. You could compile some binaries to use one set of libraries and other binaries
  3974. to use a different set of libraries.
  3975. The libraries could differ in architecture, compiler options, or other
  3976. optimizations.
  3977. </para>
  3978. <para>
  3979. Several examples exist in the
  3980. <filename>meta-skeleton</filename> layer found in the
  3981. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  3982. <itemizedlist>
  3983. <listitem><para><filename>conf/multilib-example.conf</filename>
  3984. configuration file</para></listitem>
  3985. <listitem><para><filename>conf/multilib-example2.conf</filename>
  3986. configuration file</para></listitem>
  3987. <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename>
  3988. recipe</para></listitem>
  3989. </itemizedlist>
  3990. </para>
  3991. <section id='preparing-to-use-multilib'>
  3992. <title>Preparing to Use Multilib</title>
  3993. <para>
  3994. User-specific requirements drive the Multilib feature.
  3995. Consequently, there is no one "out-of-the-box" configuration that likely
  3996. exists to meet your needs.
  3997. </para>
  3998. <para>
  3999. In order to enable Multilib, you first need to ensure your recipe is
  4000. extended to support multiple libraries.
  4001. Many standard recipes are already extended and support multiple libraries.
  4002. You can check in the <filename>meta/conf/multilib.conf</filename>
  4003. configuration file in the
  4004. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> to see how this is
  4005. done using the
  4006. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink>
  4007. variable.
  4008. Eventually, all recipes will be covered and this list will
  4009. not be needed.
  4010. </para>
  4011. <para>
  4012. For the most part, the Multilib class extension works automatically to
  4013. extend the package name from <filename>${PN}</filename> to
  4014. <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename>
  4015. is the particular multilib (e.g. "lib32-" or "lib64-").
  4016. Standard variables such as
  4017. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  4018. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  4019. <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>,
  4020. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  4021. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and
  4022. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink>
  4023. are automatically extended by the system.
  4024. If you are extending any manual code in the recipe, you can use the
  4025. <filename>${MLPREFIX}</filename> variable to ensure those names are extended
  4026. correctly.
  4027. This automatic extension code resides in <filename>multilib.bbclass</filename>.
  4028. </para>
  4029. </section>
  4030. <section id='using-multilib'>
  4031. <title>Using Multilib</title>
  4032. <para>
  4033. After you have set up the recipes, you need to define the actual
  4034. combination of multiple libraries you want to build.
  4035. You accomplish this through your <filename>local.conf</filename>
  4036. configuration file in the
  4037. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4038. An example configuration would be as follows:
  4039. <literallayout class='monospaced'>
  4040. MACHINE = "qemux86-64"
  4041. require conf/multilib.conf
  4042. MULTILIBS = "multilib:lib32"
  4043. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  4044. IMAGE_INSTALL_append = " lib32-glib-2.0"
  4045. </literallayout>
  4046. This example enables an
  4047. additional library named <filename>lib32</filename> alongside the
  4048. normal target packages.
  4049. When combining these "lib32" alternatives, the example uses "x86" for tuning.
  4050. For information on this particular tuning, see
  4051. <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>.
  4052. </para>
  4053. <para>
  4054. The example then includes <filename>lib32-glib-2.0</filename>
  4055. in all the images, which illustrates one method of including a
  4056. multiple library dependency.
  4057. You can use a normal image build to include this dependency,
  4058. for example:
  4059. <literallayout class='monospaced'>
  4060. $ bitbake core-image-sato
  4061. </literallayout>
  4062. You can also build Multilib packages specifically with a command like this:
  4063. <literallayout class='monospaced'>
  4064. $ bitbake lib32-glib-2.0
  4065. </literallayout>
  4066. </para>
  4067. </section>
  4068. <section id='additional-implementation-details'>
  4069. <title>Additional Implementation Details</title>
  4070. <para>
  4071. Generic implementation details as well as details that are
  4072. specific to package management systems exist.
  4073. Following are implementation details that exist regardless
  4074. of the package management system:
  4075. <itemizedlist>
  4076. <listitem><para>The typical convention used for the
  4077. class extension code as used by
  4078. Multilib assumes that all package names specified
  4079. in
  4080. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  4081. that contain <filename>${PN}</filename> have
  4082. <filename>${PN}</filename> at the start of the name.
  4083. When that convention is not followed and
  4084. <filename>${PN}</filename> appears at
  4085. the middle or the end of a name, problems occur.
  4086. </para></listitem>
  4087. <listitem><para>The
  4088. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink>
  4089. value under Multilib will be extended to
  4090. "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>"
  4091. (e.g. "-pokymllib32" for a "lib32" Multilib with
  4092. Poky).
  4093. The reason for this slightly unwieldy contraction
  4094. is that any "-" characters in the vendor
  4095. string presently break Autoconf's
  4096. <filename>config.sub</filename>, and
  4097. other separators are problematic for different
  4098. reasons.
  4099. </para></listitem>
  4100. </itemizedlist>
  4101. </para>
  4102. <para>
  4103. For the RPM Package Management System, the following implementation details
  4104. exist:
  4105. <itemizedlist>
  4106. <listitem><para>A unique architecture is defined for the Multilib packages,
  4107. along with creating a unique deploy folder under
  4108. <filename>tmp/deploy/rpm</filename> in the
  4109. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4110. For example, consider <filename>lib32</filename> in a
  4111. <filename>qemux86-64</filename> image.
  4112. The possible architectures in the system are "all", "qemux86_64",
  4113. "lib32_qemux86_64", and "lib32_x86".</para></listitem>
  4114. <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from
  4115. <filename>${PN}</filename> during RPM packaging.
  4116. The naming for a normal RPM package and a Multilib RPM package in a
  4117. <filename>qemux86-64</filename> system resolves to something similar to
  4118. <filename>bash-4.1-r2.x86_64.rpm</filename> and
  4119. <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively.
  4120. </para></listitem>
  4121. <listitem><para>When installing a Multilib image, the RPM backend first
  4122. installs the base image and then installs the Multilib libraries.
  4123. </para></listitem>
  4124. <listitem><para>The build system relies on RPM to resolve the identical files in the
  4125. two (or more) Multilib packages.</para></listitem>
  4126. </itemizedlist>
  4127. </para>
  4128. <para>
  4129. For the IPK Package Management System, the following implementation details exist:
  4130. <itemizedlist>
  4131. <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from
  4132. <filename>${PN}</filename> during IPK packaging.
  4133. The naming for a normal RPM package and a Multilib IPK package in a
  4134. <filename>qemux86-64</filename> system resolves to something like
  4135. <filename>bash_4.1-r2.x86_64.ipk</filename> and
  4136. <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively.
  4137. </para></listitem>
  4138. <listitem><para>The IPK deploy folder is not modified with
  4139. <filename>${MLPREFIX}</filename> because packages with and without
  4140. the Multilib feature can exist in the same folder due to the
  4141. <filename>${PN}</filename> differences.</para></listitem>
  4142. <listitem><para>IPK defines a sanity check for Multilib installation
  4143. using certain rules for file comparison, overridden, etc.
  4144. </para></listitem>
  4145. </itemizedlist>
  4146. </para>
  4147. </section>
  4148. </section>
  4149. <section id='installing-multiple-versions-of-the-same-library'>
  4150. <title>Installing Multiple Versions of the Same Library</title>
  4151. <para>
  4152. Situations can exist where you need to install and use
  4153. multiple versions of the same library on the same system
  4154. at the same time.
  4155. These situations almost always exist when a library API
  4156. changes and you have multiple pieces of software that
  4157. depend on the separate versions of the library.
  4158. To accommodate these situations, you can install multiple
  4159. versions of the same library in parallel on the same system.
  4160. </para>
  4161. <para>
  4162. The process is straightforward as long as the libraries use
  4163. proper versioning.
  4164. With properly versioned libraries, all you need to do to
  4165. individually specify the libraries is create separate,
  4166. appropriately named recipes where the
  4167. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the
  4168. name includes a portion that differentiates each library version
  4169. (e.g.the major part of the version number).
  4170. Thus, instead of having a single recipe that loads one version
  4171. of a library (e.g. <filename>clutter</filename>), you provide
  4172. multiple recipes that result in different versions
  4173. of the libraries you want.
  4174. As an example, the following two recipes would allow the
  4175. two separate versions of the <filename>clutter</filename>
  4176. library to co-exist on the same system:
  4177. <literallayout class='monospaced'>
  4178. clutter-1.6_1.6.20.bb
  4179. clutter-1.8_1.8.4.bb
  4180. </literallayout>
  4181. Additionally, if you have other recipes that depend on a given
  4182. library, you need to use the
  4183. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  4184. variable to create the dependency.
  4185. Continuing with the same example, if you want to have a recipe
  4186. depend on the 1.8 version of the <filename>clutter</filename>
  4187. library, use the following in your recipe:
  4188. <literallayout class='monospaced'>
  4189. DEPENDS = "clutter-1.8"
  4190. </literallayout>
  4191. </para>
  4192. </section>
  4193. </section>
  4194. <section id='using-x32-psabi'>
  4195. <title>Using x32 psABI</title>
  4196. <para>
  4197. x32 processor-specific Application Binary Interface
  4198. (<ulink url='https://software.intel.com/en-us/node/628948'>x32 psABI</ulink>)
  4199. is a native 32-bit processor-specific ABI for
  4200. <trademark class='registered'>Intel</trademark> 64 (x86-64)
  4201. architectures.
  4202. <note>
  4203. For more information on x32 psABI, see the
  4204. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#x32'>x32 psABI</ulink>"
  4205. section in the Yocto Project Overview Manual.
  4206. </note>
  4207. To use the x32 psABI, you need to edit your
  4208. <filename>conf/local.conf</filename> configuration file as
  4209. follows:
  4210. <literallayout class='monospaced'>
  4211. MACHINE = "qemux86-64"
  4212. DEFAULTTUNE = "x86-64-x32"
  4213. baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE', True) \
  4214. or 'INVALID'), True) or 'lib'}"
  4215. </literallayout>
  4216. Once you have set up your configuration file, use BitBake to
  4217. build an image that supports the x32 psABI.
  4218. Here is an example:
  4219. <literallayout class='monospaced'>
  4220. $ bitbake core-image-sato
  4221. </literallayout>
  4222. </para>
  4223. </section>
  4224. <section id='enabling-gobject-introspection-support'>
  4225. <title>Enabling GObject Introspection Support</title>
  4226. <para>
  4227. <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink>
  4228. is the standard mechanism for accessing GObject-based software
  4229. from runtime environments.
  4230. GObject is a feature of the GLib library that provides an object
  4231. framework for the GNOME desktop and related software.
  4232. GObject Introspection adds information to GObject that allows
  4233. objects created within it to be represented across different
  4234. programming languages.
  4235. If you want to construct GStreamer pipelines using Python, or
  4236. control UPnP infrastructure using Javascript and GUPnP,
  4237. GObject introspection is the only way to do it.
  4238. </para>
  4239. <para>
  4240. This section describes the Yocto Project support for generating
  4241. and packaging GObject introspection data.
  4242. GObject introspection data is a description of the
  4243. API provided by libraries built on top of GLib framework,
  4244. and, in particular, that framework's GObject mechanism.
  4245. GObject Introspection Repository (GIR) files go to
  4246. <filename>-dev</filename> packages,
  4247. <filename>typelib</filename> files go to main packages as they
  4248. are packaged together with libraries that are introspected.
  4249. </para>
  4250. <para>
  4251. The data is generated when building such a library, by linking
  4252. the library with a small executable binary that asks the library
  4253. to describe itself, and then executing the binary and
  4254. processing its output.
  4255. </para>
  4256. <para>
  4257. Generating this data in a cross-compilation environment
  4258. is difficult because the library is produced for the target
  4259. architecture, but its code needs to be executed on the build host.
  4260. This problem is solved with the OpenEmbedded build system by
  4261. running the code through QEMU, which allows precisely that.
  4262. Unfortunately, QEMU does not always work perfectly as mentioned
  4263. in the xxx section.
  4264. </para>
  4265. <section id='enabling-the-generation-of-introspection-data'>
  4266. <title>Enabling the Generation of Introspection Data</title>
  4267. <para>
  4268. Enabling the generation of introspection data (GIR files)
  4269. in your library package involves the following:
  4270. <orderedlist>
  4271. <listitem><para>
  4272. Inherit the
  4273. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink>
  4274. class.
  4275. </para></listitem>
  4276. <listitem><para>
  4277. Make sure introspection is not disabled anywhere in
  4278. the recipe or from anything the recipe includes.
  4279. Also, make sure that "gobject-introspection-data" is
  4280. not in
  4281. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  4282. and that "qemu-usermode" is not in
  4283. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  4284. If either of these conditions exist, nothing will
  4285. happen.
  4286. </para></listitem>
  4287. <listitem><para>
  4288. Try to build the recipe.
  4289. If you encounter build errors that look like
  4290. something is unable to find
  4291. <filename>.so</filename> libraries, check where these
  4292. libraries are located in the source tree and add
  4293. the following to the recipe:
  4294. <literallayout class='monospaced'>
  4295. GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs"
  4296. </literallayout>
  4297. <note>
  4298. See recipes in the <filename>oe-core</filename>
  4299. repository that use that
  4300. <filename>GIR_EXTRA_LIBS_PATH</filename> variable
  4301. as an example.
  4302. </note>
  4303. </para></listitem>
  4304. <listitem><para>
  4305. Look for any other errors, which probably mean that
  4306. introspection support in a package is not entirely
  4307. standard, and thus breaks down in a cross-compilation
  4308. environment.
  4309. For such cases, custom-made fixes are needed.
  4310. A good place to ask and receive help in these cases
  4311. is the
  4312. <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>.
  4313. </para></listitem>
  4314. </orderedlist>
  4315. <note>
  4316. Using a library that no longer builds against the latest
  4317. Yocto Project release and prints introspection related
  4318. errors is a good candidate for the previous procedure.
  4319. </note>
  4320. </para>
  4321. </section>
  4322. <section id='disabling-the-generation-of-introspection-data'>
  4323. <title>Disabling the Generation of Introspection Data</title>
  4324. <para>
  4325. You might find that you do not want to generate
  4326. introspection data.
  4327. Or, perhaps QEMU does not work on your build host and
  4328. target architecture combination.
  4329. If so, you can use either of the following methods to
  4330. disable GIR file generations:
  4331. <itemizedlist>
  4332. <listitem><para>
  4333. Add the following to your distro configuration:
  4334. <literallayout class='monospaced'>
  4335. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  4336. </literallayout>
  4337. Adding this statement disables generating
  4338. introspection data using QEMU but will still enable
  4339. building introspection tools and libraries
  4340. (i.e. building them does not require the use of QEMU).
  4341. </para></listitem>
  4342. <listitem><para>
  4343. Add the following to your machine configuration:
  4344. <literallayout class='monospaced'>
  4345. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  4346. </literallayout>
  4347. Adding this statement disables the use of QEMU
  4348. when building packages for your machine.
  4349. Currently, this feature is used only by introspection
  4350. recipes and has the same effect as the previously
  4351. described option.
  4352. <note>
  4353. Future releases of the Yocto Project might have
  4354. other features affected by this option.
  4355. </note>
  4356. </para></listitem>
  4357. </itemizedlist>
  4358. If you disable introspection data, you can still
  4359. obtain it through other means such as copying the data
  4360. from a suitable sysroot, or by generating it on the
  4361. target hardware.
  4362. The OpenEmbedded build system does not currently
  4363. provide specific support for these techniques.
  4364. </para>
  4365. </section>
  4366. <section id='testing-that-introspection-works-in-an-image'>
  4367. <title>Testing that Introspection Works in an Image</title>
  4368. <para>
  4369. Use the following procedure to test if generating
  4370. introspection data is working in an image:
  4371. <orderedlist>
  4372. <listitem><para>
  4373. Make sure that "gobject-introspection-data" is not in
  4374. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  4375. and that "qemu-usermode" is not in
  4376. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  4377. </para></listitem>
  4378. <listitem><para>
  4379. Build <filename>core-image-sato</filename>.
  4380. </para></listitem>
  4381. <listitem><para>
  4382. Launch a Terminal and then start Python in the
  4383. terminal.
  4384. </para></listitem>
  4385. <listitem><para>
  4386. Enter the following in the terminal:
  4387. <literallayout class='monospaced'>
  4388. >>> from gi.repository import GLib
  4389. >>> GLib.get_host_name()
  4390. </literallayout>
  4391. </para></listitem>
  4392. <listitem><para>
  4393. For something a little more advanced, enter the
  4394. following:
  4395. <literallayout class='monospaced'>
  4396. http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
  4397. </literallayout>
  4398. </para></listitem>
  4399. </orderedlist>
  4400. </para>
  4401. </section>
  4402. <section id='known-issues'>
  4403. <title>Known Issues</title>
  4404. <para>
  4405. The following know issues exist for
  4406. GObject Introspection Support:
  4407. <itemizedlist>
  4408. <listitem><para>
  4409. <filename>qemu-ppc64</filename> immediately crashes.
  4410. Consequently, you cannot build introspection data on
  4411. that architecture.
  4412. </para></listitem>
  4413. <listitem><para>
  4414. x32 is not supported by QEMU.
  4415. Consequently, introspection data is disabled.
  4416. </para></listitem>
  4417. <listitem><para>
  4418. musl causes transient GLib binaries to crash on
  4419. assertion failures.
  4420. Consequently, generating introspection data is
  4421. disabled.
  4422. </para></listitem>
  4423. <listitem><para>
  4424. Because QEMU is not able to run the binaries correctly,
  4425. introspection is disabled for some specific packages
  4426. under specific architectures (e.g.
  4427. <filename>gcr</filename>,
  4428. <filename>libsecret</filename>, and
  4429. <filename>webkit</filename>).
  4430. </para></listitem>
  4431. <listitem><para>
  4432. QEMU usermode might not work properly when running
  4433. 64-bit binaries under 32-bit host machines.
  4434. In particular, "qemumips64" is known to not work under
  4435. i686.
  4436. </para></listitem>
  4437. </itemizedlist>
  4438. </para>
  4439. </section>
  4440. </section>
  4441. <section id='dev-optionally-using-an-external-toolchain'>
  4442. <title>Optionally Using an External Toolchain</title>
  4443. <para>
  4444. You might want to use an external toolchain as part of your
  4445. development.
  4446. If this is the case, the fundamental steps you need to accomplish
  4447. are as follows:
  4448. <itemizedlist>
  4449. <listitem><para>
  4450. Understand where the installed toolchain resides.
  4451. For cases where you need to build the external toolchain,
  4452. you would need to take separate steps to build and install
  4453. the toolchain.
  4454. </para></listitem>
  4455. <listitem><para>
  4456. Make sure you add the layer that contains the toolchain to
  4457. your <filename>bblayers.conf</filename> file through the
  4458. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  4459. variable.
  4460. </para></listitem>
  4461. <listitem><para>
  4462. Set the
  4463. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink>
  4464. variable in your <filename>local.conf</filename> file
  4465. to the location in which you installed the toolchain.
  4466. </para></listitem>
  4467. </itemizedlist>
  4468. A good example of an external toolchain used with the Yocto Project
  4469. is <trademark class='registered'>Mentor Graphics</trademark>
  4470. Sourcery G++ Toolchain.
  4471. You can see information on how to use that particular layer in the
  4472. <filename>README</filename> file at
  4473. <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
  4474. You can find further information by reading about the
  4475. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
  4476. variable in the Yocto Project Reference Manual's variable glossary.
  4477. </para>
  4478. </section>
  4479. <section id='creating-partitioned-images-using-wic'>
  4480. <title>Creating Partitioned Images Using Wic</title>
  4481. <para>
  4482. Creating an image for a particular hardware target using the
  4483. OpenEmbedded build system does not necessarily mean you can boot
  4484. that image as is on your device.
  4485. Physical devices accept and boot images in various ways depending
  4486. on the specifics of the device.
  4487. Usually, information about the hardware can tell you what image
  4488. format the device requires.
  4489. Should your device require multiple partitions on an SD card, flash,
  4490. or an HDD, you can use the OpenEmbedded Image Creator,
  4491. Wic, to create the properly partitioned image.
  4492. </para>
  4493. <para>
  4494. The <filename>wic</filename> command generates partitioned
  4495. images from existing OpenEmbedded build artifacts.
  4496. Image generation is driven by partitioning commands
  4497. contained in an Openembedded kickstart file
  4498. (<filename>.wks</filename>) specified either directly on
  4499. the command line or as one of a selection of canned
  4500. kickstart files as shown with the
  4501. <filename>wic list images</filename> command in the
  4502. "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>"
  4503. section.
  4504. When you apply the command to a given set of build
  4505. artifacts, the result is an image or set of images that
  4506. can be directly written onto media and used on a particular
  4507. system.
  4508. <note>
  4509. For a kickstart file reference, see the
  4510. "<ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>OpenEmbedded Kickstart (<filename>.wks</filename>) Reference</ulink>"
  4511. Chapter in the Yocto Project Reference Manual.
  4512. </note>
  4513. </para>
  4514. <para>
  4515. The <filename>wic</filename> command and the infrastructure
  4516. it is based on is by definition incomplete.
  4517. The purpose of the command is to allow the generation of
  4518. customized images, and as such, was designed to be
  4519. completely extensible through a plug-in interface.
  4520. See the
  4521. "<link linkend='wic-using-the-wic-plug-ins-interface'>Using the Wic Plug-Ins Interface</link>"
  4522. section for information on these plug-ins.
  4523. </para>
  4524. <para>
  4525. This section provides some background information on Wic,
  4526. describes what you need to have in
  4527. place to run the tool, provides instruction on how to use
  4528. the Wic utility, provides information on using the Wic plug-ins
  4529. interface, and provides several examples that show how to use
  4530. Wic.
  4531. </para>
  4532. <section id='wic-background'>
  4533. <title>Background</title>
  4534. <para>
  4535. This section provides some background on the Wic utility.
  4536. While none of this information is required to use
  4537. Wic, you might find it interesting.
  4538. <itemizedlist>
  4539. <listitem><para>
  4540. The name "Wic" is derived from OpenEmbedded
  4541. Image Creator (oeic).
  4542. The "oe" diphthong in "oeic" was promoted to the
  4543. letter "w", because "oeic" is both difficult to
  4544. remember and to pronounce.
  4545. </para></listitem>
  4546. <listitem><para>
  4547. Wic is loosely based on the
  4548. Meego Image Creator (<filename>mic</filename>)
  4549. framework.
  4550. The Wic implementation has been
  4551. heavily modified to make direct use of OpenEmbedded
  4552. build artifacts instead of package installation and
  4553. configuration, which are already incorporated within
  4554. the OpenEmbedded artifacts.
  4555. </para></listitem>
  4556. <listitem><para>
  4557. Wic is a completely independent
  4558. standalone utility that initially provides
  4559. easier-to-use and more flexible replacements for an
  4560. existing functionality in OE Core's
  4561. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink>
  4562. class and <filename>mkefidisk.sh</filename> script.
  4563. The difference between
  4564. Wic and those examples is
  4565. that with Wic the
  4566. functionality of those scripts is implemented
  4567. by a general-purpose partitioning language, which is
  4568. based on Redhat kickstart syntax.</para></listitem>
  4569. </itemizedlist>
  4570. </para>
  4571. </section>
  4572. <section id='wic-requirements'>
  4573. <title>Requirements</title>
  4574. <para>
  4575. In order to use the Wic utility with the OpenEmbedded Build
  4576. system, your system needs to meet the following
  4577. requirements:
  4578. <itemizedlist>
  4579. <listitem><para>
  4580. The Linux distribution on your development host must
  4581. support the Yocto Project.
  4582. See the
  4583. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  4584. section in the Yocto Project Reference Manual for
  4585. the list of distributions that support the
  4586. Yocto Project.
  4587. </para></listitem>
  4588. <listitem><para>
  4589. The standard system utilities, such as
  4590. <filename>cp</filename>, must be installed on your
  4591. development host system.
  4592. </para></listitem>
  4593. <listitem><para>
  4594. You must have sourced the build environment
  4595. setup script (i.e.
  4596. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  4597. found in the
  4598. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4599. </para></listitem>
  4600. <listitem><para>
  4601. You need to have the build artifacts already
  4602. available, which typically means that you must
  4603. have already created an image using the
  4604. Openembedded build system (e.g.
  4605. <filename>core-image-minimal</filename>).
  4606. While it might seem redundant to generate an image
  4607. in order to create an image using
  4608. Wic, the current version of
  4609. Wic requires the artifacts
  4610. in the form generated by the OpenEmbedded build
  4611. system.
  4612. </para></listitem>
  4613. <listitem><para>
  4614. You must build several native tools, which are
  4615. built to run on the build system:
  4616. <literallayout class='monospaced'>
  4617. $ bitbake parted-native dosfstools-native mtools-native
  4618. </literallayout>
  4619. </para></listitem>
  4620. <listitem><para>
  4621. Include "wic" as part of the
  4622. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  4623. variable.
  4624. </para></listitem>
  4625. <listitem><para>
  4626. Include the name of the
  4627. <ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>wic kickstart file</ulink>
  4628. as part of the
  4629. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink>
  4630. variable
  4631. </para></listitem>
  4632. </itemizedlist>
  4633. </para>
  4634. </section>
  4635. <section id='wic-getting-help'>
  4636. <title>Getting Help</title>
  4637. <para>
  4638. You can get general help for the <filename>wic</filename>
  4639. command by entering the <filename>wic</filename> command
  4640. by itself or by entering the command with a help argument
  4641. as follows:
  4642. <literallayout class='monospaced'>
  4643. $ wic -h
  4644. $ wic --help
  4645. </literallayout>
  4646. </para>
  4647. <para>
  4648. Currently, Wic supports seven commands:
  4649. <filename>cp</filename>, <filename>create</filename>,
  4650. <filename>help</filename>, <filename>list</filename>,
  4651. <filename>ls</filename>, <filename>rm</filename>, and
  4652. <filename>write</filename>.
  4653. You can get help for these commands as follows with
  4654. <replaceable>command</replaceable> being one of the
  4655. supported commands:
  4656. <literallayout class='monospaced'>
  4657. $ wic help <replaceable>command</replaceable>
  4658. </literallayout>
  4659. </para>
  4660. <para>
  4661. You can also get detailed help on a number of topics
  4662. from the help system.
  4663. The output of <filename>wic --help</filename>
  4664. displays a list of available help
  4665. topics under a "Help topics" heading.
  4666. You can have the help system display the help text for
  4667. a given topic by prefacing the topic with
  4668. <filename>wic help</filename>:
  4669. <literallayout class='monospaced'>
  4670. $ wic help <replaceable>help_topic</replaceable>
  4671. </literallayout>
  4672. </para>
  4673. <para>
  4674. You can find out more about the images Wic creates using
  4675. the existing kickstart files with the following form of
  4676. the command:
  4677. <literallayout class='monospaced'>
  4678. $ wic list <replaceable>image</replaceable> help
  4679. </literallayout>
  4680. For <replaceable>image</replaceable>, you can provide
  4681. any of the following:
  4682. <literallayout class='monospaced'>
  4683. beaglebone
  4684. mpc8315e-rdb
  4685. genericx86
  4686. edgerouter
  4687. qemux86-directdisk
  4688. directdisk-gpt
  4689. mkefidisk
  4690. directdisk
  4691. systemd-bootdisk
  4692. mkhybridiso
  4693. sdimage-bootpart
  4694. directdisk-multi-rootfs
  4695. directdisk-bootloader-config
  4696. </literallayout>
  4697. </para>
  4698. </section>
  4699. <section id='operational-modes'>
  4700. <title>Operational Modes</title>
  4701. <para>
  4702. You can use Wic in two different
  4703. modes, depending on how much control you need for
  4704. specifying the Openembedded build artifacts that are
  4705. used for creating the image: Raw and Cooked:
  4706. <itemizedlist>
  4707. <listitem><para>
  4708. <emphasis>Raw Mode:</emphasis>
  4709. You explicitly specify build artifacts through
  4710. <filename>wic</filename> command-line arguments.
  4711. </para></listitem>
  4712. <listitem><para>
  4713. <emphasis>Cooked Mode:</emphasis>
  4714. The current
  4715. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4716. setting and image name are used to automatically
  4717. locate and provide the build artifacts.
  4718. You just supply a kickstart file and the name
  4719. of the image from which to use artifacts.
  4720. </para></listitem>
  4721. </itemizedlist>
  4722. </para>
  4723. <para>
  4724. Regardless of the mode you use, you need to have the build
  4725. artifacts ready and available.
  4726. </para>
  4727. <section id='raw-mode'>
  4728. <title>Raw Mode</title>
  4729. <para>
  4730. Running Wic in raw mode allows you to specify all the
  4731. partitions through the <filename>wic</filename>
  4732. command line.
  4733. The primary use for raw mode is if you have built
  4734. your kernel outside of the Yocto Project
  4735. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4736. In other words, you can point to arbitrary kernel,
  4737. root filesystem locations, and so forth.
  4738. Contrast this behavior with cooked mode where Wic
  4739. looks in the Build Directory (e.g.
  4740. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>).
  4741. </para>
  4742. <para>
  4743. The general form of the
  4744. <filename>wic</filename> command in raw mode is:
  4745. <literallayout class='monospaced'>
  4746. $ wic create <replaceable>wks_file</replaceable> <replaceable>options</replaceable> ...
  4747. Where:
  4748. <replaceable>wks_file</replaceable>:
  4749. An OpenEmbedded kickstart file. You can provide
  4750. your own custom file or use a file from a set of
  4751. existing files as described by further options.
  4752. optional arguments:
  4753. -h, --help show this help message and exit
  4754. -o <replaceable>OUTDIR</replaceable>, --outdir <replaceable>OUTDIR</replaceable>
  4755. name of directory to create image in
  4756. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  4757. name of the image to use the artifacts from e.g. core-
  4758. image-sato
  4759. -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir <replaceable>ROOTFS_DIR</replaceable>
  4760. path to the /rootfs dir to use as the .wks rootfs
  4761. source
  4762. -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir <replaceable>BOOTIMG_DIR</replaceable>
  4763. path to the dir containing the boot artifacts (e.g.
  4764. /EFI or /syslinux dirs) to use as the .wks bootimg
  4765. source
  4766. -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir <replaceable>KERNEL_DIR</replaceable>
  4767. path to the dir containing the kernel to use in the
  4768. .wks bootimg
  4769. -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot <replaceable>NATIVE_SYSROOT</replaceable>
  4770. path to the native sysroot containing the tools to use
  4771. to build the image
  4772. -s, --skip-build-check
  4773. skip the build check
  4774. -f, --build-rootfs build rootfs
  4775. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  4776. compress image with specified compressor
  4777. -m, --bmap generate .bmap
  4778. --no-fstab-update Do not change fstab file.
  4779. -v <replaceable>VARS_DIR</replaceable>, --vars <replaceable>VARS_DIR</replaceable>
  4780. directory with &lt;image&gt;.env files that store bitbake
  4781. variables
  4782. -D, --debug output debug information
  4783. </literallayout>
  4784. <note>
  4785. You do not need root privileges to run
  4786. Wic.
  4787. In fact, you should not run as root when using the
  4788. utility.
  4789. </note>
  4790. </para>
  4791. </section>
  4792. <section id='cooked-mode'>
  4793. <title>Cooked Mode</title>
  4794. <para>
  4795. Running Wic in cooked mode leverages off artifacts in
  4796. Build Directory.
  4797. In other words, you do not have to specify kernel or
  4798. root filesystem locations as part of the command.
  4799. All you need to provide is a kickstart file and the
  4800. name of the image from which to use artifacts by using
  4801. the "-e" option.
  4802. Wic looks in the Build Directory (e.g.
  4803. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>)
  4804. for artifacts.
  4805. </para>
  4806. <para>
  4807. The general form of the <filename>wic</filename>
  4808. command using Cooked Mode is as follows:
  4809. <literallayout class='monospaced'>
  4810. $ wic create <replaceable>wks_file</replaceable> -e <replaceable>IMAGE_NAME</replaceable>
  4811. Where:
  4812. <replaceable>wks_file</replaceable>:
  4813. An OpenEmbedded kickstart file. You can provide
  4814. your own custom file or use a file from a set of
  4815. existing files provided with the Yocto Project
  4816. release.
  4817. required argument:
  4818. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  4819. name of the image to use the artifacts from e.g. core-
  4820. image-sato
  4821. </literallayout>
  4822. </para>
  4823. </section>
  4824. </section>
  4825. <section id='using-a-provided-kickstart-file'>
  4826. <title>Using an Existing Kickstart File</title>
  4827. <para>
  4828. If you do not want to create your own kickstart file, you
  4829. can use an existing file provided by the Wic installation.
  4830. As shipped, kickstart files can be found in the
  4831. Yocto Project
  4832. <ulink url='&YOCTO_DOCS_OVERVIEW_URL;#source-repositories'>Source Repositories</ulink>
  4833. in the following two locations:
  4834. <literallayout class='monospaced'>
  4835. poky/meta-yocto-bsp/wic
  4836. poky/scripts/lib/wic/canned-wks
  4837. </literallayout>
  4838. Use the following command to list the available kickstart
  4839. files:
  4840. <literallayout class='monospaced'>
  4841. $ wic list images
  4842. beaglebone Create SD card image for Beaglebone
  4843. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  4844. genericx86 Create an EFI disk image for genericx86*
  4845. edgerouter Create SD card image for Edgerouter
  4846. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  4847. directdisk-gpt Create a 'pcbios' direct disk image
  4848. mkefidisk Create an EFI disk image
  4849. directdisk Create a 'pcbios' direct disk image
  4850. systemd-bootdisk Create an EFI disk image with systemd-boot
  4851. mkhybridiso Create a hybrid ISO image
  4852. sdimage-bootpart Create SD card image with a boot partition
  4853. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  4854. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  4855. </literallayout>
  4856. When you use an existing file, you do not have to use the
  4857. <filename>.wks</filename> extension.
  4858. Here is an example in Raw Mode that uses the
  4859. <filename>directdisk</filename> file:
  4860. <literallayout class='monospaced'>
  4861. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  4862. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  4863. </literallayout>
  4864. </para>
  4865. <para>
  4866. Here are the actual partition language commands
  4867. used in the <filename>genericx86.wks</filename> file to
  4868. generate an image:
  4869. <literallayout class='monospaced'>
  4870. # short-description: Create an EFI disk image for genericx86*
  4871. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  4872. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  4873. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  4874. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  4875. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  4876. </literallayout>
  4877. </para>
  4878. </section>
  4879. <section id='wic-using-the-wic-plug-ins-interface'>
  4880. <title>Using the Wic Plug-Ins Interface</title>
  4881. <para>
  4882. You can extend and specialize Wic functionality by using
  4883. Wic plug-ins.
  4884. This section explains the Wic plug-in interface.
  4885. <note>
  4886. Wic plug-ins consist of "source" and "imager" plug-ins.
  4887. Imager plug-ins are beyond the scope of this section.
  4888. </note>
  4889. </para>
  4890. <para>
  4891. Source plug-ins provide a mechanism to customize partition
  4892. content during the Wic image generation process.
  4893. You can use source plug-ins to map values that you specify
  4894. using <filename>--source</filename> commands in kickstart
  4895. files (i.e. <filename>*.wks</filename>) to a plug-in
  4896. implementation used to populate a given partition.
  4897. <note>
  4898. If you use plug-ins that have build-time dependencies
  4899. (e.g. native tools, bootloaders, and so forth)
  4900. when building a Wic image, you need to specify those
  4901. dependencies using the
  4902. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink>
  4903. variable.
  4904. </note>
  4905. </para>
  4906. <para>
  4907. Source plug-ins are subclasses defined in plug-in files.
  4908. As shipped, the Yocto Project provides several plug-in
  4909. files.
  4910. You can see the source plug-in files that ship with the
  4911. Yocto Project
  4912. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>.
  4913. Each of these plug-in files contains source plug-ins that
  4914. are designed to populate a specific Wic image partition.
  4915. </para>
  4916. <para>
  4917. Source plug-ins are subclasses of the
  4918. <filename>SourcePlugin</filename> class, which is
  4919. defined in the
  4920. <filename>poky/scripts/lib/wic/pluginbase.py</filename>
  4921. file.
  4922. For example, the <filename>BootimgEFIPlugin</filename>
  4923. source plug-in found in the
  4924. <filename>bootimg-efi.py</filename> file is a subclass of
  4925. the <filename>SourcePlugin</filename> class, which is found
  4926. in the <filename>pluginbase.py</filename> file.
  4927. </para>
  4928. <para>
  4929. You can also implement source plug-ins in a layer outside
  4930. of the Source Repositories (external layer).
  4931. To do so, be sure that your plug-in files are located in
  4932. a directory whose path is
  4933. <filename>scripts/lib/wic/plugins/source/</filename>
  4934. within your external layer.
  4935. When the plug-in files are located there, the source
  4936. plug-ins they contain are made available to Wic.
  4937. </para>
  4938. <para>
  4939. When the Wic implementation needs to invoke a
  4940. partition-specific implementation, it looks for the plug-in
  4941. with the same name as the <filename>--source</filename>
  4942. parameter used in the kickstart file given to that
  4943. partition.
  4944. For example, if the partition is set up using the following
  4945. command in a kickstart file:
  4946. <literallayout class='monospaced'>
  4947. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  4948. </literallayout>
  4949. The methods defined as class members of the matching
  4950. source plug-in (i.e. <filename>bootimg-pcbios</filename>)
  4951. in the <filename>bootimg-pcbios.py</filename> plug-in file
  4952. are used.
  4953. </para>
  4954. <para>
  4955. To be more concrete, here is the corresponding plug-in
  4956. definition from the <filename>bootimg-pcbios.py</filename>
  4957. file for the previous command along with an example
  4958. method called by the Wic implementation when it needs to
  4959. prepare a partition using an implementation-specific
  4960. function:
  4961. <literallayout class='monospaced'>
  4962. bootimg-pcbios.py
  4963. .
  4964. .
  4965. .
  4966. class BootimgPcbiosPlugin(SourcePlugin):
  4967. """
  4968. Create MBR boot partition and install syslinux on it.
  4969. """
  4970. name = 'bootimg-pcbios'
  4971. .
  4972. .
  4973. .
  4974. @classmethod
  4975. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  4976. oe_builddir, bootimg_dir, kernel_dir,
  4977. rootfs_dir, native_sysroot):
  4978. """
  4979. Called to do the actual content population for a partition i.e. it
  4980. 'prepares' the partition to be incorporated into the image.
  4981. In this case, prepare content for legacy bios boot partition.
  4982. """
  4983. .
  4984. .
  4985. .
  4986. </literallayout>
  4987. If a subclass (plug-in) itself does not implement a
  4988. particular function, Wic locates and uses the default
  4989. version in the superclass.
  4990. It is for this reason that all source plug-ins are derived
  4991. from the <filename>SourcePlugin</filename> class.
  4992. </para>
  4993. <para>
  4994. The <filename>SourcePlugin</filename> class defined in
  4995. the <filename>pluginbase.py</filename> file defines
  4996. a set of methods that source plug-ins can implement or
  4997. override.
  4998. Any plug-ins (subclass of
  4999. <filename>SourcePlugin</filename>) that do not implement
  5000. a particular method inherit the implementation of the
  5001. method from the <filename>SourcePlugin</filename> class.
  5002. For more information, see the
  5003. <filename>SourcePlugin</filename> class in the
  5004. <filename>pluginbase.py</filename> file for details:
  5005. </para>
  5006. <para>
  5007. The following list describes the methods implemented in the
  5008. <filename>SourcePlugin</filename> class:
  5009. <itemizedlist>
  5010. <listitem><para>
  5011. <emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  5012. Called to populate a partition with actual content.
  5013. In other words, the method prepares the final
  5014. partition image that is incorporated into the
  5015. disk image.
  5016. </para></listitem>
  5017. <listitem><para>
  5018. <emphasis><filename>do_configure_partition()</filename>:</emphasis>
  5019. Called before
  5020. <filename>do_prepare_partition()</filename> to
  5021. create custom configuration files for a partition
  5022. (e.g. syslinux or grub configuration files).
  5023. </para></listitem>
  5024. <listitem><para>
  5025. <emphasis><filename>do_install_disk()</filename>:</emphasis>
  5026. Called after all partitions have been prepared and
  5027. assembled into a disk image.
  5028. This method provides a hook to allow finalization
  5029. of a disk image (e.g. writing an MBR).
  5030. </para></listitem>
  5031. <listitem><para>
  5032. <emphasis><filename>do_stage_partition()</filename>:</emphasis>
  5033. Special content-staging hook called before
  5034. <filename>do_prepare_partition()</filename>.
  5035. This method is normally empty.</para>
  5036. <para>Typically, a partition just uses the passed-in
  5037. parameters (e.g. the unmodified value of
  5038. <filename>bootimg_dir</filename>).
  5039. However, in some cases, things might need to be
  5040. more tailored.
  5041. As an example, certain files might additionally
  5042. need to be taken from
  5043. <filename>bootimg_dir + /boot</filename>.
  5044. This hook allows those files to be staged in a
  5045. customized fashion.
  5046. <note>
  5047. <filename>get_bitbake_var()</filename>
  5048. allows you to access non-standard variables
  5049. that you might want to use for this
  5050. behavior.
  5051. </note>
  5052. </para></listitem>
  5053. </itemizedlist>
  5054. </para>
  5055. <para>
  5056. You can extend the source plug-in mechanism.
  5057. To add more hooks, create more source plug-in methods
  5058. within <filename>SourcePlugin</filename> and the
  5059. corresponding derived subclasses.
  5060. The code that calls the plug-in methods uses the
  5061. <filename>plugin.get_source_plugin_methods()</filename>
  5062. function to find the method or methods needed by the call.
  5063. Retrieval of those methods is accomplished by filling up
  5064. a dict with keys that contain the method names of interest.
  5065. On success, these will be filled in with the actual
  5066. methods.
  5067. See the Wic implementation for examples and details.
  5068. </para>
  5069. </section>
  5070. <section id='wic-usage-examples'>
  5071. <title>Examples</title>
  5072. <para>
  5073. This section provides several examples that show how to use
  5074. the Wic utility.
  5075. All the examples assume the list of requirements in the
  5076. "<link linkend='wic-requirements'>Requirements</link>"
  5077. section have been met.
  5078. The examples assume the previously generated image is
  5079. <filename>core-image-minimal</filename>.
  5080. </para>
  5081. <section id='generate-an-image-using-a-provided-kickstart-file'>
  5082. <title>Generate an Image using an Existing Kickstart File</title>
  5083. <para>
  5084. This example runs in Cooked Mode and uses the
  5085. <filename>mkefidisk</filename> kickstart file:
  5086. <literallayout class='monospaced'>
  5087. $ wic create mkefidisk -e core-image-minimal
  5088. INFO: Building wic-tools...
  5089. .
  5090. .
  5091. .
  5092. INFO: The new image(s) can be found here:
  5093. ./mkefidisk-201710061409-sda.direct
  5094. The following build artifacts were used to create the image(s):
  5095. ROOTFS_DIR: /home/scottrif/poky/build/tmp.wic.r4hkds0b/rootfs_copy
  5096. BOOTIMG_DIR: /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  5097. KERNEL_DIR: /home/scottrif/poky/build/tmp/deploy/images/qemux86
  5098. NATIVE_SYSROOT: /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  5099. INFO: The image(s) were created using OE kickstart file:
  5100. /home/scottrif/poky/scripts/lib/wic/canned-wks/mkefidisk.wks
  5101. </literallayout>
  5102. The previous example shows the easiest way to create
  5103. an image by running in cooked mode and supplying
  5104. a kickstart file and the "-e" option to point to the
  5105. existing build artifacts.
  5106. Your <filename>local.conf</filename> file needs to have
  5107. the
  5108. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  5109. variable set to the machine you are using, which is
  5110. "qemux86" in this example.
  5111. </para>
  5112. <para>
  5113. Once the image builds, the output provides image
  5114. location, artifact use, and kickstart file information.
  5115. <note>
  5116. You should always verify the details provided in the
  5117. output to make sure that the image was indeed
  5118. created exactly as expected.
  5119. </note>
  5120. </para>
  5121. <para>
  5122. Continuing with the example, you can now write the
  5123. image to a USB stick, or whatever media for which you
  5124. built your image, and boot from the media.
  5125. You can write the image by using
  5126. <filename>bmaptool</filename> or
  5127. <filename>dd</filename>:
  5128. <literallayout class='monospaced'>
  5129. $ oe-run-native bmaptool copy build/mkefidisk-201710061409-sda.direct /dev/sd<replaceable>X</replaceable>
  5130. </literallayout>
  5131. or
  5132. <literallayout class='monospaced'>
  5133. $ sudo dd if=build/mkefidisk-201710061409-sda.direct of=/dev/sd<replaceable>X</replaceable>
  5134. </literallayout>
  5135. <note>
  5136. For more information on how to use the
  5137. <filename>bmaptool</filename> to flash a device
  5138. with an image, see the
  5139. "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>"
  5140. section.
  5141. </note>
  5142. </para>
  5143. </section>
  5144. <section id='using-a-modified-kickstart-file'>
  5145. <title>Using a Modified Kickstart File</title>
  5146. <para>
  5147. Because partitioned image creation is driven by the
  5148. kickstart file, it is easy to affect image creation by
  5149. changing the parameters in the file.
  5150. This next example demonstrates that through modification
  5151. of the <filename>directdisk-gpt</filename> kickstart
  5152. file.
  5153. </para>
  5154. <para>
  5155. As mentioned earlier, you can use the command
  5156. <filename>wic list images</filename> to show the list
  5157. of existing kickstart files.
  5158. The directory in which the
  5159. <filename>directdisk-gpt.wks</filename> file resides is
  5160. <filename>scripts/lib/image/canned-wks/</filename>,
  5161. which is located in the
  5162. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  5163. (e.g. <filename>poky</filename>).
  5164. Because available files reside in this directory,
  5165. you can create and add your own custom files to the
  5166. directory.
  5167. Subsequent use of the
  5168. <filename>wic list images</filename> command would then
  5169. include your kickstart files.
  5170. </para>
  5171. <para>
  5172. In this example, the existing
  5173. <filename>directdisk-gpt</filename> file already does
  5174. most of what is needed.
  5175. However, for the hardware in this example, the image
  5176. will need to boot from <filename>sdb</filename> instead
  5177. of <filename>sda</filename>, which is what the
  5178. <filename>directdisk-gpt</filename> kickstart file
  5179. uses.
  5180. </para>
  5181. <para>
  5182. The example begins by making a copy of the
  5183. <filename>directdisk-gpt.wks</filename> file in the
  5184. <filename>scripts/lib/image/canned-wks</filename>
  5185. directory and then by changing the lines that specify
  5186. the target disk from which to boot.
  5187. <literallayout class='monospaced'>
  5188. $ cp /home/scottrif/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  5189. /home/scottrif/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  5190. </literallayout>
  5191. Next, the example modifies the
  5192. <filename>directdisksdb-gpt.wks</filename> file and
  5193. changes all instances of
  5194. "<filename>--ondisk sda</filename>" to
  5195. "<filename>--ondisk sdb</filename>".
  5196. The example changes the following two lines and leaves
  5197. the remaining lines untouched:
  5198. <literallayout class='monospaced'>
  5199. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  5200. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  5201. </literallayout>
  5202. Once the lines are changed, the example generates the
  5203. <filename>directdisksdb-gpt</filename> image.
  5204. The command points the process at the
  5205. <filename>core-image-minimal</filename> artifacts for
  5206. the Next Unit of Computing (nuc)
  5207. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  5208. the <filename>local.conf</filename>.
  5209. <literallayout class='monospaced'>
  5210. $ wic create directdisksdb-gpt -e core-image-minimal
  5211. INFO: Building wic-tools...
  5212. .
  5213. .
  5214. .
  5215. Initialising tasks: 100% |#######################################| Time: 0:00:01
  5216. NOTE: Executing SetScene Tasks
  5217. NOTE: Executing RunQueue Tasks
  5218. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  5219. INFO: Creating image(s)...
  5220. INFO: The new image(s) can be found here:
  5221. ./directdisksdb-gpt-201710090938-sdb.direct
  5222. The following build artifacts were used to create the image(s):
  5223. ROOTFS_DIR: /home/scottrif/poky/build/tmp.wic.hk3wl6zn/rootfs_copy
  5224. BOOTIMG_DIR: /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  5225. KERNEL_DIR: /home/scottrif/poky/build/tmp/deploy/images/qemux86
  5226. NATIVE_SYSROOT: /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  5227. INFO: The image(s) were created using OE kickstart file:
  5228. /home/scottrif/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  5229. </literallayout>
  5230. Continuing with the example, you can now directly
  5231. <filename>dd</filename> the image to a USB stick, or
  5232. whatever media for which you built your image,
  5233. and boot the resulting media:
  5234. <literallayout class='monospaced'>
  5235. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  5236. 140966+0 records in
  5237. 140966+0 records out
  5238. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  5239. $ sudo eject /dev/sdb
  5240. </literallayout>
  5241. </para>
  5242. </section>
  5243. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  5244. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  5245. <para>
  5246. This next example manually specifies each build artifact
  5247. (runs in Raw Mode) and uses a modified kickstart file.
  5248. The example also uses the <filename>-o</filename> option
  5249. to cause Wic to create the output
  5250. somewhere other than the default output directory,
  5251. which is the current directory:
  5252. <literallayout class='monospaced'>
  5253. $ wic create /home/scottrif/my_yocto/test.wks -o /home/scottrif/testwic \
  5254. --rootfs-dir /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  5255. --bootimg-dir /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  5256. --kernel-dir /home/scottrif/poky/build/tmp/deploy/images/qemux86 \
  5257. --native-sysroot /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  5258. INFO: Creating image(s)...
  5259. INFO: The new image(s) can be found here:
  5260. /home/scottrif/testwic/test-201710091445-sdb.direct
  5261. The following build artifacts were used to create the image(s):
  5262. ROOTFS_DIR: /home/scottrif/testwic/tmp.wic.x4wipbmb/rootfs_copy
  5263. BOOTIMG_DIR: /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  5264. KERNEL_DIR: /home/scottrif/poky/build/tmp/deploy/images/qemux86
  5265. NATIVE_SYSROOT: /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  5266. INFO: The image(s) were created using OE kickstart file:
  5267. /home/scottrif/my_yocto/test.wks
  5268. </literallayout>
  5269. For this example,
  5270. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  5271. did not have to be specified in the
  5272. <filename>local.conf</filename> file since the
  5273. artifact is manually specified.
  5274. </para>
  5275. </section>
  5276. <section id='using-wic-to-manipulate-an-image'>
  5277. <title>Using Wic to Manipulate an Image</title>
  5278. <para>
  5279. Wic image manipulation allows you to shorten turnaround
  5280. time during image development.
  5281. For example, you can use Wic to delete the kernel partition
  5282. of a Wic image and then insert a newly built kernel.
  5283. This saves you time from having to rebuild the entire image
  5284. each time you modify the kernel.
  5285. <note>
  5286. In order to use Wic to manipulate a Wic image as in
  5287. this example, your development machine must have the
  5288. <filename>mtools</filename> package installed.
  5289. </note>
  5290. </para>
  5291. <para>
  5292. The following example examines the contents of the Wic
  5293. image, deletes the existing kernel, and then inserts a
  5294. new kernel:
  5295. <orderedlist>
  5296. <listitem><para>
  5297. <emphasis>List the Partitions:</emphasis>
  5298. Use the <filename>wic ls</filename> command to list
  5299. all the partitions in the Wic image:
  5300. <literallayout class='monospaced'>
  5301. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  5302. Num Start End Size Fstype
  5303. 1 1048576 25041919 23993344 fat16
  5304. 2 25165824 72157183 46991360 ext4
  5305. </literallayout>
  5306. The previous output shows two partitions in the
  5307. <filename>core-image-minimal-qemux86.wic</filename>
  5308. image.
  5309. </para></listitem>
  5310. <listitem><para>
  5311. <emphasis>Examine a Particular Partition:</emphasis>
  5312. Use the <filename>wic ls</filename> command again
  5313. but in a different form to examine a particular
  5314. partition.
  5315. <note>
  5316. You can get command usage on any Wic command
  5317. using the following form:
  5318. <literallayout class='monospaced'>
  5319. $ wic help <replaceable>command</replaceable>
  5320. </literallayout>
  5321. For example, the following command shows you
  5322. the various ways to use the
  5323. <filename>wic ls</filename> command:
  5324. <literallayout class='monospaced'>
  5325. $ wic help ls
  5326. </literallayout>
  5327. </note>
  5328. The following command shows what is in Partition
  5329. one:
  5330. <literallayout class='monospaced'>
  5331. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  5332. Volume in drive : is boot
  5333. Volume Serial Number is E894-1809
  5334. Directory for ::/
  5335. libcom32 c32 186500 2017-10-09 16:06
  5336. libutil c32 24148 2017-10-09 16:06
  5337. syslinux cfg 220 2017-10-09 16:06
  5338. vesamenu c32 27104 2017-10-09 16:06
  5339. vmlinuz 6904608 2017-10-09 16:06
  5340. 5 files 7 142 580 bytes
  5341. 16 582 656 bytes free
  5342. </literallayout>
  5343. The previous output shows five files, with the
  5344. <filename>vmlinuz</filename> being the kernel.
  5345. <note>
  5346. If you see the following error, you need to
  5347. update or create a
  5348. <filename>~/.mtoolsrc</filename> file and
  5349. be sure to have the line “mtools_skip_check=1“
  5350. in the file.
  5351. Then, run the Wic command again:
  5352. <literallayout class='monospaced'>
  5353. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  5354. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  5355. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  5356. </literallayout>
  5357. </note>
  5358. </para></listitem>
  5359. <listitem><para>
  5360. <emphasis>Remove the Old Kernel:</emphasis>
  5361. Use the <filename>wic rm</filename> command to
  5362. remove the <filename>vmlinuz</filename> file
  5363. (kernel):
  5364. <literallayout class='monospaced'>
  5365. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  5366. </literallayout>
  5367. </para></listitem>
  5368. <listitem><para>
  5369. <emphasis>Add In the New Kernel:</emphasis>
  5370. Use the <filename>wic cp</filename> command to
  5371. add the updated kernel to the Wic image.
  5372. Depending on how you built your kernel, it could
  5373. be in different places.
  5374. If you used <filename>devtool</filename> and
  5375. an SDK to build your kernel, it resides in the
  5376. <filename>tmp/work</filename> directory of the
  5377. extensible SDK.
  5378. If you used <filename>make</filename> to build the
  5379. kernel, the kernel will be in the
  5380. <filename>workspace/sources</filename> area.
  5381. </para>
  5382. <para>The following example assumes
  5383. <filename>devtool</filename> was used to build
  5384. the kernel:
  5385. <literallayout class='monospaced'>
  5386. cp ~/poky_sdk/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+git999-r0/linux-yocto-4.12.12+git999/arch/x86/boot/bzImage \
  5387. ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  5388. </literallayout>
  5389. Once the new kernel is added back into the image,
  5390. you can use the <filename>dd</filename>
  5391. command or
  5392. <link linkend='flashing-images-using-bmaptool'><filename>bmaptool</filename></link>
  5393. to flash your wic image onto an SD card
  5394. or USB stick and test your target.
  5395. <note>
  5396. Using <filename>bmaptool</filename> is
  5397. generally 10 to 20 times faster than using
  5398. <filename>dd</filename>.
  5399. </note>
  5400. </para></listitem>
  5401. </orderedlist>
  5402. </para>
  5403. </section>
  5404. </section>
  5405. </section>
  5406. <section id='building-an-initramfs-image'>
  5407. <title>Building an Initial RAM Filesystem (initramfs) Image</title>
  5408. <para>
  5409. An initial RAM filesystem (initramfs) image provides a temporary
  5410. root filesystem used for early system initialization (e.g.
  5411. loading of modules needed to locate and mount the "real" root
  5412. filesystem).
  5413. <note>
  5414. The initramfs image is the successor of initial RAM disk
  5415. (initrd).
  5416. It is a "copy in and out" (cpio) archive of the initial
  5417. filesystem that gets loaded into memory during the Linux
  5418. startup process.
  5419. Because Linux uses the contents of the archive during
  5420. initialization, the initramfs image needs to contain all of the
  5421. device drivers and tools needed to mount the final root
  5422. filesystem.
  5423. </note>
  5424. </para>
  5425. <para>
  5426. Follow these steps to create an initramfs image:
  5427. <orderedlist>
  5428. <listitem><para>
  5429. <emphasis>Create the initramfs Image Recipe:</emphasis>
  5430. You can reference the
  5431. <filename>core-image-minimal-initramfs.bb</filename>
  5432. recipe found in the <filename>meta/recipes-core</filename>
  5433. directory of the
  5434. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  5435. as an example from which to work.
  5436. </para></listitem>
  5437. <listitem><para>
  5438. <emphasis>Decide if You Need to Bundle the initramfs Image
  5439. Into the Kernel Image:</emphasis>
  5440. If you want the initramfs image that is built to be
  5441. bundled in with the kernel image, set the
  5442. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  5443. variable to "1" in your <filename>local.conf</filename>
  5444. configuration file and set the
  5445. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink>
  5446. variable in the recipe that builds the kernel image.
  5447. <note><title>Tip</title>
  5448. It is recommended that you do bundle the initramfs
  5449. image with the kernel image to avoid circular
  5450. dependencies between the kernel recipe and the
  5451. initramfs recipe should the initramfs image
  5452. include kernel modules.
  5453. </note>
  5454. Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename>
  5455. flag causes the initramfs image to be unpacked
  5456. into the <filename>${B}/usr/</filename> directory.
  5457. The unpacked initramfs image is then passed to the kernel's
  5458. <filename>Makefile</filename> using the
  5459. <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink>
  5460. variable, allowing the initramfs image to be built into
  5461. the kernel normally.
  5462. <note>
  5463. If you choose to not bundle the initramfs image with
  5464. the kernel image, you are essentially using an
  5465. <ulink url='https://en.wikipedia.org/wiki/Initrd'>Initial RAM Disk (initrd)</ulink>.
  5466. Creating an initrd is handled primarily through the
  5467. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRD_IMAGE'><filename>INITRD_IMAGE</filename></ulink>,
  5468. <filename>INITRD_LIVE</filename>, and
  5469. <filename>INITRD_IMAGE_LIVE</filename> variables.
  5470. For more information, see the
  5471. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/image-live.bbclass'><filename>image-live.bbclass</filename></ulink>
  5472. file.
  5473. </note>
  5474. </para></listitem>
  5475. <!--
  5476. Some notes from Cal:
  5477. A non-bundled initramfs is essentially an initrd, which I am discovering
  5478. to be rather confusingly supported in OE at the moment.
  5479. Its primarily handled through INITRD_IMAGE(_LIVE/_VM) and INITRD(_LIVE/_VM)
  5480. variables. INITRD_IMAGE* is the primary image target, which gets added to
  5481. INITRD*, which is a list of cpio filesystems. You can add more cpio
  5482. filesystems to the INITRD variable to add more to the initrd. For
  5483. instance, meta-intel adds intel-microcode via the following:
  5484. INITRD_LIVE_prepend = "${@bb.utils.contains('MACHINE_FEATURES', 'intel-ucode', '${DEPLOY_DIR_IMAGE}/microcode.cpio ', '', d)}"
  5485. If 'intel-ucode' is in MACHINE_FEATURES, this resolves to:
  5486. INITRD_LIVE_prepend = "${DEPLOY_DIR_IMAGE}/microcode.cpio "
  5487. Unfortunately you need the full path, and its up to you to sort out
  5488. dependencies as well. For instance, we have the following:
  5489. MACHINE_ESSENTIAL_EXTRA_RDEPENDS_append = "${@bb.utils.contains('MACHINE_FEATURES', 'intel-ucode', ' intel-microcode', '', d)}"
  5490. which resolves to:
  5491. MACHINE_ESSENTIAL_EXTRA_RDEPENDS_append = "intel-microcode"
  5492. However, the above is only true with the "live" IMAGE_FSTYPE. Wic is
  5493. another beast entirely, with current wic kickstart files not supporting
  5494. initrds, and only partial support in the source plugins. That being said,
  5495. I know the generic bootfs work Ed is working on will help immensely in this
  5496. aspect. He or Saul can provide more details here.
  5497. Anyhow, its rather fractured and confusing and could probably use a
  5498. rework honestly. I don't know how feasible it is to document all the
  5499. details and corner cases of this area.
  5500. -->
  5501. <listitem><para>
  5502. <emphasis>Optionally Add Items to the initramfs Image
  5503. Through the initramfs Image Recipe:</emphasis>
  5504. If you add items to the initramfs image by way of its
  5505. recipe, you should use
  5506. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>
  5507. rather than
  5508. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>.
  5509. <filename>PACKAGE_INSTALL</filename> gives more direct
  5510. control of what is added to the image as compared to
  5511. the defaults you might not necessarily want that are
  5512. set by the
  5513. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink>
  5514. or
  5515. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink>
  5516. classes.
  5517. </para></listitem>
  5518. <listitem><para>
  5519. <emphasis>Build the Kernel Image and the initramfs
  5520. Image:</emphasis>
  5521. Build your kernel image using BitBake.
  5522. Because the initramfs image recipe is a dependency of the
  5523. kernel image, the initramfs image is built as well and
  5524. bundled with the kernel image if you used the
  5525. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  5526. variable described earlier.
  5527. </para></listitem>
  5528. </orderedlist>
  5529. </para>
  5530. </section>
  5531. <section id='flashing-images-using-bmaptool'>
  5532. <title>Flashing Images Using <filename>bmaptool</filename></title>
  5533. <para>
  5534. An easy way to flash an image to a bootable device is to use
  5535. <filename>bmaptool</filename>, which is integrated into the
  5536. OpenEmbedded build system.
  5537. </para>
  5538. <para>
  5539. Following, is an example that shows how to flash a Wic image.
  5540. <note>
  5541. You can use <filename>bmaptool</filename> to flash any
  5542. type of image.
  5543. </note>
  5544. Use these steps to flash an image using
  5545. <filename>bmaptool</filename>:
  5546. <note>
  5547. Unless you are able to install the
  5548. <filename>bmap-tools</filename> package as mentioned in the note
  5549. in the second bullet of step 3 further down, you will need to build
  5550. <filename>bmaptool</filename> before using it.
  5551. Build the tool using the following command:
  5552. <literallayout class='monospaced'>
  5553. $ bitbake bmap-tools-native
  5554. </literallayout>
  5555. </note>
  5556. <orderedlist>
  5557. <listitem><para>
  5558. <emphasis>Update the <filename>local.conf</filename> File:</emphasis>
  5559. Add the following to your <filename>local.conf</filename>
  5560. file:
  5561. <literallayout class='monospaced'>
  5562. IMAGE_FSTYPES += "wic wic.bmap"
  5563. </literallayout>
  5564. </para></listitem>
  5565. <listitem><para>
  5566. <emphasis>Get Your Image:</emphasis>
  5567. Either have your image ready (pre-built) or take the step
  5568. build the image:
  5569. <literallayout class='monospaced'>
  5570. $ bitbake <replaceable>image</replaceable>
  5571. </literallayout>
  5572. </para></listitem>
  5573. <listitem><para>
  5574. <emphasis>Flash the Device:</emphasis>
  5575. Flash the device with the image by using
  5576. <filename>bmaptool</filename> depending on your particular
  5577. setup:
  5578. <itemizedlist>
  5579. <listitem><para>
  5580. If you have write access to the media,
  5581. use this command form:
  5582. <literallayout class='monospaced'>
  5583. $ oe-run-native bmap-tools-native bmaptool copy ./tmp/deploy/images/qemux86-64-core-image-minimal-<replaceable>machine</replaceable>.wic /dev/sd<replaceable>X</replaceable>
  5584. </literallayout>
  5585. </para></listitem>
  5586. <listitem><para>
  5587. If you do not have write access to
  5588. the media, use the following
  5589. commands:
  5590. <literallayout class='monospaced'>
  5591. $ sudo chmod 666 /dev/sd<replaceable>X</replaceable>
  5592. $ oe-run-native bmap-tools-native bmaptool copy ./tmp/deploy/images/qemux86-64-core-image-minimal-<replaceable>machine</replaceable>.wic /dev/sd<replaceable>X</replaceable>
  5593. </literallayout>
  5594. <note>
  5595. If you are using Ubuntu or Debian distributions,
  5596. you can install the
  5597. <filename>bmap-tools</filename> package using
  5598. the following command and then use the tool
  5599. without specifying
  5600. <filename>PATH</filename> even from the
  5601. root account:
  5602. <literallayout class='monospaced'>
  5603. $ sudo apt-get install bmap-tools
  5604. </literallayout>
  5605. </note>
  5606. </para></listitem>
  5607. </itemizedlist>
  5608. </para></listitem>
  5609. </orderedlist>
  5610. </para>
  5611. <para>
  5612. For help on the <filename>bmaptool</filename> command, use the
  5613. following command:
  5614. <literallayout class='monospaced'>
  5615. $ bmaptool --help
  5616. </literallayout>
  5617. </para>
  5618. </section>
  5619. <section id='making-images-more-secure'>
  5620. <title>Making Images More Secure</title>
  5621. <para>
  5622. Security is of increasing concern for embedded devices.
  5623. Consider the issues and problems discussed in just this
  5624. sampling of work found across the Internet:
  5625. <itemizedlist>
  5626. <listitem><para><emphasis>
  5627. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  5628. by Bruce Schneier
  5629. </para></listitem>
  5630. <listitem><para><emphasis>
  5631. "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis>
  5632. by Carna Botnet</para></listitem>
  5633. <listitem><para><emphasis>
  5634. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  5635. by Jake Edge
  5636. </para></listitem>
  5637. </itemizedlist>
  5638. </para>
  5639. <para>
  5640. When securing your image is of concern, there are steps, tools,
  5641. and variables that you can consider to help you reach the
  5642. security goals you need for your particular device.
  5643. Not all situations are identical when it comes to making an
  5644. image secure.
  5645. Consequently, this section provides some guidance and suggestions
  5646. for consideration when you want to make your image more secure.
  5647. <note>
  5648. Because the security requirements and risks are
  5649. different for every type of device, this section cannot
  5650. provide a complete reference on securing your custom OS.
  5651. It is strongly recommended that you also consult other sources
  5652. of information on embedded Linux system hardening and on
  5653. security.
  5654. </note>
  5655. </para>
  5656. <section id='general-considerations'>
  5657. <title>General Considerations</title>
  5658. <para>
  5659. General considerations exist that help you create more
  5660. secure images.
  5661. You should consider the following suggestions to help
  5662. make your device more secure:
  5663. <itemizedlist>
  5664. <listitem><para>
  5665. Scan additional code you are adding to the system
  5666. (e.g. application code) by using static analysis
  5667. tools.
  5668. Look for buffer overflows and other potential
  5669. security problems.
  5670. </para></listitem>
  5671. <listitem><para>
  5672. Pay particular attention to the security for
  5673. any web-based administration interface.
  5674. </para>
  5675. <para>Web interfaces typically need to perform
  5676. administrative functions and tend to need to run with
  5677. elevated privileges.
  5678. Thus, the consequences resulting from the interface's
  5679. security becoming compromised can be serious.
  5680. Look for common web vulnerabilities such as
  5681. cross-site-scripting (XSS), unvalidated inputs,
  5682. and so forth.</para>
  5683. <para>As with system passwords, the default credentials
  5684. for accessing a web-based interface should not be the
  5685. same across all devices.
  5686. This is particularly true if the interface is enabled
  5687. by default as it can be assumed that many end-users
  5688. will not change the credentials.
  5689. </para></listitem>
  5690. <listitem><para>
  5691. Ensure you can update the software on the device to
  5692. mitigate vulnerabilities discovered in the future.
  5693. This consideration especially applies when your
  5694. device is network-enabled.
  5695. </para></listitem>
  5696. <listitem><para>
  5697. Ensure you remove or disable debugging functionality
  5698. before producing the final image.
  5699. For information on how to do this, see the
  5700. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  5701. section.
  5702. </para></listitem>
  5703. <listitem><para>
  5704. Ensure you have no network services listening that
  5705. are not needed.
  5706. </para></listitem>
  5707. <listitem><para>
  5708. Remove any software from the image that is not needed.
  5709. </para></listitem>
  5710. <listitem><para>
  5711. Enable hardware support for secure boot functionality
  5712. when your device supports this functionality.
  5713. </para></listitem>
  5714. </itemizedlist>
  5715. </para>
  5716. </section>
  5717. <section id='security-flags'>
  5718. <title>Security Flags</title>
  5719. <para>
  5720. The Yocto Project has security flags that you can enable that
  5721. help make your build output more secure.
  5722. The security flags are in the
  5723. <filename>meta/conf/distro/include/security_flags.inc</filename>
  5724. file in your
  5725. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  5726. (e.g. <filename>poky</filename>).
  5727. <note>
  5728. Depending on the recipe, certain security flags are enabled
  5729. and disabled by default.
  5730. </note>
  5731. </para>
  5732. <para>
  5733. <!--
  5734. The GCC/LD flags in <filename>security_flags.inc</filename>
  5735. enable more secure code generation.
  5736. By including the <filename>security_flags.inc</filename>
  5737. file, you enable flags to the compiler and linker that cause
  5738. them to generate more secure code.
  5739. <note>
  5740. The GCC/LD flags are enabled by default in the
  5741. <filename>poky-lsb</filename> distribution.
  5742. </note>
  5743. -->
  5744. Use the following line in your
  5745. <filename>local.conf</filename> file or in your custom
  5746. distribution configuration file to enable the security
  5747. compiler and linker flags for your build:
  5748. <literallayout class='monospaced'>
  5749. require conf/distro/include/security_flags.inc
  5750. </literallayout>
  5751. </para>
  5752. </section>
  5753. <section id='considerations-specific-to-the-openembedded-build-system'>
  5754. <title>Considerations Specific to the OpenEmbedded Build System</title>
  5755. <para>
  5756. You can take some steps that are specific to the
  5757. OpenEmbedded build system to make your images more secure:
  5758. <itemizedlist>
  5759. <listitem><para>
  5760. Ensure "debug-tweaks" is not one of your selected
  5761. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  5762. When creating a new project, the default is to provide you
  5763. with an initial <filename>local.conf</filename> file that
  5764. enables this feature using the
  5765. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  5766. <literallayout class='monospaced'>
  5767. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  5768. </literallayout>
  5769. To disable that feature, simply comment out that line in your
  5770. <filename>local.conf</filename> file, or
  5771. make sure <filename>IMAGE_FEATURES</filename> does not contain
  5772. "debug-tweaks" before producing your final image.
  5773. Among other things, leaving this in place sets the
  5774. root password as blank, which makes logging in for
  5775. debugging or inspection easy during
  5776. development but also means anyone can easily log in
  5777. during production.
  5778. </para></listitem>
  5779. <listitem><para>
  5780. It is possible to set a root password for the image
  5781. and also to set passwords for any extra users you might
  5782. add (e.g. administrative or service type users).
  5783. When you set up passwords for multiple images or
  5784. users, you should not duplicate passwords.
  5785. </para>
  5786. <para>
  5787. To set up passwords, use the
  5788. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  5789. class, which is the preferred method.
  5790. For an example on how to set up both root and user
  5791. passwords, see the
  5792. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  5793. section.
  5794. <note>
  5795. When adding extra user accounts or setting a
  5796. root password, be cautious about setting the
  5797. same password on every device.
  5798. If you do this, and the password you have set
  5799. is exposed, then every device is now potentially
  5800. compromised.
  5801. If you need this access but want to ensure
  5802. security, consider setting a different,
  5803. random password for each device.
  5804. Typically, you do this as a separate step after
  5805. you deploy the image onto the device.
  5806. </note>
  5807. </para></listitem>
  5808. <listitem><para>
  5809. Consider enabling a Mandatory Access Control (MAC)
  5810. framework such as SMACK or SELinux and tuning it
  5811. appropriately for your device's usage.
  5812. You can find more information in the
  5813. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink>
  5814. layer.
  5815. </para></listitem>
  5816. </itemizedlist>
  5817. </para>
  5818. <para>
  5819. </para>
  5820. </section>
  5821. <section id='tools-for-hardening-your-image'>
  5822. <title>Tools for Hardening Your Image</title>
  5823. <para>
  5824. The Yocto Project provides tools for making your image
  5825. more secure.
  5826. You can find these tools in the
  5827. <filename>meta-security</filename> layer of the
  5828. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
  5829. </para>
  5830. </section>
  5831. </section>
  5832. <section id='creating-your-own-distribution'>
  5833. <title>Creating Your Own Distribution</title>
  5834. <para>
  5835. When you build an image using the Yocto Project and
  5836. do not alter any distribution
  5837. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  5838. you are creating a Poky distribution.
  5839. If you wish to gain more control over package alternative
  5840. selections, compile-time options, and other low-level
  5841. configurations, you can create your own distribution.
  5842. </para>
  5843. <para>
  5844. To create your own distribution, the basic steps consist of
  5845. creating your own distribution layer, creating your own
  5846. distribution configuration file, and then adding any needed
  5847. code and Metadata to the layer.
  5848. The following steps provide some more detail:
  5849. <itemizedlist>
  5850. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  5851. Create your distribution layer so that you can keep your
  5852. Metadata and code for the distribution separate.
  5853. It is strongly recommended that you create and use your own
  5854. layer for configuration and code.
  5855. Using your own layer as compared to just placing
  5856. configurations in a <filename>local.conf</filename>
  5857. configuration file makes it easier to reproduce the same
  5858. build configuration when using multiple build machines.
  5859. See the
  5860. "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>"
  5861. section for information on how to quickly set up a layer.
  5862. </para></listitem>
  5863. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  5864. The distribution configuration file needs to be created in
  5865. the <filename>conf/distro</filename> directory of your
  5866. layer.
  5867. You need to name it using your distribution name
  5868. (e.g. <filename>mydistro.conf</filename>).
  5869. <note>
  5870. The
  5871. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5872. variable in your
  5873. <filename>local.conf</filename> file determines the
  5874. name of your distribution.
  5875. </note></para>
  5876. <para>You can split out parts of your configuration file
  5877. into include files and then "require" them from within
  5878. your distribution configuration file.
  5879. Be sure to place the include files in the
  5880. <filename>conf/distro/include</filename> directory of
  5881. your layer.
  5882. A common example usage of include files would be to
  5883. separate out the selection of desired version and revisions
  5884. for individual recipes.
  5885. </para>
  5886. <para>Your configuration file needs to set the following
  5887. required variables:
  5888. <literallayout class='monospaced'>
  5889. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  5890. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  5891. </literallayout>
  5892. These following variables are optional and you typically
  5893. set them from the distribution configuration file:
  5894. <literallayout class='monospaced'>
  5895. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  5896. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  5897. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  5898. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  5899. </literallayout>
  5900. <tip>
  5901. If you want to base your distribution configuration file
  5902. on the very basic configuration from OE-Core, you
  5903. can use
  5904. <filename>conf/distro/defaultsetup.conf</filename> as
  5905. a reference and just include variables that differ
  5906. as compared to <filename>defaultsetup.conf</filename>.
  5907. Alternatively, you can create a distribution
  5908. configuration file from scratch using the
  5909. <filename>defaultsetup.conf</filename> file
  5910. or configuration files from other distributions
  5911. such as Poky or Angstrom as references.
  5912. </tip></para></listitem>
  5913. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  5914. Be sure to define any other variables for which you want to
  5915. create a default or enforce as part of the distribution
  5916. configuration.
  5917. You can include nearly any variable from the
  5918. <filename>local.conf</filename> file.
  5919. The variables you use are not limited to the list in the
  5920. previous bulleted item.</para></listitem>
  5921. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  5922. In your <filename>local.conf</filename> file in the
  5923. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  5924. set your
  5925. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5926. variable to point to your distribution's configuration file.
  5927. For example, if your distribution's configuration file is
  5928. named <filename>mydistro.conf</filename>, then you point
  5929. to it as follows:
  5930. <literallayout class='monospaced'>
  5931. DISTRO = "mydistro"
  5932. </literallayout></para></listitem>
  5933. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  5934. Use your layer to hold other information needed for the
  5935. distribution:
  5936. <itemizedlist>
  5937. <listitem><para>Add recipes for installing
  5938. distro-specific configuration files that are not
  5939. already installed by another recipe.
  5940. If you have distro-specific configuration files
  5941. that are included by an existing recipe, you should
  5942. add an append file (<filename>.bbappend</filename>)
  5943. for those.
  5944. For general information and recommendations
  5945. on how to add recipes to your layer, see the
  5946. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  5947. and
  5948. "<link linkend='best-practices-to-follow-when-creating-layers'>Following Best Practices When Creating Layers</link>"
  5949. sections.</para></listitem>
  5950. <listitem><para>Add any image recipes that are specific
  5951. to your distribution.</para></listitem>
  5952. <listitem><para>Add a <filename>psplash</filename>
  5953. append file for a branded splash screen.
  5954. For information on append files, see the
  5955. "<link linkend='using-bbappend-files'>Using .bbappend Files in Your Layer</link>"
  5956. section.</para></listitem>
  5957. <listitem><para>Add any other append files to make
  5958. custom changes that are specific to individual
  5959. recipes.</para></listitem>
  5960. </itemizedlist></para></listitem>
  5961. </itemizedlist>
  5962. </para>
  5963. </section>
  5964. <section id='creating-a-custom-template-configuration-directory'>
  5965. <title>Creating a Custom Template Configuration Directory</title>
  5966. <para>
  5967. If you are producing your own customized version
  5968. of the build system for use by other users, you might
  5969. want to customize the message shown by the setup script or
  5970. you might want to change the template configuration files (i.e.
  5971. <filename>local.conf</filename> and
  5972. <filename>bblayers.conf</filename>) that are created in
  5973. a new build directory.
  5974. </para>
  5975. <para>
  5976. The OpenEmbedded build system uses the environment variable
  5977. <filename>TEMPLATECONF</filename> to locate the directory
  5978. from which it gathers configuration information that ultimately
  5979. ends up in the
  5980. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  5981. <filename>conf</filename> directory.
  5982. By default, <filename>TEMPLATECONF</filename> is set as
  5983. follows in the <filename>poky</filename> repository:
  5984. <literallayout class='monospaced'>
  5985. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  5986. </literallayout>
  5987. This is the directory used by the build system to find templates
  5988. from which to build some key configuration files.
  5989. If you look at this directory, you will see the
  5990. <filename>bblayers.conf.sample</filename>,
  5991. <filename>local.conf.sample</filename>, and
  5992. <filename>conf-notes.txt</filename> files.
  5993. The build system uses these files to form the respective
  5994. <filename>bblayers.conf</filename> file,
  5995. <filename>local.conf</filename> file, and display the list of
  5996. BitBake targets when running the setup script.
  5997. </para>
  5998. <para>
  5999. To override these default configuration files with
  6000. configurations you want used within every new
  6001. Build Directory, simply set the
  6002. <filename>TEMPLATECONF</filename> variable to your directory.
  6003. The <filename>TEMPLATECONF</filename> variable is set in the
  6004. <filename>.templateconf</filename> file, which is in the
  6005. top-level
  6006. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  6007. folder (e.g. <filename>poky</filename>).
  6008. Edit the <filename>.templateconf</filename> so that it can locate
  6009. your directory.
  6010. </para>
  6011. <para>
  6012. Best practices dictate that you should keep your
  6013. template configuration directory in your custom distribution layer.
  6014. For example, suppose you have a layer named
  6015. <filename>meta-mylayer</filename> located in your home directory
  6016. and you want your template configuration directory named
  6017. <filename>myconf</filename>.
  6018. Changing the <filename>.templateconf</filename> as follows
  6019. causes the OpenEmbedded build system to look in your directory
  6020. and base its configuration files on the
  6021. <filename>*.sample</filename> configuration files it finds.
  6022. The final configuration files (i.e.
  6023. <filename>local.conf</filename> and
  6024. <filename>bblayers.conf</filename> ultimately still end up in
  6025. your Build Directory, but they are based on your
  6026. <filename>*.sample</filename> files.
  6027. <literallayout class='monospaced'>
  6028. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  6029. </literallayout>
  6030. </para>
  6031. <para>
  6032. Aside from the <filename>*.sample</filename> configuration files,
  6033. the <filename>conf-notes.txt</filename> also resides in the
  6034. default <filename>meta-poky/conf</filename> directory.
  6035. The script that sets up the build environment
  6036. (i.e.
  6037. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>)
  6038. uses this file to display BitBake targets as part of the script
  6039. output.
  6040. Customizing this <filename>conf-notes.txt</filename> file is a
  6041. good way to make sure your list of custom targets appears
  6042. as part of the script's output.
  6043. </para>
  6044. <para>
  6045. Here is the default list of targets displayed as a result of
  6046. running either of the setup scripts:
  6047. <literallayout class='monospaced'>
  6048. You can now run 'bitbake &lt;target&gt;'
  6049. Common targets are:
  6050. core-image-minimal
  6051. core-image-sato
  6052. meta-toolchain
  6053. meta-ide-support
  6054. </literallayout>
  6055. </para>
  6056. <para>
  6057. Changing the listed common targets is as easy as editing your
  6058. version of <filename>conf-notes.txt</filename> in your
  6059. custom template configuration directory and making sure you
  6060. have <filename>TEMPLATECONF</filename> set to your directory.
  6061. </para>
  6062. </section>
  6063. <section id='building-a-tiny-system'>
  6064. <title>Building a Tiny System</title>
  6065. <para>
  6066. Very small distributions have some significant advantages such
  6067. as requiring less on-die or in-package memory (cheaper), better
  6068. performance through efficient cache usage, lower power requirements
  6069. due to less memory, faster boot times, and reduced development
  6070. overhead.
  6071. Some real-world examples where a very small distribution gives
  6072. you distinct advantages are digital cameras, medical devices,
  6073. and small headless systems.
  6074. </para>
  6075. <para>
  6076. This section presents information that shows you how you can
  6077. trim your distribution to even smaller sizes than the
  6078. <filename>poky-tiny</filename> distribution, which is around
  6079. 5 Mbytes, that can be built out-of-the-box using the Yocto Project.
  6080. </para>
  6081. <section id='tiny-system-overview'>
  6082. <title>Overview</title>
  6083. <para>
  6084. The following list presents the overall steps you need to
  6085. consider and perform to create distributions with smaller
  6086. root filesystems, achieve faster boot times, maintain your critical
  6087. functionality, and avoid initial RAM disks:
  6088. <itemizedlist>
  6089. <listitem><para>
  6090. <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link>
  6091. </para></listitem>
  6092. <listitem><para>
  6093. <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link>
  6094. </para></listitem>
  6095. <listitem><para>
  6096. <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link>
  6097. </para></listitem>
  6098. <listitem><para>
  6099. <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link>
  6100. </para></listitem>
  6101. <listitem><para>
  6102. <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link>
  6103. </para></listitem>
  6104. <listitem><para>
  6105. <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link>
  6106. </para></listitem>
  6107. <listitem><para>
  6108. <link linkend='iterate-on-the-process'>Iterate on the process.</link>
  6109. </para></listitem>
  6110. </itemizedlist>
  6111. </para>
  6112. </section>
  6113. <section id='goals-and-guiding-principles'>
  6114. <title>Goals and Guiding Principles</title>
  6115. <para>
  6116. Before you can reach your destination, you need to know
  6117. where you are going.
  6118. Here is an example list that you can use as a guide when
  6119. creating very small distributions:
  6120. <itemizedlist>
  6121. <listitem><para>Determine how much space you need
  6122. (e.g. a kernel that is 1 Mbyte or less and
  6123. a root filesystem that is 3 Mbytes or less).
  6124. </para></listitem>
  6125. <listitem><para>Find the areas that are currently
  6126. taking 90% of the space and concentrate on reducing
  6127. those areas.
  6128. </para></listitem>
  6129. <listitem><para>Do not create any difficult "hacks"
  6130. to achieve your goals.</para></listitem>
  6131. <listitem><para>Leverage the device-specific
  6132. options.</para></listitem>
  6133. <listitem><para>Work in a separate layer so that you
  6134. keep changes isolated.
  6135. For information on how to create layers, see
  6136. the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section.
  6137. </para></listitem>
  6138. </itemizedlist>
  6139. </para>
  6140. </section>
  6141. <section id='understand-what-gives-your-image-size'>
  6142. <title>Understand What Contributes to Your Image Size</title>
  6143. <para>
  6144. It is easiest to have something to start with when creating
  6145. your own distribution.
  6146. You can use the Yocto Project out-of-the-box to create the
  6147. <filename>poky-tiny</filename> distribution.
  6148. Ultimately, you will want to make changes in your own
  6149. distribution that are likely modeled after
  6150. <filename>poky-tiny</filename>.
  6151. <note>
  6152. To use <filename>poky-tiny</filename> in your build,
  6153. set the
  6154. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6155. variable in your
  6156. <filename>local.conf</filename> file to "poky-tiny"
  6157. as described in the
  6158. "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  6159. section.
  6160. </note>
  6161. </para>
  6162. <para>
  6163. Understanding some memory concepts will help you reduce the
  6164. system size.
  6165. Memory consists of static, dynamic, and temporary memory.
  6166. Static memory is the TEXT (code), DATA (initialized data
  6167. in the code), and BSS (uninitialized data) sections.
  6168. Dynamic memory represents memory that is allocated at runtime:
  6169. stacks, hash tables, and so forth.
  6170. Temporary memory is recovered after the boot process.
  6171. This memory consists of memory used for decompressing
  6172. the kernel and for the <filename>__init__</filename>
  6173. functions.
  6174. </para>
  6175. <para>
  6176. To help you see where you currently are with kernel and root
  6177. filesystem sizes, you can use two tools found in the
  6178. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> in
  6179. the <filename>scripts/tiny/</filename> directory:
  6180. <itemizedlist>
  6181. <listitem><para><filename>ksize.py</filename>: Reports
  6182. component sizes for the kernel build objects.
  6183. </para></listitem>
  6184. <listitem><para><filename>dirsize.py</filename>: Reports
  6185. component sizes for the root filesystem.</para></listitem>
  6186. </itemizedlist>
  6187. This next tool and command help you organize configuration
  6188. fragments and view file dependencies in a human-readable form:
  6189. <itemizedlist>
  6190. <listitem><para><filename>merge_config.sh</filename>:
  6191. Helps you manage configuration files and fragments
  6192. within the kernel.
  6193. With this tool, you can merge individual configuration
  6194. fragments together.
  6195. The tool allows you to make overrides and warns you
  6196. of any missing configuration options.
  6197. The tool is ideal for allowing you to iterate on
  6198. configurations, create minimal configurations, and
  6199. create configuration files for different machines
  6200. without having to duplicate your process.</para>
  6201. <para>The <filename>merge_config.sh</filename> script is
  6202. part of the Linux Yocto kernel Git repositories
  6203. (i.e. <filename>linux-yocto-3.14</filename>,
  6204. <filename>linux-yocto-3.10</filename>,
  6205. <filename>linux-yocto-3.8</filename>, and so forth)
  6206. in the
  6207. <filename>scripts/kconfig</filename> directory.</para>
  6208. <para>For more information on configuration fragments,
  6209. see the
  6210. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#creating-config-fragments'>Creating Configuration Fragments</ulink>"
  6211. section in the Yocto Project Linux Kernel Development
  6212. Manual.
  6213. </para></listitem>
  6214. <listitem><para><filename>bitbake -u taskexp -g <replaceable>bitbake_target</replaceable></filename>:
  6215. Using the BitBake command with these options brings up
  6216. a Dependency Explorer from which you can view file
  6217. dependencies.
  6218. Understanding these dependencies allows you to make
  6219. informed decisions when cutting out various pieces of the
  6220. kernel and root filesystem.</para></listitem>
  6221. </itemizedlist>
  6222. </para>
  6223. </section>
  6224. <section id='trim-the-root-filesystem'>
  6225. <title>Trim the Root Filesystem</title>
  6226. <para>
  6227. The root filesystem is made up of packages for booting,
  6228. libraries, and applications.
  6229. To change things, you can configure how the packaging happens,
  6230. which changes the way you build them.
  6231. You can also modify the filesystem itself or select a different
  6232. filesystem.
  6233. </para>
  6234. <para>
  6235. First, find out what is hogging your root filesystem by running the
  6236. <filename>dirsize.py</filename> script from your root directory:
  6237. <literallayout class='monospaced'>
  6238. $ cd <replaceable>root-directory-of-image</replaceable>
  6239. $ dirsize.py 100000 > dirsize-100k.log
  6240. $ cat dirsize-100k.log
  6241. </literallayout>
  6242. You can apply a filter to the script to ignore files under
  6243. a certain size.
  6244. The previous example filters out any files below 100 Kbytes.
  6245. The sizes reported by the tool are uncompressed, and thus
  6246. will be smaller by a relatively constant factor in a
  6247. compressed root filesystem.
  6248. When you examine your log file, you can focus on areas of the
  6249. root filesystem that take up large amounts of memory.
  6250. </para>
  6251. <para>
  6252. You need to be sure that what you eliminate does not cripple
  6253. the functionality you need.
  6254. One way to see how packages relate to each other is by using
  6255. the Dependency Explorer UI with the BitBake command:
  6256. <literallayout class='monospaced'>
  6257. $ cd <replaceable>image-directory</replaceable>
  6258. $ bitbake -u taskexp -g <replaceable>image</replaceable>
  6259. </literallayout>
  6260. Use the interface to select potential packages you wish to
  6261. eliminate and see their dependency relationships.
  6262. </para>
  6263. <para>
  6264. When deciding how to reduce the size, get rid of packages that
  6265. result in minimal impact on the feature set.
  6266. For example, you might not need a VGA display.
  6267. Or, you might be able to get by with <filename>devtmpfs</filename>
  6268. and <filename>mdev</filename> instead of
  6269. <filename>udev</filename>.
  6270. </para>
  6271. <para>
  6272. Use your <filename>local.conf</filename> file to make changes.
  6273. For example, to eliminate <filename>udev</filename> and
  6274. <filename>glib</filename>, set the following in the
  6275. local configuration file:
  6276. <literallayout class='monospaced'>
  6277. VIRTUAL-RUNTIME_dev_manager = ""
  6278. </literallayout>
  6279. </para>
  6280. <para>
  6281. Finally, you should consider exactly the type of root
  6282. filesystem you need to meet your needs while also reducing
  6283. its size.
  6284. For example, consider <filename>cramfs</filename>,
  6285. <filename>squashfs</filename>, <filename>ubifs</filename>,
  6286. <filename>ext2</filename>, or an <filename>initramfs</filename>
  6287. using <filename>initramfs</filename>.
  6288. Be aware that <filename>ext3</filename> requires a 1 Mbyte
  6289. journal.
  6290. If you are okay with running read-only, you do not need this
  6291. journal.
  6292. </para>
  6293. <note>
  6294. After each round of elimination, you need to rebuild your
  6295. system and then use the tools to see the effects of your
  6296. reductions.
  6297. </note>
  6298. </section>
  6299. <section id='trim-the-kernel'>
  6300. <title>Trim the Kernel</title>
  6301. <para>
  6302. The kernel is built by including policies for hardware-independent
  6303. aspects.
  6304. What subsystems do you enable?
  6305. For what architecture are you building?
  6306. Which drivers do you build by default?
  6307. <note>You can modify the kernel source if you want to help
  6308. with boot time.
  6309. </note>
  6310. </para>
  6311. <para>
  6312. Run the <filename>ksize.py</filename> script from the top-level
  6313. Linux build directory to get an idea of what is making up
  6314. the kernel:
  6315. <literallayout class='monospaced'>
  6316. $ cd <replaceable>top-level-linux-build-directory</replaceable>
  6317. $ ksize.py > ksize.log
  6318. $ cat ksize.log
  6319. </literallayout>
  6320. When you examine the log, you will see how much space is
  6321. taken up with the built-in <filename>.o</filename> files for
  6322. drivers, networking, core kernel files, filesystem, sound,
  6323. and so forth.
  6324. The sizes reported by the tool are uncompressed, and thus
  6325. will be smaller by a relatively constant factor in a compressed
  6326. kernel image.
  6327. Look to reduce the areas that are large and taking up around
  6328. the "90% rule."
  6329. </para>
  6330. <para>
  6331. To examine, or drill down, into any particular area, use the
  6332. <filename>-d</filename> option with the script:
  6333. <literallayout class='monospaced'>
  6334. $ ksize.py -d > ksize.log
  6335. </literallayout>
  6336. Using this option breaks out the individual file information
  6337. for each area of the kernel (e.g. drivers, networking, and
  6338. so forth).
  6339. </para>
  6340. <para>
  6341. Use your log file to see what you can eliminate from the kernel
  6342. based on features you can let go.
  6343. For example, if you are not going to need sound, you do not
  6344. need any drivers that support sound.
  6345. </para>
  6346. <para>
  6347. After figuring out what to eliminate, you need to reconfigure
  6348. the kernel to reflect those changes during the next build.
  6349. You could run <filename>menuconfig</filename> and make all your
  6350. changes at once.
  6351. However, that makes it difficult to see the effects of your
  6352. individual eliminations and also makes it difficult to replicate
  6353. the changes for perhaps another target device.
  6354. A better method is to start with no configurations using
  6355. <filename>allnoconfig</filename>, create configuration
  6356. fragments for individual changes, and then manage the
  6357. fragments into a single configuration file using
  6358. <filename>merge_config.sh</filename>.
  6359. The tool makes it easy for you to iterate using the
  6360. configuration change and build cycle.
  6361. </para>
  6362. <para>
  6363. Each time you make configuration changes, you need to rebuild
  6364. the kernel and check to see what impact your changes had on
  6365. the overall size.
  6366. </para>
  6367. </section>
  6368. <section id='remove-package-management-requirements'>
  6369. <title>Remove Package Management Requirements</title>
  6370. <para>
  6371. Packaging requirements add size to the image.
  6372. One way to reduce the size of the image is to remove all the
  6373. packaging requirements from the image.
  6374. This reduction includes both removing the package manager
  6375. and its unique dependencies as well as removing the package
  6376. management data itself.
  6377. </para>
  6378. <para>
  6379. To eliminate all the packaging requirements for an image,
  6380. be sure that "package-management" is not part of your
  6381. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  6382. statement for the image.
  6383. When you remove this feature, you are removing the package
  6384. manager as well as its dependencies from the root filesystem.
  6385. </para>
  6386. </section>
  6387. <section id='look-for-other-ways-to-minimize-size'>
  6388. <title>Look for Other Ways to Minimize Size</title>
  6389. <para>
  6390. Depending on your particular circumstances, other areas that you
  6391. can trim likely exist.
  6392. The key to finding these areas is through tools and methods
  6393. described here combined with experimentation and iteration.
  6394. Here are a couple of areas to experiment with:
  6395. <itemizedlist>
  6396. <listitem><para><filename>glibc</filename>:
  6397. In general, follow this process:
  6398. <orderedlist>
  6399. <listitem><para>Remove <filename>glibc</filename>
  6400. features from
  6401. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6402. that you think you do not need.</para></listitem>
  6403. <listitem><para>Build your distribution.
  6404. </para></listitem>
  6405. <listitem><para>If the build fails due to missing
  6406. symbols in a package, determine if you can
  6407. reconfigure the package to not need those
  6408. features.
  6409. For example, change the configuration to not
  6410. support wide character support as is done for
  6411. <filename>ncurses</filename>.
  6412. Or, if support for those characters is needed,
  6413. determine what <filename>glibc</filename>
  6414. features provide the support and restore the
  6415. configuration.
  6416. </para></listitem>
  6417. <listitem><para>Rebuild and repeat the process.
  6418. </para></listitem>
  6419. </orderedlist></para></listitem>
  6420. <listitem><para><filename>busybox</filename>:
  6421. For BusyBox, use a process similar as described for
  6422. <filename>glibc</filename>.
  6423. A difference is you will need to boot the resulting
  6424. system to see if you are able to do everything you
  6425. expect from the running system.
  6426. You need to be sure to integrate configuration fragments
  6427. into Busybox because BusyBox handles its own core
  6428. features and then allows you to add configuration
  6429. fragments on top.
  6430. </para></listitem>
  6431. </itemizedlist>
  6432. </para>
  6433. </section>
  6434. <section id='iterate-on-the-process'>
  6435. <title>Iterate on the Process</title>
  6436. <para>
  6437. If you have not reached your goals on system size, you need
  6438. to iterate on the process.
  6439. The process is the same.
  6440. Use the tools and see just what is taking up 90% of the root
  6441. filesystem and the kernel.
  6442. Decide what you can eliminate without limiting your device
  6443. beyond what you need.
  6444. </para>
  6445. <para>
  6446. Depending on your system, a good place to look might be
  6447. Busybox, which provides a stripped down
  6448. version of Unix tools in a single, executable file.
  6449. You might be able to drop virtual terminal services or perhaps
  6450. ipv6.
  6451. </para>
  6452. </section>
  6453. </section>
  6454. <section id='building-images-for-more-than-one-machine'>
  6455. <title>Building Images for More than One Machine</title>
  6456. <para>
  6457. A common scenario developers face is creating images for several
  6458. different machines that use the same software environment.
  6459. In this situation, it is tempting to set the
  6460. tunings and optimization flags for each build specifically for
  6461. the targeted hardware (i.e. "maxing out" the tunings).
  6462. Doing so can considerably add to build times and package feed
  6463. maintenance collectively for the machines.
  6464. For example, selecting tunes that are extremely specific to a
  6465. CPU core used in a system might enable some micro optimizations
  6466. in GCC for that particular system but would otherwise not gain
  6467. you much of a performance difference across the other systems
  6468. as compared to using a more general tuning across all the builds
  6469. (e.g. setting
  6470. <ulink url='var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink>
  6471. specifically for each machine's build).
  6472. Rather than "max out" each build's tunings, you can take steps that
  6473. cause the OpenEmbedded build system to reuse software across the
  6474. various machines where it makes sense.
  6475. </para>
  6476. <para>
  6477. If build speed and package feed maintenance are considerations,
  6478. you should consider the points in this section that can help you
  6479. optimize your tunings to best consider build times and package
  6480. feed maintenance.
  6481. <itemizedlist>
  6482. <listitem><para><emphasis>Share the Build Directory:</emphasis>
  6483. If at all possible, share the
  6484. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  6485. across builds.
  6486. The Yocto Project supports switching between different
  6487. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6488. values in the same <filename>TMPDIR</filename>.
  6489. This practice is well supported and regularly used by
  6490. developers when building for multiple machines.
  6491. When you use the same <filename>TMPDIR</filename> for
  6492. multiple machine builds, the OpenEmbedded build system can
  6493. reuse the existing native and often cross-recipes for
  6494. multiple machines.
  6495. Thus, build time decreases.
  6496. <note>
  6497. If
  6498. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6499. settings change or fundamental configuration settings
  6500. such as the filesystem layout, you need to work with
  6501. a clean <filename>TMPDIR</filename>.
  6502. Sharing <filename>TMPDIR</filename> under these
  6503. circumstances might work but since it is not
  6504. guaranteed, you should use a clean
  6505. <filename>TMPDIR</filename>.
  6506. </note>
  6507. </para></listitem>
  6508. <listitem><para><emphasis>Enable the Appropriate Package Architecture:</emphasis>
  6509. By default, the OpenEmbedded build system enables three
  6510. levels of package architectures: "all", "tune" or "package",
  6511. and "machine".
  6512. Any given recipe usually selects one of these package
  6513. architectures (types) for its output.
  6514. Depending for what a given recipe creates packages, making
  6515. sure you enable the appropriate package architecture can
  6516. directly impact the build time.</para>
  6517. <para>A recipe that just generates scripts can enable
  6518. "all" architecture because there are no binaries to build.
  6519. To specifically enable "all" architecture, be sure your
  6520. recipe inherits the
  6521. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  6522. class.
  6523. This class is useful for "all" architectures because it
  6524. configures many variables so packages can be used across
  6525. multiple architectures.</para>
  6526. <para>If your recipe needs to generate packages that are
  6527. machine-specific or when one of the build or runtime
  6528. dependencies is already machine-architecture dependent,
  6529. which makes your recipe also machine-architecture dependent,
  6530. make sure your recipe enables the "machine" package
  6531. architecture through the
  6532. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>
  6533. variable:
  6534. <literallayout class='monospaced'>
  6535. PACKAGE_ARCH = "${MACHINE_ARCH}"
  6536. </literallayout>
  6537. When you do not specifically enable a package
  6538. architecture through the
  6539. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>,
  6540. The OpenEmbedded build system defaults to the
  6541. <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink>
  6542. setting:
  6543. <literallayout class='monospaced'>
  6544. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  6545. </literallayout>
  6546. </para></listitem>
  6547. <listitem><para><emphasis>Choose a Generic Tuning File if Possible:</emphasis>
  6548. Some tunes are more generic and can run on multiple targets
  6549. (e.g. an <filename>armv5</filename> set of packages could
  6550. run on <filename>armv6</filename> and
  6551. <filename>armv7</filename> processors in most cases).
  6552. Similarly, <filename>i486</filename> binaries could work
  6553. on <filename>i586</filename> and higher processors.
  6554. You should realize, however, that advances on newer
  6555. processor versions would not be used.</para>
  6556. <para>If you select the same tune for several different
  6557. machines, the OpenEmbedded build system reuses software
  6558. previously built, thus speeding up the overall build time.
  6559. Realize that even though a new sysroot for each machine is
  6560. generated, the software is not recompiled and only one
  6561. package feed exists.
  6562. </para></listitem>
  6563. <listitem><para><emphasis>Manage Granular Level Packaging:</emphasis>
  6564. Sometimes cases exist where injecting another level
  6565. of package architecture beyond the three higher levels
  6566. noted earlier can be useful.
  6567. For example, consider the <filename>emgd</filename>
  6568. graphics stack in the
  6569. <filename>meta-intel</filename> layer.
  6570. In this layer, a subset of software exists that is
  6571. compiled against something different from the rest of the
  6572. generic packages.
  6573. You can examine the key code in the
  6574. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Source Repositories</ulink>
  6575. "daisy" branch in
  6576. <filename>classes/emgd-gl.bbclass</filename>.
  6577. For a specific set of packages, the code redefines
  6578. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>.
  6579. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXTRA_ARCHS'><filename>PACKAGE_EXTRA_ARCHS</filename></ulink>
  6580. is then appended with this extra tune name in
  6581. <filename>meta-intel-emgd.inc</filename>.
  6582. The result is that when searching for packages, the
  6583. build system uses a four-level search and the packages
  6584. in this new level are preferred as compared to the standard
  6585. tune.
  6586. The overall result is that the build system reuses most
  6587. software from the common tune except for specific cases
  6588. as needed.
  6589. </para></listitem>
  6590. <listitem><para><emphasis>Use Tools to Debug Issues:</emphasis>
  6591. Sometimes you can run into situations where software is
  6592. being rebuilt when you think it should not be.
  6593. For example, the OpenEmbedded build system might not be
  6594. using shared state between machines when you think it
  6595. should be.
  6596. These types of situations are usually due to references
  6597. to machine-specific variables such as
  6598. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  6599. <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLE'><filename>SERIAL_CONSOLE</filename></ulink>,
  6600. <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>,
  6601. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>,
  6602. and so forth in code that is supposed to only be
  6603. tune-specific or when the recipe depends
  6604. (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  6605. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  6606. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  6607. <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>,
  6608. and so forth) on some other recipe that already has
  6609. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>
  6610. defined as "${MACHINE_ARCH}".
  6611. <note>
  6612. Patches to fix any issues identified are most welcome
  6613. as these issues occasionally do occur.
  6614. </note></para>
  6615. <para>For such cases, you can use some tools to help you
  6616. sort out the situation:
  6617. <itemizedlist>
  6618. <listitem><para><emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis>
  6619. You can find this tool in the
  6620. <filename>scripts</filename> directory of the
  6621. Source Repositories.
  6622. See the comments in the script for information on
  6623. how to use the tool.
  6624. </para></listitem>
  6625. <listitem><para><emphasis>BitBake's "-S printdiff" Option:</emphasis>
  6626. Using this option causes BitBake to try to
  6627. establish the closest signature match it can
  6628. (e.g. in the shared state cache) and then run
  6629. <filename>bitbake-diffsigs</filename> over the
  6630. matches to determine the stamps and delta where
  6631. these two stamp trees diverge.
  6632. </para></listitem>
  6633. </itemizedlist>
  6634. </para></listitem>
  6635. </itemizedlist>
  6636. </para>
  6637. </section>
  6638. <section id='working-with-packages'>
  6639. <title>Working with Packages</title>
  6640. <para>
  6641. This section describes a few tasks that involve packages:
  6642. <itemizedlist>
  6643. <listitem><para>
  6644. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  6645. </para></listitem>
  6646. <listitem><para>
  6647. <link linkend='incrementing-a-binary-package-version'>Incrementing a binary package version</link>
  6648. </para></listitem>
  6649. <listitem><para>
  6650. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  6651. </para></listitem>
  6652. <listitem><para>
  6653. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  6654. </para></listitem>
  6655. <listitem><para>
  6656. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  6657. </para></listitem>
  6658. </itemizedlist>
  6659. </para>
  6660. <section id='excluding-packages-from-an-image'>
  6661. <title>Excluding Packages from an Image</title>
  6662. <para>
  6663. You might find it necessary to prevent specific packages
  6664. from being installed into an image.
  6665. If so, you can use several variables to direct the build
  6666. system to essentially ignore installing recommended packages
  6667. or to not install a package at all.
  6668. </para>
  6669. <para>
  6670. The following list introduces variables you can use to
  6671. prevent packages from being installed into your image.
  6672. Each of these variables only works with IPK and RPM
  6673. package types.
  6674. Support for Debian packages does not exist.
  6675. Also, you can use these variables from your
  6676. <filename>local.conf</filename> file or attach them to a
  6677. specific image recipe by using a recipe name override.
  6678. For more detail on the variables, see the descriptions in the
  6679. Yocto Project Reference Manual's glossary chapter.
  6680. <itemizedlist>
  6681. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  6682. Use this variable to specify "recommended-only"
  6683. packages that you do not want installed.
  6684. </para></listitem>
  6685. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  6686. Use this variable to prevent all "recommended-only"
  6687. packages from being installed.
  6688. </para></listitem>
  6689. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  6690. Use this variable to prevent specific packages from
  6691. being installed regardless of whether they are
  6692. "recommended-only" or not.
  6693. You need to realize that the build process could
  6694. fail with an error when you
  6695. prevent the installation of a package whose presence
  6696. is required by an installed package.
  6697. </para></listitem>
  6698. </itemizedlist>
  6699. </para>
  6700. </section>
  6701. <section id='incrementing-a-binary-package-version'>
  6702. <title>Incrementing a Package Version</title>
  6703. <para>
  6704. This section provides some background on how binary package
  6705. versioning is accomplished and presents some of the services,
  6706. variables, and terminology involved.
  6707. </para>
  6708. <para>
  6709. In order to understand binary package versioning, you need
  6710. to consider the following:
  6711. <itemizedlist>
  6712. <listitem><para>
  6713. Binary Package: The binary package that is eventually
  6714. built and installed into an image.
  6715. </para></listitem>
  6716. <listitem><para>
  6717. Binary Package Version: The binary package version
  6718. is composed of two components - a version and a
  6719. revision.
  6720. <note>
  6721. Technically, a third component, the "epoch" (i.e.
  6722. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>)
  6723. is involved but this discussion for the most part
  6724. ignores <filename>PE</filename>.
  6725. </note>
  6726. The version and revision are taken from the
  6727. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  6728. and
  6729. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  6730. variables, respectively.
  6731. </para></listitem>
  6732. <listitem><para>
  6733. <filename>PV</filename>: The recipe version.
  6734. <filename>PV</filename> represents the version of the
  6735. software being packaged.
  6736. Do not confuse <filename>PV</filename> with the
  6737. binary package version.
  6738. </para></listitem>
  6739. <listitem><para>
  6740. <filename>PR</filename>: The recipe revision.
  6741. </para></listitem>
  6742. <listitem><para>
  6743. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>:
  6744. The OpenEmbedded build system uses this string
  6745. to help define the value of <filename>PV</filename>
  6746. when the source code revision needs to be included
  6747. in it.
  6748. </para></listitem>
  6749. <listitem><para>
  6750. <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>:
  6751. A network-based service that helps automate keeping
  6752. package feeds compatible with existing package
  6753. manager applications such as RPM, APT, and OPKG.
  6754. </para></listitem>
  6755. </itemizedlist>
  6756. </para>
  6757. <para>
  6758. Whenever the binary package content changes, the binary package
  6759. version must change.
  6760. Changing the binary package version is accomplished by changing
  6761. or "bumping" the <filename>PR</filename> and/or
  6762. <filename>PV</filename> values.
  6763. Increasing these values occurs one of two ways:
  6764. <itemizedlist>
  6765. <listitem><para>Automatically using a Package Revision
  6766. Service (PR Service).
  6767. </para></listitem>
  6768. <listitem><para>Manually incrementing the
  6769. <filename>PR</filename> and/or
  6770. <filename>PV</filename> variables.
  6771. </para></listitem>
  6772. </itemizedlist>
  6773. </para>
  6774. <para>
  6775. Given a primary challenge of any build system and its users
  6776. is how to maintain a package feed that is compatible with
  6777. existing package manager applications such as RPM, APT, and
  6778. OPKG, using an automated system is much preferred over a
  6779. manual system.
  6780. In either system, the main requirement is that binary package
  6781. version numbering increases in a linear fashion and that a
  6782. number of version components exist that support that linear
  6783. progression.
  6784. For information on how to ensure package revisioning remains
  6785. linear, see the
  6786. "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>"
  6787. section.
  6788. </para>
  6789. <para>
  6790. The following three sections provide related information on the
  6791. PR Service, the manual method for "bumping"
  6792. <filename>PR</filename> and/or <filename>PV</filename>, and
  6793. on how to ensure binary package revisioning remains linear.
  6794. </para>
  6795. <section id='working-with-a-pr-service'>
  6796. <title>Working With a PR Service</title>
  6797. <para>
  6798. As mentioned, attempting to maintain revision numbers in the
  6799. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  6800. is error prone, inaccurate, and causes problems for people
  6801. submitting recipes.
  6802. Conversely, the PR Service automatically generates
  6803. increasing numbers, particularly the revision field,
  6804. which removes the human element.
  6805. <note>
  6806. For additional information on using a PR Service, you
  6807. can see the
  6808. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  6809. wiki page.
  6810. </note>
  6811. </para>
  6812. <para>
  6813. The Yocto Project uses variables in order of
  6814. decreasing priority to facilitate revision numbering (i.e.
  6815. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  6816. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  6817. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  6818. for epoch, version, and revision, respectively).
  6819. The values are highly dependent on the policies and
  6820. procedures of a given distribution and package feed.
  6821. </para>
  6822. <para>
  6823. Because the OpenEmbedded build system uses
  6824. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#overview-checksums'>signatures</ulink>",
  6825. which are unique to a given build, the build system
  6826. knows when to rebuild packages.
  6827. All the inputs into a given task are represented by a
  6828. signature, which can trigger a rebuild when different.
  6829. Thus, the build system itself does not rely on the
  6830. <filename>PR</filename>, <filename>PV</filename>, and
  6831. <filename>PE</filename> numbers to trigger a rebuild.
  6832. The signatures, however, can be used to generate
  6833. these values.
  6834. </para>
  6835. <para>
  6836. The PR Service works with both
  6837. <filename>OEBasic</filename> and
  6838. <filename>OEBasicHash</filename> generators.
  6839. The value of <filename>PR</filename> bumps when the
  6840. checksum changes and the different generator mechanisms
  6841. change signatures under different circumstances.
  6842. </para>
  6843. <para>
  6844. As implemented, the build system includes values from
  6845. the PR Service into the <filename>PR</filename> field as
  6846. an addition using the form "<filename>.x</filename>" so
  6847. <filename>r0</filename> becomes <filename>r0.1</filename>,
  6848. <filename>r0.2</filename> and so forth.
  6849. This scheme allows existing <filename>PR</filename> values
  6850. to be used for whatever reasons, which include manual
  6851. <filename>PR</filename> bumps, should it be necessary.
  6852. </para>
  6853. <para>
  6854. By default, the PR Service is not enabled or running.
  6855. Thus, the packages generated are just "self consistent".
  6856. The build system adds and removes packages and
  6857. there are no guarantees about upgrade paths but images
  6858. will be consistent and correct with the latest changes.
  6859. </para>
  6860. <para>
  6861. The simplest form for a PR Service is for it to exist
  6862. for a single host development system that builds the
  6863. package feed (building system).
  6864. For this scenario, you can enable a local PR Service by
  6865. setting
  6866. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  6867. in your <filename>local.conf</filename> file in the
  6868. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  6869. <literallayout class='monospaced'>
  6870. PRSERV_HOST = "localhost:0"
  6871. </literallayout>
  6872. Once the service is started, packages will automatically
  6873. get increasing <filename>PR</filename> values and
  6874. BitBake takes care of starting and stopping the server.
  6875. </para>
  6876. <para>
  6877. If you have a more complex setup where multiple host
  6878. development systems work against a common, shared package
  6879. feed, you have a single PR Service running and it is
  6880. connected to each building system.
  6881. For this scenario, you need to start the PR Service using
  6882. the <filename>bitbake-prserv</filename> command:
  6883. <literallayout class='monospaced'>
  6884. bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start
  6885. </literallayout>
  6886. In addition to hand-starting the service, you need to
  6887. update the <filename>local.conf</filename> file of each
  6888. building system as described earlier so each system
  6889. points to the server and port.
  6890. </para>
  6891. <para>
  6892. It is also recommended you use build history, which adds
  6893. some sanity checks to binary package versions, in
  6894. conjunction with the server that is running the PR Service.
  6895. To enable build history, add the following to each building
  6896. system's <filename>local.conf</filename> file:
  6897. <literallayout class='monospaced'>
  6898. # It is recommended to activate "buildhistory" for testing the PR service
  6899. INHERIT += "buildhistory"
  6900. BUILDHISTORY_COMMIT = "1"
  6901. </literallayout>
  6902. For information on build history, see the
  6903. "<link linkend='maintaining-build-output-quality'>Maintaining Build Output Quality</link>"
  6904. section.
  6905. </para>
  6906. <note>
  6907. <para>
  6908. The OpenEmbedded build system does not maintain
  6909. <filename>PR</filename> information as part of the
  6910. shared state (sstate) packages.
  6911. If you maintain an sstate feed, its expected that either
  6912. all your building systems that contribute to the sstate
  6913. feed use a shared PR Service, or you do not run a PR
  6914. Service on any of your building systems.
  6915. Having some systems use a PR Service while others do
  6916. not leads to obvious problems.
  6917. </para>
  6918. <para>
  6919. For more information on shared state, see the
  6920. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#shared-state-cache'>Shared State Cache</ulink>"
  6921. section in the Yocto Project Overview Manual.
  6922. </para>
  6923. </note>
  6924. </section>
  6925. <section id='manually-bumping-pr'>
  6926. <title>Manually Bumping PR</title>
  6927. <para>
  6928. The alternative to setting up a PR Service is to manually
  6929. "bump" the
  6930. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  6931. variable.
  6932. </para>
  6933. <para>
  6934. If a committed change results in changing the package
  6935. output, then the value of the PR variable needs to be
  6936. increased (or "bumped") as part of that commit.
  6937. For new recipes you should add the <filename>PR</filename>
  6938. variable and set its initial value equal to "r0", which is
  6939. the default.
  6940. Even though the default value is "r0", the practice of
  6941. adding it to a new recipe makes it harder to forget to bump
  6942. the variable when you make changes to the recipe in future.
  6943. </para>
  6944. <para>
  6945. If you are sharing a common <filename>.inc</filename> file
  6946. with multiple recipes, you can also use the
  6947. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  6948. variable to ensure that the recipes sharing the
  6949. <filename>.inc</filename> file are rebuilt when the
  6950. <filename>.inc</filename> file itself is changed.
  6951. The <filename>.inc</filename> file must set
  6952. <filename>INC_PR</filename> (initially to "r0"), and all
  6953. recipes referring to it should set <filename>PR</filename>
  6954. to "${INC_PR}.0" initially, incrementing the last number
  6955. when the recipe is changed.
  6956. If the <filename>.inc</filename> file is changed then its
  6957. <filename>INC_PR</filename> should be incremented.
  6958. </para>
  6959. <para>
  6960. When upgrading the version of a binary package, assuming the
  6961. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  6962. changes, the <filename>PR</filename> variable should be
  6963. reset to "r0" (or "${INC_PR}.0" if you are using
  6964. <filename>INC_PR</filename>).
  6965. </para>
  6966. <para>
  6967. Usually, version increases occur only to binary packages.
  6968. However, if for some reason <filename>PV</filename> changes
  6969. but does not increase, you can increase the
  6970. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  6971. variable (Package Epoch).
  6972. The <filename>PE</filename> variable defaults to "0".
  6973. </para>
  6974. <para>
  6975. Binary package version numbering strives to follow the
  6976. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  6977. Debian Version Field Policy Guidelines</ulink>.
  6978. These guidelines define how versions are compared and what
  6979. "increasing" a version means.
  6980. </para>
  6981. </section>
  6982. <section id='automatically-incrementing-a-binary-package-revision-number'>
  6983. <title>Automatically Incrementing a Package Version Number</title>
  6984. <para>
  6985. When fetching a repository, BitBake uses the
  6986. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  6987. variable to determine the specific source code revision
  6988. from which to build.
  6989. You set the <filename>SRCREV</filename> variable to
  6990. <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>
  6991. to cause the OpenEmbedded build system to automatically use the
  6992. latest revision of the software:
  6993. <literallayout class='monospaced'>
  6994. SRCREV = "${AUTOREV}"
  6995. </literallayout>
  6996. </para>
  6997. <para>
  6998. Furthermore, you need to reference <filename>SRCPV</filename>
  6999. in <filename>PV</filename> in order to automatically update
  7000. the version whenever the revision of the source code
  7001. changes.
  7002. Here is an example:
  7003. <literallayout class='monospaced'>
  7004. PV = "1.0+git${SRCPV}"
  7005. </literallayout>
  7006. The OpenEmbedded build system substitutes
  7007. <filename>SRCPV</filename> with the following:
  7008. <literallayout class='monospaced'>
  7009. AUTOINC+<replaceable>source_code_revision</replaceable>
  7010. </literallayout>
  7011. The build system replaces the <filename>AUTOINC</filename> with
  7012. a number.
  7013. The number used depends on the state of the PR Service:
  7014. <itemizedlist>
  7015. <listitem><para>
  7016. If PR Service is enabled, the build system increments
  7017. the number, which is similar to the behavior of
  7018. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>.
  7019. This behavior results in linearly increasing package
  7020. versions, which is desirable.
  7021. Here is an example:
  7022. <literallayout class='monospaced'>
  7023. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  7024. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  7025. </literallayout>
  7026. </para></listitem>
  7027. <listitem><para>
  7028. If PR Service is not enabled, the build system
  7029. replaces the <filename>AUTOINC</filename>
  7030. placeholder with zero (i.e. "0").
  7031. This results in changing the package version since
  7032. the source revision is included.
  7033. However, package versions are not increased linearly.
  7034. Here is an example:
  7035. <literallayout class='monospaced'>
  7036. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  7037. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  7038. </literallayout>
  7039. </para></listitem>
  7040. </itemizedlist>
  7041. </para>
  7042. <para>
  7043. In summary, the OpenEmbedded build system does not track the
  7044. history of binary package versions for this purpose.
  7045. <filename>AUTOINC</filename>, in this case, is comparable to
  7046. <filename>PR</filename>.
  7047. If PR server is not enabled, <filename>AUTOINC</filename>
  7048. in the package version is simply replaced by "0".
  7049. If PR server is enabled, the build system keeps track of the
  7050. package versions and bumps the number when the package
  7051. revision changes.
  7052. </para>
  7053. </section>
  7054. </section>
  7055. <section id='handling-optional-module-packaging'>
  7056. <title>Handling Optional Module Packaging</title>
  7057. <para>
  7058. Many pieces of software split functionality into optional
  7059. modules (or plug-ins) and the plug-ins that are built
  7060. might depend on configuration options.
  7061. To avoid having to duplicate the logic that determines what
  7062. modules are available in your recipe or to avoid having
  7063. to package each module by hand, the OpenEmbedded build system
  7064. provides functionality to handle module packaging dynamically.
  7065. </para>
  7066. <para>
  7067. To handle optional module packaging, you need to do two things:
  7068. <itemizedlist>
  7069. <listitem><para>Ensure the module packaging is actually
  7070. done.</para></listitem>
  7071. <listitem><para>Ensure that any dependencies on optional
  7072. modules from other recipes are satisfied by your recipe.
  7073. </para></listitem>
  7074. </itemizedlist>
  7075. </para>
  7076. <section id='making-sure-the-packaging-is-done'>
  7077. <title>Making Sure the Packaging is Done</title>
  7078. <para>
  7079. To ensure the module packaging actually gets done, you use
  7080. the <filename>do_split_packages</filename> function within
  7081. the <filename>populate_packages</filename> Python function
  7082. in your recipe.
  7083. The <filename>do_split_packages</filename> function
  7084. searches for a pattern of files or directories under a
  7085. specified path and creates a package for each one it finds
  7086. by appending to the
  7087. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  7088. variable and setting the appropriate values for
  7089. <filename>FILES_packagename</filename>,
  7090. <filename>RDEPENDS_packagename</filename>,
  7091. <filename>DESCRIPTION_packagename</filename>, and so forth.
  7092. Here is an example from the <filename>lighttpd</filename>
  7093. recipe:
  7094. <literallayout class='monospaced'>
  7095. python populate_packages_prepend () {
  7096. lighttpd_libdir = d.expand('${libdir}')
  7097. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  7098. 'lighttpd-module-%s', 'Lighttpd module for %s',
  7099. extra_depends='')
  7100. }
  7101. </literallayout>
  7102. The previous example specifies a number of things in the
  7103. call to <filename>do_split_packages</filename>.
  7104. <itemizedlist>
  7105. <listitem><para>A directory within the files installed
  7106. by your recipe through <filename>do_install</filename>
  7107. in which to search.</para></listitem>
  7108. <listitem><para>A regular expression used to match module
  7109. files in that directory.
  7110. In the example, note the parentheses () that mark
  7111. the part of the expression from which the module
  7112. name should be derived.</para></listitem>
  7113. <listitem><para>A pattern to use for the package names.
  7114. </para></listitem>
  7115. <listitem><para>A description for each package.
  7116. </para></listitem>
  7117. <listitem><para>An empty string for
  7118. <filename>extra_depends</filename>, which disables
  7119. the default dependency on the main
  7120. <filename>lighttpd</filename> package.
  7121. Thus, if a file in <filename>${libdir}</filename>
  7122. called <filename>mod_alias.so</filename> is found,
  7123. a package called <filename>lighttpd-module-alias</filename>
  7124. is created for it and the
  7125. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  7126. is set to "Lighttpd module for alias".</para></listitem>
  7127. </itemizedlist>
  7128. </para>
  7129. <para>
  7130. Often, packaging modules is as simple as the previous
  7131. example.
  7132. However, more advanced options exist that you can use
  7133. within <filename>do_split_packages</filename> to modify its
  7134. behavior.
  7135. And, if you need to, you can add more logic by specifying
  7136. a hook function that is called for each package.
  7137. It is also perfectly acceptable to call
  7138. <filename>do_split_packages</filename> multiple times if
  7139. you have more than one set of modules to package.
  7140. </para>
  7141. <para>
  7142. For more examples that show how to use
  7143. <filename>do_split_packages</filename>, see the
  7144. <filename>connman.inc</filename> file in the
  7145. <filename>meta/recipes-connectivity/connman/</filename>
  7146. directory of the <filename>poky</filename>
  7147. <ulink url='&YOCTO_DOCS_OVERVIEW_URL;#yocto-project-repositories'>source repository</ulink>.
  7148. You can also find examples in
  7149. <filename>meta/classes/kernel.bbclass</filename>.
  7150. </para>
  7151. <para>
  7152. Following is a reference that shows
  7153. <filename>do_split_packages</filename> mandatory and
  7154. optional arguments:
  7155. <literallayout class='monospaced'>
  7156. Mandatory arguments
  7157. root
  7158. The path in which to search
  7159. file_regex
  7160. Regular expression to match searched files.
  7161. Use parentheses () to mark the part of this
  7162. expression that should be used to derive the
  7163. module name (to be substituted where %s is
  7164. used in other function arguments as noted below)
  7165. output_pattern
  7166. Pattern to use for the package names. Must
  7167. include %s.
  7168. description
  7169. Description to set for each package. Must
  7170. include %s.
  7171. Optional arguments
  7172. postinst
  7173. Postinstall script to use for all packages
  7174. (as a string)
  7175. recursive
  7176. True to perform a recursive search - default
  7177. False
  7178. hook
  7179. A hook function to be called for every match.
  7180. The function will be called with the following
  7181. arguments (in the order listed):
  7182. f
  7183. Full path to the file/directory match
  7184. pkg
  7185. The package name
  7186. file_regex
  7187. As above
  7188. output_pattern
  7189. As above
  7190. modulename
  7191. The module name derived using file_regex
  7192. extra_depends
  7193. Extra runtime dependencies (RDEPENDS) to be
  7194. set for all packages. The default value of None
  7195. causes a dependency on the main package
  7196. (${PN}) - if you do not want this, pass empty
  7197. string '' for this parameter.
  7198. aux_files_pattern
  7199. Extra item(s) to be added to FILES for each
  7200. package. Can be a single string item or a list
  7201. of strings for multiple items. Must include %s.
  7202. postrm
  7203. postrm script to use for all packages (as a
  7204. string)
  7205. allow_dirs
  7206. True to allow directories to be matched -
  7207. default False
  7208. prepend
  7209. If True, prepend created packages to PACKAGES
  7210. instead of the default False which appends them
  7211. match_path
  7212. match file_regex on the whole relative path to
  7213. the root rather than just the file name
  7214. aux_files_pattern_verbatim
  7215. Extra item(s) to be added to FILES for each
  7216. package, using the actual derived module name
  7217. rather than converting it to something legal
  7218. for a package name. Can be a single string item
  7219. or a list of strings for multiple items. Must
  7220. include %s.
  7221. allow_links
  7222. True to allow symlinks to be matched - default
  7223. False
  7224. summary
  7225. Summary to set for each package. Must include %s;
  7226. defaults to description if not set.
  7227. </literallayout>
  7228. </para>
  7229. </section>
  7230. <section id='satisfying-dependencies'>
  7231. <title>Satisfying Dependencies</title>
  7232. <para>
  7233. The second part for handling optional module packaging
  7234. is to ensure that any dependencies on optional modules
  7235. from other recipes are satisfied by your recipe.
  7236. You can be sure these dependencies are satisfied by
  7237. using the
  7238. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  7239. Here is an example that continues with the
  7240. <filename>lighttpd</filename> recipe shown earlier:
  7241. <literallayout class='monospaced'>
  7242. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  7243. </literallayout>
  7244. The name specified in the regular expression can of
  7245. course be anything.
  7246. In this example, it is <filename>lighttpd-module-</filename>
  7247. and is specified as the prefix to ensure that any
  7248. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  7249. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  7250. on a package name starting with the prefix are satisfied
  7251. during build time.
  7252. If you are using <filename>do_split_packages</filename>
  7253. as described in the previous section, the value you put in
  7254. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  7255. the name pattern specified in the call to
  7256. <filename>do_split_packages</filename>.
  7257. </para>
  7258. </section>
  7259. </section>
  7260. <section id='using-runtime-package-management'>
  7261. <title>Using Runtime Package Management</title>
  7262. <para>
  7263. During a build, BitBake always transforms a recipe into one or
  7264. more packages.
  7265. For example, BitBake takes the <filename>bash</filename> recipe
  7266. and currently produces the <filename>bash-dbg</filename>,
  7267. <filename>bash-staticdev</filename>,
  7268. <filename>bash-dev</filename>, <filename>bash-doc</filename>,
  7269. <filename>bash-locale</filename>, and
  7270. <filename>bash</filename> packages.
  7271. Not all generated packages are included in an image.
  7272. </para>
  7273. <para>
  7274. In several situations, you might need to update, add, remove,
  7275. or query the packages on a target device at runtime
  7276. (i.e. without having to generate a new image).
  7277. Examples of such situations include:
  7278. <itemizedlist>
  7279. <listitem><para>
  7280. You want to provide in-the-field updates to deployed
  7281. devices (e.g. security updates).
  7282. </para></listitem>
  7283. <listitem><para>
  7284. You want to have a fast turn-around development cycle
  7285. for one or more applications that run on your device.
  7286. </para></listitem>
  7287. <listitem><para>
  7288. You want to temporarily install the "debug" packages
  7289. of various applications on your device so that
  7290. debugging can be greatly improved by allowing
  7291. access to symbols and source debugging.
  7292. </para></listitem>
  7293. <listitem><para>
  7294. You want to deploy a more minimal package selection of
  7295. your device but allow in-the-field updates to add a
  7296. larger selection for customization.
  7297. </para></listitem>
  7298. </itemizedlist>
  7299. </para>
  7300. <para>
  7301. In all these situations, you have something similar to a more
  7302. traditional Linux distribution in that in-field devices
  7303. are able to receive pre-compiled packages from a server for
  7304. installation or update.
  7305. Being able to install these packages on a running,
  7306. in-field device is what is termed "runtime package
  7307. management".
  7308. </para>
  7309. <para>
  7310. In order to use runtime package management, you
  7311. need a host/server machine that serves up the pre-compiled
  7312. packages plus the required metadata.
  7313. You also need package manipulation tools on the target.
  7314. The build machine is a likely candidate to act as the server.
  7315. However, that machine does not necessarily have to be the
  7316. package server.
  7317. The build machine could push its artifacts to another machine
  7318. that acts as the server (e.g. Internet-facing).
  7319. </para>
  7320. <para>
  7321. A simple build that targets just one device produces
  7322. more than one package database.
  7323. In other words, the packages produced by a build are separated
  7324. out into a couple of different package groupings based on
  7325. criteria such as the target's CPU architecture, the target
  7326. board, or the C library used on the target.
  7327. For example, a build targeting the <filename>qemuarm</filename>
  7328. device produces the following three package databases:
  7329. <filename>all</filename>, <filename>armv5te</filename>, and
  7330. <filename>qemuarm</filename>.
  7331. If you wanted your <filename>qemuarm</filename> device to be
  7332. aware of all the packages that were available to it,
  7333. you would need to point it to each of these databases
  7334. individually.
  7335. In a similar way, a traditional Linux distribution usually is
  7336. configured to be aware of a number of software repositories
  7337. from which it retrieves packages.
  7338. </para>
  7339. <para>
  7340. Using runtime package management is completely optional and
  7341. not required for a successful build or deployment in any
  7342. way.
  7343. But if you want to make use of runtime package management,
  7344. you need to do a couple things above and beyond the basics.
  7345. The remainder of this section describes what you need to do.
  7346. </para>
  7347. <section id='runtime-package-management-build'>
  7348. <title>Build Considerations</title>
  7349. <para>
  7350. This section describes build considerations of which you
  7351. need to be aware in order to provide support for runtime
  7352. package management.
  7353. </para>
  7354. <para>
  7355. When BitBake generates packages, it needs to know
  7356. what format or formats to use.
  7357. In your configuration, you use the
  7358. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  7359. variable to specify the format:
  7360. <orderedlist>
  7361. <listitem><para>
  7362. Open the <filename>local.conf</filename> file
  7363. inside your
  7364. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  7365. (e.g. <filename>~/poky/build/conf/local.conf</filename>).
  7366. </para></listitem>
  7367. <listitem><para>
  7368. Select the desired package format as follows:
  7369. <literallayout class='monospaced'>
  7370. PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>”
  7371. </literallayout>
  7372. where <replaceable>packageformat</replaceable>
  7373. can be "ipk", "rpm", and "deb", which are the
  7374. supported package formats.
  7375. <note>
  7376. Because the Yocto Project supports three
  7377. different package formats, you can set the
  7378. variable with more than one argument.
  7379. However, the OpenEmbedded build system only
  7380. uses the first argument when creating an image
  7381. or Software Development Kit (SDK).
  7382. </note>
  7383. </para></listitem>
  7384. </orderedlist>
  7385. </para>
  7386. <para>
  7387. If you would like your image to start off with a basic
  7388. package database containing the packages in your current
  7389. build as well as to have the relevant tools available on the
  7390. target for runtime package management, you can include
  7391. "package-management" in the
  7392. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  7393. variable.
  7394. Including "package-management" in this
  7395. configuration variable ensures that when the image
  7396. is assembled for your target, the image includes
  7397. the currently-known package databases as well as
  7398. the target-specific tools required for runtime
  7399. package management to be performed on the target.
  7400. However, this is not strictly necessary.
  7401. You could start your image off without any databases
  7402. but only include the required on-target package
  7403. tool(s).
  7404. As an example, you could include "opkg" in your
  7405. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  7406. variable if you are using the IPK package format.
  7407. You can then initialize your target's package database(s)
  7408. later once your image is up and running.
  7409. </para>
  7410. <para>
  7411. Whenever you perform any sort of build step that can
  7412. potentially generate a package or modify an existing
  7413. package, it is always a good idea to re-generate the
  7414. package index with:
  7415. <literallayout class='monospaced'>
  7416. $ bitbake package-index
  7417. </literallayout>
  7418. Realize that it is not sufficient to simply do the
  7419. following:
  7420. <literallayout class='monospaced'>
  7421. $ bitbake <replaceable>some-package</replaceable> package-index
  7422. </literallayout>
  7423. The reason for this restriction is because BitBake does not
  7424. properly schedule the <filename>package-index</filename>
  7425. target fully after any other target has completed.
  7426. Thus, be sure to run the package update step separately.
  7427. </para>
  7428. <para>
  7429. You can use the
  7430. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7431. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  7432. and
  7433. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7434. variables to pre-configure target images to use a package
  7435. feed.
  7436. If you do not define these variables, then manual steps
  7437. as described in the subsequent sections are necessary to
  7438. configure the target.
  7439. You should set these variables before building the image
  7440. in order to produce a correctly configured image.
  7441. </para>
  7442. <para>
  7443. When your build is complete, your packages reside in the
  7444. <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename>
  7445. directory.
  7446. For example, if
  7447. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename>
  7448. is <filename>tmp</filename> and your selected package type
  7449. is IPK, then your IPK packages are available in
  7450. <filename>tmp/deploy/ipk</filename>.
  7451. </para>
  7452. </section>
  7453. <section id='runtime-package-management-server'>
  7454. <title>Host or Server Machine Setup</title>
  7455. <para>
  7456. Although other protocols are possible, a server using HTTP
  7457. typically serves packages.
  7458. If you want to use HTTP, then set up and configure a
  7459. web server such as Apache 2, lighttpd, or
  7460. SimpleHTTPServer on the machine serving the packages.
  7461. </para>
  7462. <para>
  7463. To keep things simple, this section describes how to set
  7464. up a SimpleHTTPServer web server to share package feeds
  7465. from the developer's machine.
  7466. Although this server might not be the best for a production
  7467. environment, the setup is simple and straight forward.
  7468. Should you want to use a different server more suited for
  7469. production (e.g. Apache 2, Lighttpd, or Nginx), take the
  7470. appropriate steps to do so.
  7471. </para>
  7472. <para>
  7473. From within the build directory where you have built an
  7474. image based on your packaging choice (i.e. the
  7475. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  7476. setting), simply start the server.
  7477. The following example assumes a build directory of
  7478. <filename>~/poky/build/tmp/deploy/rpm</filename> and a
  7479. <filename>PACKAGE_CLASSES</filename> setting of
  7480. "package_rpm":
  7481. <literallayout class='monospaced'>
  7482. $ cd ~/poky/build/tmp/deploy/rpm
  7483. $ python -m SimpleHTTPServer
  7484. </literallayout>
  7485. </para>
  7486. </section>
  7487. <section id='runtime-package-management-target'>
  7488. <title>Target Setup</title>
  7489. <para>
  7490. Setting up the target differs depending on the
  7491. package management system.
  7492. This section provides information for RPM, IPK, and DEB.
  7493. </para>
  7494. <section id='runtime-package-management-target-rpm'>
  7495. <title>Using RPM</title>
  7496. <para>
  7497. The <filename>dnf</filename> application performs
  7498. runtime package management of RPM packages.
  7499. You must perform an initial setup for
  7500. <filename>dnf</filename> on the target machine
  7501. if the
  7502. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7503. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  7504. and
  7505. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7506. variables have not been set or the target image was
  7507. built before the variables were set.
  7508. </para>
  7509. <para>
  7510. As an example, assume the target is able to use the
  7511. following package databases:
  7512. <filename>all</filename>, <filename>i586</filename>,
  7513. and <filename>qemux86</filename> from a server named
  7514. <filename>my.server</filename>.
  7515. You must inform <filename>dnf</filename> of the
  7516. availability of these databases by creating a
  7517. <filename>/etc/yum.repos.d/oe-packages.repo</filename>
  7518. file with the following content:
  7519. <literallayout class='monospaced'>
  7520. [oe-packages]
  7521. baseurl=http://my.server http://my.server/rpm/qemux86 http://my.server/rpm/all
  7522. </literallayout>
  7523. From the target machine, fetch the repository:
  7524. <literallayout class='monospaced'>
  7525. # dnf makecache
  7526. </literallayout>
  7527. After everything is set up, <filename>dnf</filename>
  7528. is able to find, install, and upgrade packages from
  7529. the specified repository.
  7530. <note>
  7531. See the
  7532. <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink>
  7533. for additional information.
  7534. </note>
  7535. </para>
  7536. </section>
  7537. <section id='runtime-package-management-target-ipk'>
  7538. <title>Using IPK</title>
  7539. <para>
  7540. The <filename>opkg</filename> application performs
  7541. runtime package management of IPK packages.
  7542. You must perform an initial setup for
  7543. <filename>opkg</filename> on the target machine
  7544. if the
  7545. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7546. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  7547. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7548. variables have not been set or the target image was
  7549. built before the variables were set.
  7550. </para>
  7551. <para>
  7552. The <filename>opkg</filename> application uses
  7553. configuration files to find available package
  7554. databases.
  7555. Thus, you need to create a configuration file inside
  7556. the <filename>/etc/opkg/</filename> direction, which
  7557. informs <filename>opkg</filename> of any repository
  7558. you want to use.
  7559. </para>
  7560. <para>
  7561. As an example, suppose you are serving packages from a
  7562. <filename>ipk/</filename> directory containing the
  7563. <filename>i586</filename>,
  7564. <filename>all</filename>, and
  7565. <filename>qemux86</filename> databases through an
  7566. HTTP server named <filename>my.server</filename>.
  7567. On the target, create a configuration file
  7568. (e.g. <filename>my_repo.conf</filename>) inside the
  7569. <filename>/etc/opkg/</filename> directory containing
  7570. the following:
  7571. <literallayout class='monospaced'>
  7572. src/gz all http://my.server/ipk/all
  7573. src/gz i586 http://my.server/ipk/i586
  7574. src/gz qemux86 http://my.server/ipk/qemux86
  7575. </literallayout>
  7576. Next, instruct <filename>opkg</filename> to fetch
  7577. the repository information:
  7578. <literallayout class='monospaced'>
  7579. # opkg update
  7580. </literallayout>
  7581. The <filename>opkg</filename> application is now able
  7582. to find, install, and upgrade packages from the
  7583. specified repository.
  7584. </para>
  7585. </section>
  7586. <section id='runtime-package-management-target-deb'>
  7587. <title>Using DEB</title>
  7588. <para>
  7589. The <filename>apt</filename> application performs
  7590. runtime package management of DEB packages.
  7591. This application uses a source list file to find
  7592. available package databases.
  7593. You must perform an initial setup for
  7594. <filename>apt</filename> on the target machine
  7595. if the
  7596. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7597. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  7598. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7599. variables have not been set or the target image was
  7600. built before the variables were set.
  7601. </para>
  7602. <para>
  7603. To inform <filename>apt</filename> of the repository
  7604. you want to use, you might create a list file (e.g.
  7605. <filename>my_repo.list</filename>) inside the
  7606. <filename>/etc/apt/sources.list.d/</filename>
  7607. directory.
  7608. As an example, suppose you are serving packages from a
  7609. <filename>deb/</filename> directory containing the
  7610. <filename>i586</filename>,
  7611. <filename>all</filename>, and
  7612. <filename>qemux86</filename> databases through an
  7613. HTTP server named <filename>my.server</filename>.
  7614. The list file should contain:
  7615. <literallayout class='monospaced'>
  7616. deb http://my.server/deb/all ./
  7617. deb http://my.server/deb/i586 ./
  7618. deb http://my.server/deb/qemux86 ./
  7619. </literallayout>
  7620. Next, instruct the <filename>apt</filename>
  7621. application to fetch the repository information:
  7622. <literallayout class='monospaced'>
  7623. # apt-get update
  7624. </literallayout>
  7625. After this step, <filename>apt</filename> is able
  7626. to find, install, and upgrade packages from the
  7627. specified repository.
  7628. </para>
  7629. </section>
  7630. </section>
  7631. </section>
  7632. <section id='generating-and-using-signed-packages'>
  7633. <title>Generating and Using Signed Packages</title>
  7634. <para>
  7635. In order to add security to RPM packages used during a build,
  7636. you can take steps to securely sign them.
  7637. Once a signature is verified, the OpenEmbedded build system
  7638. can use the package in the build.
  7639. If security fails for a signed package, the build system
  7640. aborts the build.
  7641. </para>
  7642. <para>
  7643. This section describes how to sign RPM packages during a build
  7644. and how to use signed package feeds (repositories) when
  7645. doing a build.
  7646. </para>
  7647. <section id='signing-rpm-packages'>
  7648. <title>Signing RPM Packages</title>
  7649. <para>
  7650. To enable signing RPM packages, you must set up the
  7651. following configurations in either your
  7652. <filename>local.config</filename> or
  7653. <filename>distro.config</filename> file:
  7654. <literallayout class='monospaced'>
  7655. # Inherit sign_rpm.bbclass to enable signing functionality
  7656. INHERIT += " sign_rpm"
  7657. # Define the GPG key that will be used for signing.
  7658. RPM_GPG_NAME = "<replaceable>key_name</replaceable>"
  7659. # Provide passphrase for the key
  7660. RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>"
  7661. </literallayout>
  7662. <note>
  7663. Be sure to supply appropriate values for both
  7664. <replaceable>key_name</replaceable> and
  7665. <replaceable>passphrase</replaceable>
  7666. </note>
  7667. Aside from the
  7668. <filename>RPM_GPG_NAME</filename> and
  7669. <filename>RPM_GPG_PASSPHRASE</filename> variables in the
  7670. previous example, two optional variables related to signing
  7671. exist:
  7672. <itemizedlist>
  7673. <listitem><para>
  7674. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  7675. Specifies a <filename>gpg</filename> binary/wrapper
  7676. that is executed when the package is signed.
  7677. </para></listitem>
  7678. <listitem><para>
  7679. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  7680. Specifies the <filename>gpg</filename> home
  7681. directory used when the package is signed.
  7682. </para></listitem>
  7683. </itemizedlist>
  7684. </para>
  7685. </section>
  7686. <section id='processing-package-feeds'>
  7687. <title>Processing Package Feeds</title>
  7688. <para>
  7689. In addition to being able to sign RPM packages, you can
  7690. also enable signed package feeds for IPK and RPM packages.
  7691. </para>
  7692. <para>
  7693. The steps you need to take to enable signed package feed
  7694. use are similar to the steps used to sign RPM packages.
  7695. You must define the following in your
  7696. <filename>local.config</filename> or
  7697. <filename>distro.config</filename> file:
  7698. <literallayout class='monospaced'>
  7699. INHERIT += "sign_package_feed"
  7700. PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>"
  7701. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>"
  7702. </literallayout>
  7703. For signed package feeds, the passphrase must exist in a
  7704. separate file, which is pointed to by the
  7705. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  7706. variable.
  7707. Regarding security, keeping a plain text passphrase out of
  7708. the configuration is more secure.
  7709. </para>
  7710. <para>
  7711. Aside from the
  7712. <filename>PACKAGE_FEED_GPG_NAME</filename> and
  7713. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  7714. variables, three optional variables related to signed
  7715. package feeds exist:
  7716. <itemizedlist>
  7717. <listitem><para>
  7718. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  7719. Specifies a <filename>gpg</filename> binary/wrapper
  7720. that is executed when the package is signed.
  7721. </para></listitem>
  7722. <listitem><para>
  7723. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  7724. Specifies the <filename>gpg</filename> home
  7725. directory used when the package is signed.
  7726. </para></listitem>
  7727. <listitem><para>
  7728. <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis>
  7729. Specifies the type of <filename>gpg</filename>
  7730. signature.
  7731. This variable applies only to RPM and IPK package
  7732. feeds.
  7733. Allowable values for the
  7734. <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>
  7735. are "ASC", which is the default and specifies ascii
  7736. armored, and "BIN", which specifies binary.
  7737. </para></listitem>
  7738. </itemizedlist>
  7739. </para>
  7740. </section>
  7741. </section>
  7742. <section id='testing-packages-with-ptest'>
  7743. <title>Testing Packages With ptest</title>
  7744. <para>
  7745. A Package Test (ptest) runs tests against packages built
  7746. by the OpenEmbedded build system on the target machine.
  7747. A ptest contains at least two items: the actual test, and
  7748. a shell script (<filename>run-ptest</filename>) that starts
  7749. the test.
  7750. The shell script that starts the test must not contain
  7751. the actual test - the script only starts the test.
  7752. On the other hand, the test can be anything from a simple
  7753. shell script that runs a binary and checks the output to
  7754. an elaborate system of test binaries and data files.
  7755. </para>
  7756. <para>
  7757. The test generates output in the format used by
  7758. Automake:
  7759. <literallayout class='monospaced'>
  7760. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  7761. </literallayout>
  7762. where the result can be <filename>PASS</filename>,
  7763. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  7764. and the testname can be any identifying string.
  7765. </para>
  7766. <para>
  7767. For a list of Yocto Project recipes that are already
  7768. enabled with ptest, see the
  7769. <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink>
  7770. wiki page.
  7771. <note>
  7772. A recipe is "ptest-enabled" if it inherits the
  7773. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  7774. class.
  7775. </note>
  7776. </para>
  7777. <section id='adding-ptest-to-your-build'>
  7778. <title>Adding ptest to Your Build</title>
  7779. <para>
  7780. To add package testing to your build, add the
  7781. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  7782. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  7783. variables to your <filename>local.conf</filename> file,
  7784. which is found in the
  7785. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  7786. <literallayout class='monospaced'>
  7787. DISTRO_FEATURES_append = " ptest"
  7788. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  7789. </literallayout>
  7790. Once your build is complete, the ptest files are installed
  7791. into the
  7792. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  7793. directory within the image, where
  7794. <filename><replaceable>package</replaceable></filename>
  7795. is the name of the package.
  7796. </para>
  7797. </section>
  7798. <section id='running-ptest'>
  7799. <title>Running ptest</title>
  7800. <para>
  7801. The <filename>ptest-runner</filename> package installs a
  7802. shell script that loops through all installed ptest test
  7803. suites and runs them in sequence.
  7804. Consequently, you might want to add this package to
  7805. your image.
  7806. </para>
  7807. </section>
  7808. <section id='getting-your-package-ready'>
  7809. <title>Getting Your Package Ready</title>
  7810. <para>
  7811. In order to enable a recipe to run installed ptests
  7812. on target hardware,
  7813. you need to prepare the recipes that build the packages
  7814. you want to test.
  7815. Here is what you have to do for each recipe:
  7816. <itemizedlist>
  7817. <listitem><para><emphasis>Be sure the recipe
  7818. inherits the
  7819. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  7820. class:</emphasis>
  7821. Include the following line in each recipe:
  7822. <literallayout class='monospaced'>
  7823. inherit ptest
  7824. </literallayout>
  7825. </para></listitem>
  7826. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  7827. This script starts your test.
  7828. Locate the script where you will refer to it
  7829. using
  7830. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  7831. Here is an example that starts a test for
  7832. <filename>dbus</filename>:
  7833. <literallayout class='monospaced'>
  7834. #!/bin/sh
  7835. cd test
  7836. make -k runtest-TESTS
  7837. </literallayout>
  7838. </para></listitem>
  7839. <listitem><para><emphasis>Ensure dependencies are
  7840. met:</emphasis>
  7841. If the test adds build or runtime dependencies
  7842. that normally do not exist for the package
  7843. (such as requiring "make" to run the test suite),
  7844. use the
  7845. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  7846. and
  7847. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  7848. variables in your recipe in order for the package
  7849. to meet the dependencies.
  7850. Here is an example where the package has a runtime
  7851. dependency on "make":
  7852. <literallayout class='monospaced'>
  7853. RDEPENDS_${PN}-ptest += "make"
  7854. </literallayout>
  7855. </para></listitem>
  7856. <listitem><para><emphasis>Add a function to build the
  7857. test suite:</emphasis>
  7858. Not many packages support cross-compilation of
  7859. their test suites.
  7860. Consequently, you usually need to add a
  7861. cross-compilation function to the package.
  7862. </para>
  7863. <para>Many packages based on Automake compile and
  7864. run the test suite by using a single command
  7865. such as <filename>make check</filename>.
  7866. However, the host <filename>make check</filename>
  7867. builds and runs on the same computer, while
  7868. cross-compiling requires that the package is built
  7869. on the host but executed for the target
  7870. architecture (though often, as in the case for
  7871. ptest, the execution occurs on the host).
  7872. The built version of Automake that ships with the
  7873. Yocto Project includes a patch that separates
  7874. building and execution.
  7875. Consequently, packages that use the unaltered,
  7876. patched version of <filename>make check</filename>
  7877. automatically cross-compiles.</para>
  7878. <para>Regardless, you still must add a
  7879. <filename>do_compile_ptest</filename> function to
  7880. build the test suite.
  7881. Add a function similar to the following to your
  7882. recipe:
  7883. <literallayout class='monospaced'>
  7884. do_compile_ptest() {
  7885. oe_runmake buildtest-TESTS
  7886. }
  7887. </literallayout>
  7888. </para></listitem>
  7889. <listitem><para><emphasis>Ensure special configurations
  7890. are set:</emphasis>
  7891. If the package requires special configurations
  7892. prior to compiling the test code, you must
  7893. insert a <filename>do_configure_ptest</filename>
  7894. function into the recipe.
  7895. </para></listitem>
  7896. <listitem><para><emphasis>Install the test
  7897. suite:</emphasis>
  7898. The <filename>ptest</filename> class
  7899. automatically copies the file
  7900. <filename>run-ptest</filename> to the target and
  7901. then runs make <filename>install-ptest</filename>
  7902. to run the tests.
  7903. If this is not enough, you need to create a
  7904. <filename>do_install_ptest</filename> function and
  7905. make sure it gets called after the
  7906. "make install-ptest" completes.
  7907. </para></listitem>
  7908. </itemizedlist>
  7909. </para>
  7910. </section>
  7911. </section>
  7912. </section>
  7913. <section id='working-with-source-files'>
  7914. <title>Working with Source Files</title>
  7915. <para>
  7916. The OpenEmbedded build system works with source files located
  7917. through the
  7918. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  7919. variable.
  7920. When you build something using BitBake, a big part of the operation
  7921. is locating and downloading all the source tarballs.
  7922. For images, downloading all the source for various packages can
  7923. take a significant amount of time.
  7924. </para>
  7925. <para>
  7926. This section presents information for working with source
  7927. files that can lead to more efficient use of resources and
  7928. time.
  7929. </para>
  7930. <section id='setting-up-effective-mirrors'>
  7931. <title>Setting up Effective Mirrors</title>
  7932. <para>
  7933. As mentioned, a good deal that goes into a Yocto Project
  7934. build is simply downloading all of the source tarballs.
  7935. Maybe you have been working with another build system
  7936. (OpenEmbedded or Angstrom) for which you have built up a
  7937. sizable directory of source tarballs.
  7938. Or, perhaps someone else has such a directory for which you
  7939. have read access.
  7940. If so, you can save time by adding statements to your
  7941. configuration file so that the build process checks local
  7942. directories first for existing tarballs before checking the
  7943. Internet.
  7944. </para>
  7945. <para>
  7946. Here is an efficient way to set it up in your
  7947. <filename>local.conf</filename> file:
  7948. <literallayout class='monospaced'>
  7949. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  7950. INHERIT += "own-mirrors"
  7951. BB_GENERATE_MIRROR_TARBALLS = "1"
  7952. # BB_NO_NETWORK = "1"
  7953. </literallayout>
  7954. </para>
  7955. <para>
  7956. In the previous example, the
  7957. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  7958. variable causes the OpenEmbedded build system to generate
  7959. tarballs of the Git repositories and store them in the
  7960. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  7961. directory.
  7962. Due to performance reasons, generating and storing these
  7963. tarballs is not the build system's default behavior.
  7964. </para>
  7965. <para>
  7966. You can also use the
  7967. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  7968. variable.
  7969. For an example, see the variable's glossary entry in the
  7970. Yocto Project Reference Manual.
  7971. </para>
  7972. </section>
  7973. <section id='getting-source-files-and-suppressing-the-build'>
  7974. <title>Getting Source Files and Suppressing the Build</title>
  7975. <para>
  7976. Another technique you can use to ready yourself for a
  7977. successive string of build operations, is to pre-fetch
  7978. all the source files without actually starting a build.
  7979. This technique lets you work through any download issues
  7980. and ultimately gathers all the source files into your
  7981. download directory
  7982. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  7983. which is located with
  7984. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  7985. </para>
  7986. <para>
  7987. Use the following BitBake command form to fetch all the
  7988. necessary sources without starting the build:
  7989. <literallayout class='monospaced'>
  7990. $ bitbake -c fetchall <replaceable>target</replaceable>
  7991. </literallayout>
  7992. This variation of the BitBake command guarantees that you
  7993. have all the sources for that BitBake target should you
  7994. disconnect from the Internet and want to do the build
  7995. later offline.
  7996. </para>
  7997. </section>
  7998. </section>
  7999. <section id="building-software-from-an-external-source">
  8000. <title>Building Software from an External Source</title>
  8001. <para>
  8002. By default, the OpenEmbedded build system uses the
  8003. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8004. when building source code.
  8005. The build process involves fetching the source files, unpacking
  8006. them, and then patching them if necessary before the build takes
  8007. place.
  8008. </para>
  8009. <para>
  8010. Situations exist where you might want to build software from source
  8011. files that are external to and thus outside of the
  8012. OpenEmbedded build system.
  8013. For example, suppose you have a project that includes a new BSP with
  8014. a heavily customized kernel.
  8015. And, you want to minimize exposing the build system to the
  8016. development team so that they can focus on their project and
  8017. maintain everyone's workflow as much as possible.
  8018. In this case, you want a kernel source directory on the development
  8019. machine where the development occurs.
  8020. You want the recipe's
  8021. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  8022. variable to point to the external directory and use it as is, not
  8023. copy it.
  8024. </para>
  8025. <para>
  8026. To build from software that comes from an external source, all you
  8027. need to do is inherit the
  8028. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  8029. class and then set the
  8030. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>
  8031. variable to point to your external source code.
  8032. Here are the statements to put in your
  8033. <filename>local.conf</filename> file:
  8034. <literallayout class='monospaced'>
  8035. INHERIT += "externalsrc"
  8036. EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  8037. </literallayout>
  8038. </para>
  8039. <para>
  8040. This next example shows how to accomplish the same thing by setting
  8041. <filename>EXTERNALSRC</filename> in the recipe itself or in the
  8042. recipe's append file:
  8043. <literallayout class='monospaced'>
  8044. EXTERNALSRC = "<replaceable>path</replaceable>"
  8045. EXTERNALSRC_BUILD = "<replaceable>path</replaceable>"
  8046. </literallayout>
  8047. <note>
  8048. In order for these settings to take effect, you must globally
  8049. or locally inherit the
  8050. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  8051. class.
  8052. </note>
  8053. </para>
  8054. <para>
  8055. By default, <filename>externalsrc.bbclass</filename> builds
  8056. the source code in a directory separate from the external source
  8057. directory as specified by
  8058. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>.
  8059. If you need to have the source built in the same directory in
  8060. which it resides, or some other nominated directory, you can set
  8061. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink>
  8062. to point to that directory:
  8063. <literallayout class='monospaced'>
  8064. EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  8065. </literallayout>
  8066. </para>
  8067. </section>
  8068. <section id="selecting-an-initialization-manager">
  8069. <title>Selecting an Initialization Manager</title>
  8070. <para>
  8071. By default, the Yocto Project uses SysVinit as the initialization
  8072. manager.
  8073. However, support also exists for systemd,
  8074. which is a full replacement for init with
  8075. parallel starting of services, reduced shell overhead and other
  8076. features that are used by many distributions.
  8077. </para>
  8078. <para>
  8079. If you want to use SysVinit, you do
  8080. not have to do anything.
  8081. But, if you want to use systemd, you must
  8082. take some steps as described in the following sections.
  8083. </para>
  8084. <section id='using-systemd-exclusively'>
  8085. <title>Using systemd Exclusively</title>
  8086. <para>
  8087. Set the these variables in your distribution configuration
  8088. file as follows:
  8089. <literallayout class='monospaced'>
  8090. DISTRO_FEATURES_append = " systemd"
  8091. VIRTUAL-RUNTIME_init_manager = "systemd"
  8092. </literallayout>
  8093. You can also prevent the SysVinit
  8094. distribution feature from
  8095. being automatically enabled as follows:
  8096. <literallayout class='monospaced'>
  8097. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  8098. </literallayout>
  8099. Doing so removes any redundant SysVinit scripts.
  8100. </para>
  8101. <para>
  8102. To remove initscripts from your image altogether,
  8103. set this variable also:
  8104. <literallayout class='monospaced'>
  8105. VIRTUAL-RUNTIME_initscripts = ""
  8106. </literallayout>
  8107. </para>
  8108. <para>
  8109. For information on the backfill variable, see
  8110. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  8111. </para>
  8112. </section>
  8113. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  8114. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  8115. <para>
  8116. Set these variables in your distribution configuration
  8117. file as follows:
  8118. <literallayout class='monospaced'>
  8119. DISTRO_FEATURES_append = " systemd"
  8120. VIRTUAL-RUNTIME_init_manager = "systemd"
  8121. </literallayout>
  8122. Doing so causes your main image to use the
  8123. <filename>packagegroup-core-boot.bb</filename> recipe and
  8124. systemd.
  8125. The rescue/minimal image cannot use this package group.
  8126. However, it can install SysVinit
  8127. and the appropriate packages will have support for both
  8128. systemd and SysVinit.
  8129. </para>
  8130. </section>
  8131. </section>
  8132. <section id="selecting-dev-manager">
  8133. <title>Selecting a Device Manager</title>
  8134. <para>
  8135. The Yocto Project provides multiple ways to manage the device
  8136. manager (<filename>/dev</filename>):
  8137. <itemizedlist>
  8138. <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis>
  8139. For this case, the <filename>/dev</filename> directory
  8140. is persistent and the required device nodes are created
  8141. during the build.
  8142. </para></listitem>
  8143. <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis>
  8144. For this case, the <filename>/dev</filename> directory
  8145. is provided by the kernel as an in-memory file system and
  8146. is automatically populated by the kernel at runtime.
  8147. Additional configuration of device nodes is done in user
  8148. space by a device manager like
  8149. <filename>udev</filename> or
  8150. <filename>busybox-mdev</filename>.
  8151. </para></listitem>
  8152. </itemizedlist>
  8153. </para>
  8154. <section id="static-dev-management">
  8155. <title>Using Persistent and Pre-Populated<filename>/dev</filename></title>
  8156. <para>
  8157. To use the static method for device population, you need to
  8158. set the
  8159. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  8160. variable to "0" as follows:
  8161. <literallayout class='monospaced'>
  8162. USE_DEVFS = "0"
  8163. </literallayout>
  8164. </para>
  8165. <para>
  8166. The content of the resulting <filename>/dev</filename>
  8167. directory is defined in a Device Table file.
  8168. The
  8169. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink>
  8170. variable defines the Device Table to use and should be set
  8171. in the machine or distro configuration file.
  8172. Alternatively, you can set this variable in your
  8173. <filename>local.conf</filename> configuration file.
  8174. </para>
  8175. <para>
  8176. If you do not define the
  8177. <filename>IMAGE_DEVICE_TABLES</filename> variable, the default
  8178. <filename>device_table-minimal.txt</filename> is used:
  8179. <literallayout class='monospaced'>
  8180. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  8181. </literallayout>
  8182. </para>
  8183. <para>
  8184. The population is handled by the <filename>makedevs</filename>
  8185. utility during image creation:
  8186. </para>
  8187. </section>
  8188. <section id="devtmpfs-dev-management">
  8189. <title>Using <filename>devtmpfs</filename> and a Device Manager</title>
  8190. <para>
  8191. To use the dynamic method for device population, you need to
  8192. use (or be sure to set) the
  8193. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  8194. variable to "1", which is the default:
  8195. <literallayout class='monospaced'>
  8196. USE_DEVFS = "1"
  8197. </literallayout>
  8198. With this setting, the resulting <filename>/dev</filename>
  8199. directory is populated by the kernel using
  8200. <filename>devtmpfs</filename>.
  8201. Make sure the corresponding kernel configuration variable
  8202. <filename>CONFIG_DEVTMPFS</filename> is set when building
  8203. you build a Linux kernel.
  8204. </para>
  8205. <para>
  8206. All devices created by <filename>devtmpfs</filename> will be
  8207. owned by <filename>root</filename> and have permissions
  8208. <filename>0600</filename>.
  8209. </para>
  8210. <para>
  8211. To have more control over the device nodes, you can use a
  8212. device manager like <filename>udev</filename> or
  8213. <filename>busybox-mdev</filename>.
  8214. You choose the device manager by defining the
  8215. <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable
  8216. in your machine or distro configuration file.
  8217. Alternatively, you can set this variable in your
  8218. <filename>local.conf</filename> configuration file:
  8219. <literallayout class='monospaced'>
  8220. VIRTUAL-RUNTIME_dev_manager = "udev"
  8221. # Some alternative values
  8222. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  8223. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  8224. </literallayout>
  8225. </para>
  8226. </section>
  8227. </section>
  8228. <section id="platdev-appdev-srcrev">
  8229. <title>Using an External SCM</title>
  8230. <para>
  8231. If you're working on a recipe that pulls from an external Source
  8232. Code Manager (SCM), it is possible to have the OpenEmbedded build
  8233. system notice new recipe changes added to the SCM and then build
  8234. the resulting packages that depend on the new recipes by using
  8235. the latest versions.
  8236. This only works for SCMs from which it is possible to get a
  8237. sensible revision number for changes.
  8238. Currently, you can do this with Apache Subversion (SVN), Git, and
  8239. Bazaar (BZR) repositories.
  8240. </para>
  8241. <para>
  8242. To enable this behavior, the
  8243. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  8244. of the recipe needs to reference
  8245. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  8246. Here is an example:
  8247. <literallayout class='monospaced'>
  8248. PV = "1.2.3+git${SRCPV}"
  8249. </literallayout>
  8250. Then, you can add the following to your
  8251. <filename>local.conf</filename>:
  8252. <literallayout class='monospaced'>
  8253. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  8254. </literallayout>
  8255. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  8256. is the name of the recipe for which you want to enable automatic source
  8257. revision updating.
  8258. </para>
  8259. <para>
  8260. If you do not want to update your local configuration file, you can
  8261. add the following directly to the recipe to finish enabling
  8262. the feature:
  8263. <literallayout class='monospaced'>
  8264. SRCREV = "${AUTOREV}"
  8265. </literallayout>
  8266. </para>
  8267. <para>
  8268. The Yocto Project provides a distribution named
  8269. <filename>poky-bleeding</filename>, whose configuration
  8270. file contains the line:
  8271. <literallayout class='monospaced'>
  8272. require conf/distro/include/poky-floating-revisions.inc
  8273. </literallayout>
  8274. This line pulls in the listed include file that contains
  8275. numerous lines of exactly that form:
  8276. <literallayout class='monospaced'>
  8277. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  8278. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  8279. #SRCREV_pn-opkg ?= "${AUTOREV}"
  8280. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  8281. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  8282. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  8283. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  8284. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  8285. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  8286. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  8287. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  8288. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  8289. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  8290. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  8291. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  8292. SRCREV_pn-screenshot ?= "${AUTOREV}"
  8293. .
  8294. .
  8295. .
  8296. </literallayout>
  8297. These lines allow you to experiment with building a
  8298. distribution that tracks the latest development source
  8299. for numerous packages.
  8300. <note><title>Caution</title>
  8301. The <filename>poky-bleeding</filename> distribution
  8302. is not tested on a regular basis.
  8303. Keep this in mind if you use it.
  8304. </note>
  8305. </para>
  8306. </section>
  8307. <section id='creating-a-read-only-root-filesystem'>
  8308. <title>Creating a Read-Only Root Filesystem</title>
  8309. <para>
  8310. Suppose, for security reasons, you need to disable
  8311. your target device's root filesystem's write permissions
  8312. (i.e. you need a read-only root filesystem).
  8313. Or, perhaps you are running the device's operating system
  8314. from a read-only storage device.
  8315. For either case, you can customize your image for
  8316. that behavior.
  8317. </para>
  8318. <note>
  8319. Supporting a read-only root filesystem requires that the system and
  8320. applications do not try to write to the root filesystem.
  8321. You must configure all parts of the target system to write
  8322. elsewhere, or to gracefully fail in the event of attempting to
  8323. write to the root filesystem.
  8324. </note>
  8325. <section id='creating-the-root-filesystem'>
  8326. <title>Creating the Root Filesystem</title>
  8327. <para>
  8328. To create the read-only root filesystem, simply add the
  8329. "read-only-rootfs" feature to your image.
  8330. Using either of the following statements in your
  8331. image recipe or from within the
  8332. <filename>local.conf</filename> file found in the
  8333. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8334. causes the build system to create a read-only root filesystem:
  8335. <literallayout class='monospaced'>
  8336. IMAGE_FEATURES = "read-only-rootfs"
  8337. </literallayout>
  8338. or
  8339. <literallayout class='monospaced'>
  8340. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  8341. </literallayout>
  8342. </para>
  8343. <para>
  8344. For more information on how to use these variables, see the
  8345. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  8346. section.
  8347. For information on the variables, see
  8348. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  8349. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  8350. </para>
  8351. </section>
  8352. <section id='post-installation-scripts'>
  8353. <title>Post-Installation Scripts</title>
  8354. <para>
  8355. It is very important that you make sure all
  8356. post-Installation (<filename>pkg_postinst</filename>) scripts
  8357. for packages that are installed into the image can be run
  8358. at the time when the root filesystem is created during the
  8359. build on the host system.
  8360. These scripts cannot attempt to run during first-boot on the
  8361. target device.
  8362. With the "read-only-rootfs" feature enabled,
  8363. the build system checks during root filesystem creation to make
  8364. sure all post-installation scripts succeed.
  8365. If any of these scripts still need to be run after the root
  8366. filesystem is created, the build immediately fails.
  8367. These build-time checks ensure that the build fails
  8368. rather than the target device fails later during its
  8369. initial boot operation.
  8370. </para>
  8371. <para>
  8372. Most of the common post-installation scripts generated by the
  8373. build system for the out-of-the-box Yocto Project are engineered
  8374. so that they can run during root filesystem creation
  8375. (e.g. post-installation scripts for caching fonts).
  8376. However, if you create and add custom scripts, you need
  8377. to be sure they can be run during this file system creation.
  8378. </para>
  8379. <para>
  8380. Here are some common problems that prevent
  8381. post-installation scripts from running during root filesystem
  8382. creation:
  8383. <itemizedlist>
  8384. <listitem><para>
  8385. <emphasis>Not using $D in front of absolute
  8386. paths:</emphasis>
  8387. The build system defines
  8388. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  8389. when the root filesystem is created.
  8390. Furthermore, <filename>$D</filename> is blank when the
  8391. script is run on the target device.
  8392. This implies two purposes for <filename>$D</filename>:
  8393. ensuring paths are valid in both the host and target
  8394. environments, and checking to determine which
  8395. environment is being used as a method for taking
  8396. appropriate actions.
  8397. </para></listitem>
  8398. <listitem><para>
  8399. <emphasis>Attempting to run processes that are
  8400. specific to or dependent on the target
  8401. architecture:</emphasis>
  8402. You can work around these attempts by using native
  8403. tools, which run on the host system,
  8404. to accomplish the same tasks, or
  8405. by alternatively running the processes under QEMU,
  8406. which has the <filename>qemu_run_binary</filename>
  8407. function.
  8408. For more information, see the
  8409. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  8410. class.</para></listitem>
  8411. </itemizedlist>
  8412. </para>
  8413. </section>
  8414. <section id='areas-with-write-access'>
  8415. <title>Areas With Write Access</title>
  8416. <para>
  8417. With the "read-only-rootfs" feature enabled,
  8418. any attempt by the target to write to the root filesystem at
  8419. runtime fails.
  8420. Consequently, you must make sure that you configure processes
  8421. and applications that attempt these types of writes do so
  8422. to directories with write access (e.g.
  8423. <filename>/tmp</filename> or <filename>/var/run</filename>).
  8424. </para>
  8425. </section>
  8426. </section>
  8427. <section id='maintaining-build-output-quality'>
  8428. <title>Maintaining Build Output Quality</title>
  8429. <para>
  8430. Many factors can influence the quality of a build.
  8431. For example, if you upgrade a recipe to use a new version of an
  8432. upstream software package or you experiment with some new
  8433. configuration options, subtle changes can occur that you might
  8434. not detect until later.
  8435. Consider the case where your recipe is using a newer version of
  8436. an upstream package.
  8437. In this case, a new version of a piece of software might
  8438. introduce an optional dependency on another library, which is
  8439. auto-detected.
  8440. If that library has already been built when the software is
  8441. building, the software will link to the built library and that
  8442. library will be pulled into your image along with the new
  8443. software even if you did not want the library.
  8444. </para>
  8445. <para>
  8446. The
  8447. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-buildhistory'><filename>buildhistory</filename></ulink>
  8448. class exists to help you maintain the quality of your build
  8449. output.
  8450. You can use the class to highlight unexpected and possibly
  8451. unwanted changes in the build output.
  8452. When you enable build history, it records information about the
  8453. contents of each package and image and then commits that
  8454. information to a local Git repository where you can examine
  8455. the information.
  8456. </para>
  8457. <para>
  8458. The remainder of this section describes the following:
  8459. <itemizedlist>
  8460. <listitem><para>
  8461. How you can enable and disable build history
  8462. </para></listitem>
  8463. <listitem><para>
  8464. How to understand what the build history contains
  8465. </para></listitem>
  8466. <listitem><para>
  8467. How to limit the information used for build history
  8468. </para></listitem>
  8469. <listitem><para>
  8470. How to examine the build history from both a
  8471. command-line and web interface
  8472. </para></listitem>
  8473. </itemizedlist>
  8474. </para>
  8475. <section id='enabling-and-disabling-build-history'>
  8476. <title>Enabling and Disabling Build History</title>
  8477. <para>
  8478. Build history is disabled by default.
  8479. To enable it, add the following <filename>INHERIT</filename>
  8480. statement and set the
  8481. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink>
  8482. variable to "1" at the end of your
  8483. <filename>conf/local.conf</filename> file found in the
  8484. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8485. <literallayout class='monospaced'>
  8486. INHERIT += "buildhistory"
  8487. BUILDHISTORY_COMMIT = "1"
  8488. </literallayout>
  8489. Enabling build history as previously described causes the
  8490. OpenEmbedded build system to collect build output information
  8491. and commit it as a single commit to a local
  8492. <ulink url='&YOCTO_DOCS_OVERVIEW_URL;#git'>Git</ulink>
  8493. repository.
  8494. <note>
  8495. Enabling build history increases your build times slightly,
  8496. particularly for images, and increases the amount of disk
  8497. space used during the build.
  8498. </note>
  8499. </para>
  8500. <para>
  8501. You can disable build history by removing the previous
  8502. statements from your <filename>conf/local.conf</filename>
  8503. file.
  8504. </para>
  8505. </section>
  8506. <section id='understanding-what-the-build-history-contains'>
  8507. <title>Understanding What the Build History Contains</title>
  8508. <para>
  8509. Build history information is kept in
  8510. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink><filename>}/buildhistory</filename>
  8511. in the Build Directory as defined by the
  8512. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></ulink>
  8513. variable.
  8514. The following is an example abbreviated listing:
  8515. <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" />
  8516. </para>
  8517. <para>
  8518. At the top level, a <filename>metadata-revs</filename>
  8519. file exists that lists the revisions of the repositories for
  8520. the enabled layers when the build was produced.
  8521. The rest of the data splits into separate
  8522. <filename>packages</filename>, <filename>images</filename>
  8523. and <filename>sdk</filename> directories, the contents of
  8524. which are described as follows.
  8525. </para>
  8526. <section id='build-history-package-information'>
  8527. <title>Build History Package Information</title>
  8528. <para>
  8529. The history for each package contains a text file that has
  8530. name-value pairs with information about the package.
  8531. For example,
  8532. <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename>
  8533. contains the following:
  8534. <literallayout class='monospaced'>
  8535. PV = 1.22.1
  8536. PR = r32
  8537. RPROVIDES =
  8538. RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
  8539. RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
  8540. PKGSIZE = 540168
  8541. FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
  8542. /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
  8543. /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
  8544. /usr/share/pixmaps /usr/share/applications /usr/share/idl \
  8545. /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
  8546. FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
  8547. /etc/busybox.links.nosuid /etc/busybox.links.suid
  8548. </literallayout>
  8549. Most of these name-value pairs correspond to variables
  8550. used to produce the package.
  8551. The exceptions are <filename>FILELIST</filename>, which
  8552. is the actual list of files in the package, and
  8553. <filename>PKGSIZE</filename>, which is the total size of
  8554. files in the package in bytes.
  8555. </para>
  8556. <para>
  8557. A file also exists that corresponds to the recipe from
  8558. which the package came (e.g.
  8559. <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>):
  8560. <literallayout class='monospaced'>
  8561. PV = 1.22.1
  8562. PR = r32
  8563. DEPENDS = initscripts kern-tools-native update-rc.d-native \
  8564. virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
  8565. virtual/libc virtual/update-alternatives
  8566. PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
  8567. busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
  8568. busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
  8569. </literallayout>
  8570. </para>
  8571. <para>
  8572. Finally, for those recipes fetched from a version control
  8573. system (e.g., Git), a file exists that lists source
  8574. revisions that are specified in the recipe and lists
  8575. the actual revisions used during the build.
  8576. Listed and actual revisions might differ when
  8577. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  8578. is set to
  8579. ${<ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>}.
  8580. Here is an example assuming
  8581. <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>):
  8582. <literallayout class='monospaced'>
  8583. # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  8584. SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  8585. # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  8586. SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  8587. </literallayout>
  8588. You can use the
  8589. <filename>buildhistory-collect-srcrevs</filename>
  8590. command with the <filename>-a</filename> option to
  8591. collect the stored <filename>SRCREV</filename> values
  8592. from build history and report them in a format suitable for
  8593. use in global configuration (e.g.,
  8594. <filename>local.conf</filename> or a distro include file)
  8595. to override floating <filename>AUTOREV</filename> values
  8596. to a fixed set of revisions.
  8597. Here is some example output from this command:
  8598. <literallayout class='monospaced'>
  8599. $ buildhistory-collect-srcrevs -a
  8600. # i586-poky-linux
  8601. SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
  8602. SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
  8603. SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
  8604. SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  8605. # x86_64-linux
  8606. SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
  8607. SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
  8608. SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
  8609. SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
  8610. SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
  8611. SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
  8612. SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
  8613. SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
  8614. SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  8615. # qemux86-poky-linux
  8616. SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  8617. SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
  8618. # all-poky-linux
  8619. SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
  8620. </literallayout>
  8621. <note>
  8622. Here are some notes on using the
  8623. <filename>buildhistory-collect-srcrevs</filename>
  8624. command:
  8625. <itemizedlist>
  8626. <listitem><para>
  8627. By default, only values where the
  8628. <filename>SRCREV</filename> was not hardcoded
  8629. (usually when <filename>AUTOREV</filename>
  8630. is used) are reported.
  8631. Use the <filename>-a</filename> option to
  8632. see all <filename>SRCREV</filename> values.
  8633. </para></listitem>
  8634. <listitem><para>
  8635. The output statements might not have any effect
  8636. if overrides are applied elsewhere in the
  8637. build system configuration.
  8638. Use the <filename>-f</filename> option to add
  8639. the <filename>forcevariable</filename> override
  8640. to each output line if you need to work around
  8641. this restriction.
  8642. </para></listitem>
  8643. <listitem><para>
  8644. The script does apply special handling when
  8645. building for multiple machines.
  8646. However, the script does place a comment before
  8647. each set of values that specifies which
  8648. triplet to which they belong as previously
  8649. shown (e.g.,
  8650. <filename>i586-poky-linux</filename>).
  8651. </para></listitem>
  8652. </itemizedlist>
  8653. </note>
  8654. </para>
  8655. </section>
  8656. <section id='build-history-image-information'>
  8657. <title>Build History Image Information</title>
  8658. <para>
  8659. The files produced for each image are as follows:
  8660. <itemizedlist>
  8661. <listitem><para>
  8662. <filename>image-files:</filename>
  8663. A directory containing selected files from the root
  8664. filesystem.
  8665. The files are defined by
  8666. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></ulink>.
  8667. </para></listitem>
  8668. <listitem><para>
  8669. <filename>build-id.txt:</filename>
  8670. Human-readable information about the build
  8671. configuration and metadata source revisions.
  8672. This file contains the full build header as printed
  8673. by BitBake.
  8674. </para></listitem>
  8675. <listitem><para>
  8676. <filename>*.dot:</filename>
  8677. Dependency graphs for the image that are
  8678. compatible with <filename>graphviz</filename>.
  8679. </para></listitem>
  8680. <listitem><para>
  8681. <filename>files-in-image.txt:</filename>
  8682. A list of files in the image with permissions,
  8683. owner, group, size, and symlink information.
  8684. </para></listitem>
  8685. <listitem><para>
  8686. <filename>image-info.txt:</filename>
  8687. A text file containing name-value pairs with
  8688. information about the image.
  8689. See the following listing example for more
  8690. information.
  8691. </para></listitem>
  8692. <listitem><para>
  8693. <filename>installed-package-names.txt:</filename>
  8694. A list of installed packages by name only.
  8695. </para></listitem>
  8696. <listitem><para>
  8697. <filename>installed-package-sizes.txt:</filename>
  8698. A list of installed packages ordered by size.
  8699. </para></listitem>
  8700. <listitem><para>
  8701. <filename>installed-packages.txt:</filename>
  8702. A list of installed packages with full package
  8703. filenames.
  8704. </para></listitem>
  8705. </itemizedlist>
  8706. <note>
  8707. Installed package information is able to be gathered
  8708. and produced even if package management is disabled
  8709. for the final image.
  8710. </note>
  8711. </para>
  8712. <para>
  8713. Here is an example of <filename>image-info.txt</filename>:
  8714. <literallayout class='monospaced'>
  8715. DISTRO = poky
  8716. DISTRO_VERSION = 1.7
  8717. USER_CLASSES = buildstats image-mklibs image-prelink
  8718. IMAGE_CLASSES = image_types
  8719. IMAGE_FEATURES = debug-tweaks
  8720. IMAGE_LINGUAS =
  8721. IMAGE_INSTALL = packagegroup-core-boot run-postinsts
  8722. BAD_RECOMMENDATIONS =
  8723. NO_RECOMMENDATIONS =
  8724. PACKAGE_EXCLUDE =
  8725. ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
  8726. write_image_manifest ; buildhistory_list_installed_image ; \
  8727. buildhistory_get_image_installed ; ssh_allow_empty_password; \
  8728. postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
  8729. IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
  8730. IMAGESIZE = 6900
  8731. </literallayout>
  8732. Other than <filename>IMAGESIZE</filename>, which is the
  8733. total size of the files in the image in Kbytes, the
  8734. name-value pairs are variables that may have influenced the
  8735. content of the image.
  8736. This information is often useful when you are trying to
  8737. determine why a change in the package or file
  8738. listings has occurred.
  8739. </para>
  8740. </section>
  8741. <section id='using-build-history-to-gather-image-information-only'>
  8742. <title>Using Build History to Gather Image Information Only</title>
  8743. <para>
  8744. As you can see, build history produces image information,
  8745. including dependency graphs, so you can see why something
  8746. was pulled into the image.
  8747. If you are just interested in this information and not
  8748. interested in collecting specific package or SDK
  8749. information, you can enable writing only image information
  8750. without any history by adding the following to your
  8751. <filename>conf/local.conf</filename> file found in the
  8752. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8753. <literallayout class='monospaced'>
  8754. INHERIT += "buildhistory"
  8755. BUILDHISTORY_COMMIT = "0"
  8756. BUILDHISTORY_FEATURES = "image"
  8757. </literallayout>
  8758. Here, you set the
  8759. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></ulink>
  8760. variable to use the image feature only.
  8761. </para>
  8762. </section>
  8763. <section id='build-history-sdk-information'>
  8764. <title>Build History SDK Information</title>
  8765. <para>
  8766. Build history collects similar information on the contents
  8767. of SDKs
  8768. (e.g. <filename>bitbake -c populate_sdk imagename</filename>)
  8769. as compared to information it collects for images.
  8770. Furthermore, this information differs depending on whether
  8771. an extensible or standard SDK is being produced.
  8772. </para>
  8773. <para>
  8774. The following list shows the files produced for SDKs:
  8775. <itemizedlist>
  8776. <listitem><para>
  8777. <filename>files-in-sdk.txt:</filename>
  8778. A list of files in the SDK with permissions,
  8779. owner, group, size, and symlink information.
  8780. This list includes both the host and target parts
  8781. of the SDK.
  8782. </para></listitem>
  8783. <listitem><para>
  8784. <filename>sdk-info.txt:</filename>
  8785. A text file containing name-value pairs with
  8786. information about the SDK.
  8787. See the following listing example for more
  8788. information.
  8789. </para></listitem>
  8790. <listitem><para>
  8791. <filename>sstate-task-sizes.txt:</filename>
  8792. A text file containing name-value pairs with
  8793. information about task group sizes
  8794. (e.g. <filename>do_populate_sysroot</filename>
  8795. tasks have a total size).
  8796. The <filename>sstate-task-sizes.txt</filename> file
  8797. exists only when an extensible SDK is created.
  8798. </para></listitem>
  8799. <listitem><para>
  8800. <filename>sstate-package-sizes.txt:</filename>
  8801. A text file containing name-value pairs with
  8802. information for the shared-state packages and
  8803. sizes in the SDK.
  8804. The <filename>sstate-package-sizes.txt</filename>
  8805. file exists only when an extensible SDK is created.
  8806. </para></listitem>
  8807. <listitem><para>
  8808. <filename>sdk-files:</filename>
  8809. A folder that contains copies of the files
  8810. mentioned in
  8811. <filename>BUILDHISTORY_SDK_FILES</filename> if the
  8812. files are present in the output.
  8813. Additionally, the default value of
  8814. <filename>BUILDHISTORY_SDK_FILES</filename> is
  8815. specific to the extensible SDK although you can
  8816. set it differently if you would like to pull in
  8817. specific files from the standard SDK.</para>
  8818. <para>The default files are
  8819. <filename>conf/local.conf</filename>,
  8820. <filename>conf/bblayers.conf</filename>,
  8821. <filename>conf/auto.conf</filename>,
  8822. <filename>conf/locked-sigs.inc</filename>, and
  8823. <filename>conf/devtool.conf</filename>.
  8824. Thus, for an extensible SDK, these files get
  8825. copied into the <filename>sdk-files</filename>
  8826. directory.
  8827. </para></listitem>
  8828. <listitem><para>
  8829. The following information appears under
  8830. each of the <filename>host</filename>
  8831. and <filename>target</filename> directories
  8832. for the portions of the SDK that run on the host
  8833. and on the target, respectively:
  8834. <note>
  8835. The following files for the most part are empty
  8836. when producing an extensible SDK because this
  8837. type of SDK is not constructed from packages
  8838. as is the standard SDK.
  8839. </note>
  8840. <itemizedlist>
  8841. <listitem><para>
  8842. <filename>depends.dot:</filename>
  8843. Dependency graph for the SDK that is
  8844. compatible with
  8845. <filename>graphviz</filename>.
  8846. </para></listitem>
  8847. <listitem><para>
  8848. <filename>installed-package-names.txt:</filename>
  8849. A list of installed packages by name only.
  8850. </para></listitem>
  8851. <listitem><para>
  8852. <filename>installed-package-sizes.txt:</filename>
  8853. A list of installed packages ordered by size.
  8854. </para></listitem>
  8855. <listitem><para>
  8856. <filename>installed-packages.txt:</filename>
  8857. A list of installed packages with full
  8858. package filenames.
  8859. </para></listitem>
  8860. </itemizedlist>
  8861. </para></listitem>
  8862. </itemizedlist>
  8863. </para>
  8864. <para>
  8865. Here is an example of <filename>sdk-info.txt</filename>:
  8866. <literallayout class='monospaced'>
  8867. DISTRO = poky
  8868. DISTRO_VERSION = 1.3+snapshot-20130327
  8869. SDK_NAME = poky-glibc-i686-arm
  8870. SDK_VERSION = 1.3+snapshot
  8871. SDKMACHINE =
  8872. SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
  8873. BAD_RECOMMENDATIONS =
  8874. SDKSIZE = 352712
  8875. </literallayout>
  8876. Other than <filename>SDKSIZE</filename>, which is the
  8877. total size of the files in the SDK in Kbytes, the
  8878. name-value pairs are variables that might have influenced
  8879. the content of the SDK.
  8880. This information is often useful when you are trying to
  8881. determine why a change in the package or file listings
  8882. has occurred.
  8883. </para>
  8884. </section>
  8885. <section id='examining-build-history-information'>
  8886. <title>Examining Build History Information</title>
  8887. <para>
  8888. You can examine build history output from the command
  8889. line or from a web interface.
  8890. </para>
  8891. <para>
  8892. To see any changes that have occurred (assuming you have
  8893. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink><filename>&nbsp;= "1"</filename>),
  8894. you can simply use any Git command that allows you to
  8895. view the history of a repository.
  8896. Here is one method:
  8897. <literallayout class='monospaced'>
  8898. $ git log -p
  8899. </literallayout>
  8900. You need to realize, however, that this method does show
  8901. changes that are not significant (e.g. a package's size
  8902. changing by a few bytes).
  8903. </para>
  8904. <para>
  8905. A command-line tool called
  8906. <filename>buildhistory-diff</filename> does exist, though,
  8907. that queries the Git repository and prints just the
  8908. differences that might be significant in human-readable
  8909. form.
  8910. Here is an example:
  8911. <literallayout class='monospaced'>
  8912. $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
  8913. Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
  8914. /etc/anotherpkg.conf was added
  8915. /sbin/anotherpkg was added
  8916. * (installed-package-names.txt):
  8917. * anotherpkg was added
  8918. Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
  8919. anotherpkg was added
  8920. packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
  8921. * PR changed from "r0" to "r1"
  8922. * PV changed from "0.1.10" to "0.1.12"
  8923. packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
  8924. * PR changed from "r0" to "r1"
  8925. * PV changed from "0.1.10" to "0.1.12"
  8926. </literallayout>
  8927. <note>
  8928. The <filename>buildhistory-diff</filename> tool
  8929. requires the <filename>GitPython</filename> package.
  8930. Be sure to install it using Pip3 as follows:
  8931. <literallayout class='monospaced'>
  8932. $ pip3 install GitPython --user
  8933. </literallayout>
  8934. Alternatively, you can install
  8935. <filename>python3-git</filename> using the appropriate
  8936. distribution package manager (e.g.
  8937. <filename>apt-get</filename>, <filename>dnf</filename>,
  8938. or <filename>zipper</filename>).
  8939. </note>
  8940. </para>
  8941. <para>
  8942. To see changes to the build history using a web interface,
  8943. follow the instruction in the <filename>README</filename>
  8944. file here.
  8945. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>.
  8946. </para>
  8947. <para>
  8948. Here is a sample screenshot of the interface:
  8949. <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" />
  8950. </para>
  8951. </section>
  8952. </section>
  8953. </section>
  8954. <section id="performing-automated-runtime-testing">
  8955. <title>Performing Automated Runtime Testing</title>
  8956. <para>
  8957. The OpenEmbedded build system makes available a series of automated
  8958. tests for images to verify runtime functionality.
  8959. You can run these tests on either QEMU or actual target hardware.
  8960. Tests are written in Python making use of the
  8961. <filename>unittest</filename> module, and the majority of them
  8962. run commands on the target system over SSH.
  8963. This section describes how you set up the environment to use these
  8964. tests, run available tests, and write and add your own tests.
  8965. </para>
  8966. <para>
  8967. For information on the test and QA infrastructure available
  8968. within the Yocto Project, see the
  8969. "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>"
  8970. section in the Yocto Project Reference Manual.
  8971. </para>
  8972. <section id='enabling-tests'>
  8973. <title>Enabling Tests</title>
  8974. <para>
  8975. Depending on whether you are planning to run tests using
  8976. QEMU or on the hardware, you have to take
  8977. different steps to enable the tests.
  8978. See the following subsections for information on how to
  8979. enable both types of tests.
  8980. </para>
  8981. <section id='qemu-image-enabling-tests'>
  8982. <title>Enabling Runtime Tests on QEMU</title>
  8983. <para>
  8984. In order to run tests, you need to do the following:
  8985. <itemizedlist>
  8986. <listitem><para><emphasis>Set up to avoid interaction
  8987. with <filename>sudo</filename> for networking:</emphasis>
  8988. To accomplish this, you must do one of the
  8989. following:
  8990. <itemizedlist>
  8991. <listitem><para>Add
  8992. <filename>NOPASSWD</filename> for your user
  8993. in <filename>/etc/sudoers</filename> either for
  8994. all commands or just for
  8995. <filename>runqemu-ifup</filename>.
  8996. You must provide the full path as that can
  8997. change if you are using multiple clones of the
  8998. source repository.
  8999. <note>
  9000. On some distributions, you also need to
  9001. comment out "Defaults requiretty" in
  9002. <filename>/etc/sudoers</filename>.
  9003. </note></para></listitem>
  9004. <listitem><para>Manually configure a tap interface
  9005. for your system.</para></listitem>
  9006. <listitem><para>Run as root the script in
  9007. <filename>scripts/runqemu-gen-tapdevs</filename>,
  9008. which should generate a list of tap devices.
  9009. This is the option typically chosen for
  9010. Autobuilder-type environments.
  9011. </para></listitem>
  9012. </itemizedlist></para></listitem>
  9013. <listitem><para><emphasis>Set the
  9014. <filename>DISPLAY</filename> variable:</emphasis>
  9015. You need to set this variable so that you have an X
  9016. server available (e.g. start
  9017. <filename>vncserver</filename> for a headless machine).
  9018. </para></listitem>
  9019. <listitem><para><emphasis>Be sure your host's firewall
  9020. accepts incoming connections from
  9021. 192.168.7.0/24:</emphasis>
  9022. Some of the tests (in particular DNF tests) start
  9023. an HTTP server on a random high number port,
  9024. which is used to serve files to the target.
  9025. The DNF module serves
  9026. <filename>${WORKDIR}/oe-rootfs-repo</filename>
  9027. so it can run DNF channel commands.
  9028. That means your host's firewall
  9029. must accept incoming connections from 192.168.7.0/24,
  9030. which is the default IP range used for tap devices
  9031. by <filename>runqemu</filename>.</para></listitem>
  9032. <listitem><para><emphasis>Be sure your host has the
  9033. correct packages installed:</emphasis>
  9034. Depending your host's distribution, you need
  9035. to have the following packages installed:
  9036. <itemizedlist>
  9037. <listitem><para>Ubuntu and Debian:
  9038. <filename>sysstat</filename> and
  9039. <filename>iproute2</filename>
  9040. </para></listitem>
  9041. <listitem><para>OpenSUSE:
  9042. <filename>sysstat</filename> and
  9043. <filename>iproute2</filename>
  9044. </para></listitem>
  9045. <listitem><para>Fedora:
  9046. <filename>sysstat</filename> and
  9047. <filename>iproute</filename>
  9048. </para></listitem>
  9049. <listitem><para>CentOS:
  9050. <filename>sysstat</filename> and
  9051. <filename>iproute</filename>
  9052. </para></listitem>
  9053. </itemizedlist>
  9054. </para></listitem>
  9055. </itemizedlist>
  9056. </para>
  9057. <para>
  9058. Once you start running the tests, the following happens:
  9059. <orderedlist>
  9060. <listitem><para>A copy of the root filesystem is written
  9061. to <filename>${WORKDIR}/testimage</filename>.
  9062. </para></listitem>
  9063. <listitem><para>The image is booted under QEMU using the
  9064. standard <filename>runqemu</filename> script.
  9065. </para></listitem>
  9066. <listitem><para>A default timeout of 500 seconds occurs
  9067. to allow for the boot process to reach the login prompt.
  9068. You can change the timeout period by setting
  9069. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  9070. in the <filename>local.conf</filename> file.
  9071. </para></listitem>
  9072. <listitem><para>Once the boot process is reached and the
  9073. login prompt appears, the tests run.
  9074. The full boot log is written to
  9075. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  9076. </para></listitem>
  9077. <listitem><para>Each test module loads in the order found
  9078. in <filename>TEST_SUITES</filename>.
  9079. You can find the full output of the commands run over
  9080. SSH in
  9081. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  9082. </para></listitem>
  9083. <listitem><para>If no failures occur, the task running the
  9084. tests ends successfully.
  9085. You can find the output from the
  9086. <filename>unittest</filename> in the task log at
  9087. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  9088. </para></listitem>
  9089. </orderedlist>
  9090. </para>
  9091. </section>
  9092. <section id='hardware-image-enabling-tests'>
  9093. <title>Enabling Runtime Tests on Hardware</title>
  9094. <para>
  9095. The OpenEmbedded build system can run tests on real
  9096. hardware, and for certain devices it can also deploy
  9097. the image to be tested onto the device beforehand.
  9098. </para>
  9099. <para>
  9100. For automated deployment, a "master image" is installed
  9101. onto the hardware once as part of setup.
  9102. Then, each time tests are to be run, the following
  9103. occurs:
  9104. <orderedlist>
  9105. <listitem><para>The master image is booted into and
  9106. used to write the image to be tested to
  9107. a second partition.
  9108. </para></listitem>
  9109. <listitem><para>The device is then rebooted using an
  9110. external script that you need to provide.
  9111. </para></listitem>
  9112. <listitem><para>The device boots into the image to be
  9113. tested.
  9114. </para></listitem>
  9115. </orderedlist>
  9116. </para>
  9117. <para>
  9118. When running tests (independent of whether the image
  9119. has been deployed automatically or not), the device is
  9120. expected to be connected to a network on a
  9121. pre-determined IP address.
  9122. You can either use static IP addresses written into
  9123. the image, or set the image to use DHCP and have your
  9124. DHCP server on the test network assign a known IP address
  9125. based on the MAC address of the device.
  9126. </para>
  9127. <para>
  9128. In order to run tests on hardware, you need to set
  9129. <filename>TEST_TARGET</filename> to an appropriate value.
  9130. For QEMU, you do not have to change anything, the default
  9131. value is "QemuTarget".
  9132. For running tests on hardware, the following options exist:
  9133. <itemizedlist>
  9134. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  9135. Choose "SimpleRemoteTarget" if you are going to
  9136. run tests on a target system that is already
  9137. running the image to be tested and is available
  9138. on the network.
  9139. You can use "SimpleRemoteTarget" in conjunction
  9140. with either real hardware or an image running
  9141. within a separately started QEMU or any
  9142. other virtual machine manager.
  9143. </para></listitem>
  9144. <listitem><para><emphasis>"Systemd-bootTarget":</emphasis>
  9145. Choose "Systemd-bootTarget" if your hardware is
  9146. an EFI-based machine with
  9147. <filename>systemd-boot</filename> as bootloader and
  9148. <filename>core-image-testmaster</filename>
  9149. (or something similar) is installed.
  9150. Also, your hardware under test must be in a
  9151. DHCP-enabled network that gives it the same IP
  9152. address for each reboot.</para>
  9153. <para>If you choose "Systemd-bootTarget", there are
  9154. additional requirements and considerations.
  9155. See the
  9156. "<link linkend='selecting-systemd-boottarget'>Selecting Systemd-bootTarget</link>"
  9157. section, which follows, for more information.
  9158. </para></listitem>
  9159. <listitem><para><emphasis>"BeagleBoneTarget":</emphasis>
  9160. Choose "BeagleBoneTarget" if you are deploying
  9161. images and running tests on the BeagleBone
  9162. "Black" or original "White" hardware.
  9163. For information on how to use these tests, see the
  9164. comments at the top of the BeagleBoneTarget
  9165. <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename>
  9166. file.
  9167. </para></listitem>
  9168. <listitem><para><emphasis>"EdgeRouterTarget":</emphasis>
  9169. Choose "EdgeRouterTarget" is you are deploying
  9170. images and running tests on the Ubiquiti Networks
  9171. EdgeRouter Lite.
  9172. For information on how to use these tests, see the
  9173. comments at the top of the EdgeRouterTarget
  9174. <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename>
  9175. file.
  9176. </para></listitem>
  9177. <listitem><para><emphasis>"GrubTarget":</emphasis>
  9178. Choose the "supports deploying images and running
  9179. tests on any generic PC that boots using GRUB.
  9180. For information on how to use these tests, see the
  9181. comments at the top of the GrubTarget
  9182. <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename>
  9183. file.
  9184. </para></listitem>
  9185. <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis>
  9186. Create your own custom target if you want to run
  9187. tests when you are deploying images and running
  9188. tests on a custom machine within your BSP layer.
  9189. To do this, you need to add a Python unit that
  9190. defines the target class under
  9191. <filename>lib/oeqa/controllers/</filename> within
  9192. your layer.
  9193. You must also provide an empty
  9194. <filename>__init__.py</filename>.
  9195. For examples, see files in
  9196. <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>.
  9197. </para></listitem>
  9198. </itemizedlist>
  9199. </para>
  9200. </section>
  9201. <section id='selecting-systemd-boottarget'>
  9202. <title>Selecting Systemd-bootTarget</title>
  9203. <para>
  9204. If you did not set <filename>TEST_TARGET</filename> to
  9205. "Systemd-bootTarget", then you do not need any information
  9206. in this section.
  9207. You can skip down to the
  9208. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  9209. section.
  9210. </para>
  9211. <para>
  9212. If you did set <filename>TEST_TARGET</filename> to
  9213. "Systemd-bootTarget", you also need to perform a one-time
  9214. setup of your master image by doing the following:
  9215. <orderedlist>
  9216. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  9217. Be sure that <filename>EFI_PROVIDER</filename>
  9218. is as follows:
  9219. <literallayout class='monospaced'>
  9220. EFI_PROVIDER = "systemd-boot"
  9221. </literallayout>
  9222. </para></listitem>
  9223. <listitem><para><emphasis>Build the master image:</emphasis>
  9224. Build the <filename>core-image-testmaster</filename>
  9225. image.
  9226. The <filename>core-image-testmaster</filename>
  9227. recipe is provided as an example for a
  9228. "master" image and you can customize the image
  9229. recipe as you would any other recipe.
  9230. </para>
  9231. <para>Here are the image recipe requirements:
  9232. <itemizedlist>
  9233. <listitem><para>Inherits
  9234. <filename>core-image</filename>
  9235. so that kernel modules are installed.
  9236. </para></listitem>
  9237. <listitem><para>Installs normal linux utilities
  9238. not busybox ones (e.g.
  9239. <filename>bash</filename>,
  9240. <filename>coreutils</filename>,
  9241. <filename>tar</filename>,
  9242. <filename>gzip</filename>, and
  9243. <filename>kmod</filename>).
  9244. </para></listitem>
  9245. <listitem><para>Uses a custom
  9246. Initial RAM Disk (initramfs) image with a
  9247. custom installer.
  9248. A normal image that you can install usually
  9249. creates a single rootfs partition.
  9250. This image uses another installer that
  9251. creates a specific partition layout.
  9252. Not all Board Support Packages (BSPs)
  9253. can use an installer.
  9254. For such cases, you need to manually create
  9255. the following partition layout on the
  9256. target:
  9257. <itemizedlist>
  9258. <listitem><para>First partition mounted
  9259. under <filename>/boot</filename>,
  9260. labeled "boot".
  9261. </para></listitem>
  9262. <listitem><para>The main rootfs
  9263. partition where this image gets
  9264. installed, which is mounted under
  9265. <filename>/</filename>.
  9266. </para></listitem>
  9267. <listitem><para>Another partition
  9268. labeled "testrootfs" where test
  9269. images get deployed.
  9270. </para></listitem>
  9271. </itemizedlist>
  9272. </para></listitem>
  9273. </itemizedlist>
  9274. </para></listitem>
  9275. <listitem><para><emphasis>Install image:</emphasis>
  9276. Install the image that you just built on the target
  9277. system.
  9278. </para></listitem>
  9279. </orderedlist>
  9280. </para>
  9281. <para>
  9282. The final thing you need to do when setting
  9283. <filename>TEST_TARGET</filename> to "Systemd-bootTarget" is
  9284. to set up the test image:
  9285. <orderedlist>
  9286. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  9287. Make sure you have the following statements in
  9288. your <filename>local.conf</filename> file:
  9289. <literallayout class='monospaced'>
  9290. IMAGE_FSTYPES += "tar.gz"
  9291. INHERIT += "testimage"
  9292. TEST_TARGET = "Systemd-bootTarget"
  9293. TEST_TARGET_IP = "192.168.2.3"
  9294. </literallayout>
  9295. </para></listitem>
  9296. <listitem><para><emphasis>Build your test image:</emphasis>
  9297. Use BitBake to build the image:
  9298. <literallayout class='monospaced'>
  9299. $ bitbake core-image-sato
  9300. </literallayout>
  9301. </para></listitem>
  9302. </orderedlist>
  9303. </para>
  9304. </section>
  9305. <section id='power-control'>
  9306. <title>Power Control</title>
  9307. <para>
  9308. For most hardware targets other than SimpleRemoteTarget,
  9309. you can control power:
  9310. <itemizedlist>
  9311. <listitem><para>
  9312. You can use
  9313. <filename>TEST_POWERCONTROL_CMD</filename>
  9314. together with
  9315. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  9316. as a command that runs on the host and does power
  9317. cycling.
  9318. The test code passes one argument to that command:
  9319. off, on or cycle (off then on).
  9320. Here is an example that could appear in your
  9321. <filename>local.conf</filename> file:
  9322. <literallayout class='monospaced'>
  9323. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  9324. </literallayout>
  9325. In this example, the expect script does the
  9326. following:
  9327. <literallayout class='monospaced'>
  9328. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  9329. </literallayout>
  9330. It then runs a Python script that controls power
  9331. for a label called <filename>nuc1</filename>.
  9332. <note>
  9333. You need to customize
  9334. <filename>TEST_POWERCONTROL_CMD</filename>
  9335. and
  9336. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  9337. for your own setup.
  9338. The one requirement is that it accepts
  9339. "on", "off", and "cycle" as the last argument.
  9340. </note>
  9341. </para></listitem>
  9342. <listitem><para>
  9343. When no command is defined, it connects to the
  9344. device over SSH and uses the classic reboot command
  9345. to reboot the device.
  9346. Classic reboot is fine as long as the machine
  9347. actually reboots (i.e. the SSH test has not
  9348. failed).
  9349. It is useful for scenarios where you have a simple
  9350. setup, typically with a single board, and where
  9351. some manual interaction is okay from time to time.
  9352. </para></listitem>
  9353. </itemizedlist>
  9354. If you have no hardware to automatically perform power
  9355. control but still wish to experiment with automated
  9356. hardware testing, you can use the dialog-power-control
  9357. script that shows a dialog prompting you to perform the
  9358. required power action.
  9359. This script requires either KDialog or Zenity to be
  9360. installed.
  9361. To use this script, set the
  9362. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink>
  9363. variable as follows:
  9364. <literallayout class='monospaced'>
  9365. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  9366. </literallayout>
  9367. </para>
  9368. </section>
  9369. <section id='serial-console-connection'>
  9370. <title>Serial Console Connection</title>
  9371. <para>
  9372. For test target classes requiring a serial console
  9373. to interact with the bootloader (e.g. BeagleBoneTarget,
  9374. EdgeRouterTarget, and GrubTarget), you need to
  9375. specify a command to use to connect to the serial console
  9376. of the target machine by using the
  9377. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink>
  9378. variable and optionally the
  9379. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink>
  9380. variable.
  9381. </para>
  9382. <para>
  9383. These cases could be a serial terminal program if the
  9384. machine is connected to a local serial port, or a
  9385. <filename>telnet</filename> or
  9386. <filename>ssh</filename> command connecting to a remote
  9387. console server.
  9388. Regardless of the case, the command simply needs to
  9389. connect to the serial console and forward that connection
  9390. to standard input and output as any normal terminal
  9391. program does.
  9392. For example, to use the picocom terminal program on
  9393. serial device <filename>/dev/ttyUSB0</filename>
  9394. at 115200bps, you would set the variable as follows:
  9395. <literallayout class='monospaced'>
  9396. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  9397. </literallayout>
  9398. For local devices where the serial port device disappears
  9399. when the device reboots, an additional "serdevtry" wrapper
  9400. script is provided.
  9401. To use this wrapper, simply prefix the terminal command
  9402. with
  9403. <filename>${COREBASE}/scripts/contrib/serdevtry</filename>:
  9404. <literallayout class='monospaced'>
  9405. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b
  9406. 115200 /dev/ttyUSB0"
  9407. </literallayout>
  9408. </para>
  9409. </section>
  9410. </section>
  9411. <section id="qemu-image-running-tests">
  9412. <title>Running Tests</title>
  9413. <para>
  9414. You can start the tests automatically or manually:
  9415. <itemizedlist>
  9416. <listitem><para><emphasis>Automatically running tests:</emphasis>
  9417. To run the tests automatically after the
  9418. OpenEmbedded build system successfully creates an image,
  9419. first set the
  9420. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink>
  9421. variable to "1" in your <filename>local.conf</filename>
  9422. file in the
  9423. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  9424. <literallayout class='monospaced'>
  9425. TEST_IMAGE = "1"
  9426. </literallayout>
  9427. Next, build your image.
  9428. If the image successfully builds, the tests will be
  9429. run:
  9430. <literallayout class='monospaced'>
  9431. bitbake core-image-sato
  9432. </literallayout></para></listitem>
  9433. <listitem><para><emphasis>Manually running tests:</emphasis>
  9434. To manually run the tests, first globally inherit the
  9435. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  9436. class by editing your <filename>local.conf</filename>
  9437. file:
  9438. <literallayout class='monospaced'>
  9439. INHERIT += "testimage"
  9440. </literallayout>
  9441. Next, use BitBake to run the tests:
  9442. <literallayout class='monospaced'>
  9443. bitbake -c testimage <replaceable>image</replaceable>
  9444. </literallayout></para></listitem>
  9445. </itemizedlist>
  9446. </para>
  9447. <para>
  9448. All test files reside in
  9449. <filename>meta/lib/oeqa/runtime</filename> in the
  9450. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  9451. A test name maps directly to a Python module.
  9452. Each test module may contain a number of individual tests.
  9453. Tests are usually grouped together by the area
  9454. tested (e.g tests for systemd reside in
  9455. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  9456. </para>
  9457. <para>
  9458. You can add tests to any layer provided you place them in the
  9459. proper area and you extend
  9460. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  9461. in the <filename>local.conf</filename> file as normal.
  9462. Be sure that tests reside in
  9463. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  9464. <note>
  9465. Be sure that module names do not collide with module names
  9466. used in the default set of test modules in
  9467. <filename>meta/lib/oeqa/runtime</filename>.
  9468. </note>
  9469. </para>
  9470. <para>
  9471. You can change the set of tests run by appending or overriding
  9472. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  9473. variable in <filename>local.conf</filename>.
  9474. Each name in <filename>TEST_SUITES</filename> represents a
  9475. required test for the image.
  9476. Test modules named within <filename>TEST_SUITES</filename>
  9477. cannot be skipped even if a test is not suitable for an image
  9478. (e.g. running the RPM tests on an image without
  9479. <filename>rpm</filename>).
  9480. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  9481. build system to try to run all tests that are suitable for the
  9482. image (i.e. each test module may elect to skip itself).
  9483. </para>
  9484. <para>
  9485. The order you list tests in <filename>TEST_SUITES</filename>
  9486. is important and influences test dependencies.
  9487. Consequently, tests that depend on other tests should be added
  9488. after the test on which they depend.
  9489. For example, since the <filename>ssh</filename> test
  9490. depends on the
  9491. <filename>ping</filename> test, "ssh" needs to come after
  9492. "ping" in the list.
  9493. The test class provides no re-ordering or dependency handling.
  9494. <note>
  9495. Each module can have multiple classes with multiple test
  9496. methods.
  9497. And, Python <filename>unittest</filename> rules apply.
  9498. </note>
  9499. </para>
  9500. <para>
  9501. Here are some things to keep in mind when running tests:
  9502. <itemizedlist>
  9503. <listitem><para>The default tests for the image are defined
  9504. as:
  9505. <literallayout class='monospaced'>
  9506. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  9507. </literallayout></para></listitem>
  9508. <listitem><para>Add your own test to the list of the
  9509. by using the following:
  9510. <literallayout class='monospaced'>
  9511. TEST_SUITES_append = " mytest"
  9512. </literallayout></para></listitem>
  9513. <listitem><para>Run a specific list of tests as follows:
  9514. <literallayout class='monospaced'>
  9515. TEST_SUITES = "test1 test2 test3"
  9516. </literallayout>
  9517. Remember, order is important.
  9518. Be sure to place a test that is dependent on another test
  9519. later in the order.</para></listitem>
  9520. </itemizedlist>
  9521. </para>
  9522. </section>
  9523. <section id="exporting-tests">
  9524. <title>Exporting Tests</title>
  9525. <para>
  9526. You can export tests so that they can run independently of
  9527. the build system.
  9528. Exporting tests is required if you want to be able to hand
  9529. the test execution off to a scheduler.
  9530. You can only export tests that are defined in
  9531. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  9532. </para>
  9533. <para>
  9534. If your image is already built, make sure the following are set
  9535. in your <filename>local.conf</filename> file:
  9536. <literallayout class='monospaced'>
  9537. INHERIT +="testexport"
  9538. TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>"
  9539. TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>"
  9540. </literallayout>
  9541. You can then export the tests with the following BitBake
  9542. command form:
  9543. <literallayout class='monospaced'>
  9544. $ bitbake <replaceable>image</replaceable> -c testexport
  9545. </literallayout>
  9546. Exporting the tests places them in the
  9547. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9548. in
  9549. <filename>tmp/testexport/</filename><replaceable>image</replaceable>,
  9550. which is controlled by the
  9551. <filename>TEST_EXPORT_DIR</filename> variable.
  9552. </para>
  9553. <para>
  9554. You can now run the tests outside of the build environment:
  9555. <literallayout class='monospaced'>
  9556. $ cd tmp/testexport/<replaceable>image</replaceable>
  9557. $ ./runexported.py testdata.json
  9558. </literallayout>
  9559. </para>
  9560. <para>
  9561. Here is a complete example that shows IP addresses and uses
  9562. the <filename>core-image-sato</filename> image:
  9563. <literallayout class='monospaced'>
  9564. INHERIT +="testexport"
  9565. TEST_TARGET_IP = "192.168.7.2"
  9566. TEST_SERVER_IP = "192.168.7.1"
  9567. </literallayout>
  9568. Use BitBake to export the tests:
  9569. <literallayout class='monospaced'>
  9570. $ bitbake core-image-sato -c testexport
  9571. </literallayout>
  9572. Run the tests outside of the build environment using the
  9573. following:
  9574. <literallayout class='monospaced'>
  9575. $ cd tmp/testexport/core-image-sato
  9576. $ ./runexported.py testdata.json
  9577. </literallayout>
  9578. </para>
  9579. </section>
  9580. <section id="qemu-image-writing-new-tests">
  9581. <title>Writing New Tests</title>
  9582. <para>
  9583. As mentioned previously, all new test files need to be in the
  9584. proper place for the build system to find them.
  9585. New tests for additional functionality outside of the core
  9586. should be added to the layer that adds the functionality, in
  9587. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  9588. (as long as
  9589. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  9590. is extended in the layer's
  9591. <filename>layer.conf</filename> file as normal).
  9592. Just remember the following:
  9593. <itemizedlist>
  9594. <listitem><para>Filenames need to map directly to test
  9595. (module) names.
  9596. </para></listitem>
  9597. <listitem><para>Do not use module names that
  9598. collide with existing core tests.
  9599. </para></listitem>
  9600. <listitem><para>Minimally, an empty
  9601. <filename>__init__.py</filename> file must exist
  9602. in the runtime directory.
  9603. </para></listitem>
  9604. </itemizedlist>
  9605. </para>
  9606. <para>
  9607. To create a new test, start by copying an existing module
  9608. (e.g. <filename>syslog.py</filename> or
  9609. <filename>gcc.py</filename> are good ones to use).
  9610. Test modules can use code from
  9611. <filename>meta/lib/oeqa/utils</filename>, which are helper
  9612. classes.
  9613. </para>
  9614. <note>
  9615. Structure shell commands such that you rely on them and they
  9616. return a single code for success.
  9617. Be aware that sometimes you will need to parse the output.
  9618. See the <filename>df.py</filename> and
  9619. <filename>date.py</filename> modules for examples.
  9620. </note>
  9621. <para>
  9622. You will notice that all test classes inherit
  9623. <filename>oeRuntimeTest</filename>, which is found in
  9624. <filename>meta/lib/oetest.py</filename>.
  9625. This base class offers some helper attributes, which are
  9626. described in the following sections:
  9627. </para>
  9628. <section id='qemu-image-writing-tests-class-methods'>
  9629. <title>Class Methods</title>
  9630. <para>
  9631. Class methods are as follows:
  9632. <itemizedlist>
  9633. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  9634. Returns "True" if <filename>pkg</filename> is in the
  9635. installed package list of the image, which is based
  9636. on the manifest file that is generated during the
  9637. <filename>do_rootfs</filename> task.
  9638. </para></listitem>
  9639. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  9640. Returns "True" if the feature is in
  9641. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  9642. or
  9643. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  9644. </para></listitem>
  9645. </itemizedlist>
  9646. </para>
  9647. </section>
  9648. <section id='qemu-image-writing-tests-class-attributes'>
  9649. <title>Class Attributes</title>
  9650. <para>
  9651. Class attributes are as follows:
  9652. <itemizedlist>
  9653. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  9654. Equals "ps -ef" if <filename>procps</filename> is
  9655. installed in the image.
  9656. Otherwise, <filename>pscmd</filename> equals
  9657. "ps" (busybox).
  9658. </para></listitem>
  9659. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  9660. The called test context, which gives access to the
  9661. following attributes:
  9662. <itemizedlist>
  9663. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  9664. The BitBake datastore, which allows you to
  9665. use stuff such as
  9666. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  9667. </para></listitem>
  9668. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  9669. Used internally.
  9670. The tests do not need these.
  9671. </para></listitem>
  9672. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  9673. The absolute path to
  9674. <filename>meta/lib/oeqa/runtime/files</filename>,
  9675. which contains helper files for tests meant
  9676. for copying on the target such as small
  9677. files written in C for compilation.
  9678. </para></listitem>
  9679. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  9680. The target controller object used to deploy
  9681. and start an image on a particular target
  9682. (e.g. QemuTarget, SimpleRemote, and
  9683. Systemd-bootTarget).
  9684. Tests usually use the following:
  9685. <itemizedlist>
  9686. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  9687. The target's IP address.
  9688. </para></listitem>
  9689. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  9690. The host's IP address, which is
  9691. usually used by the DNF test
  9692. suite.
  9693. </para></listitem>
  9694. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  9695. The single, most used method.
  9696. This command is a wrapper for:
  9697. <filename>ssh root@host "cmd"</filename>.
  9698. The command returns a tuple:
  9699. (status, output), which are what
  9700. their names imply - the return code
  9701. of "cmd" and whatever output
  9702. it produces.
  9703. The optional timeout argument
  9704. represents the number of seconds the
  9705. test should wait for "cmd" to
  9706. return.
  9707. If the argument is "None", the
  9708. test uses the default instance's
  9709. timeout period, which is 300
  9710. seconds.
  9711. If the argument is "0", the test
  9712. runs until the command returns.
  9713. </para></listitem>
  9714. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  9715. <filename>scp localpath root@ip:remotepath</filename>.
  9716. </para></listitem>
  9717. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  9718. <filename>scp root@host:remotepath localpath</filename>.
  9719. </para></listitem>
  9720. </itemizedlist></para></listitem>
  9721. </itemizedlist></para></listitem>
  9722. </itemizedlist>
  9723. </para>
  9724. </section>
  9725. <section id='qemu-image-writing-tests-instance-attributes'>
  9726. <title>Instance Attributes</title>
  9727. <para>
  9728. A single instance attribute exists, which is
  9729. <filename>target</filename>.
  9730. The <filename>target</filename> instance attribute is
  9731. identical to the class attribute of the same name, which
  9732. is described in the previous section.
  9733. This attribute exists as both an instance and class
  9734. attribute so tests can use
  9735. <filename>self.target.run(cmd)</filename> in instance
  9736. methods instead of
  9737. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  9738. </para>
  9739. </section>
  9740. </section>
  9741. <section id='installing-packages-in-the-dut-without-the-package-manager'>
  9742. <title>Installing Packages in the DUT Without the Package Manager</title>
  9743. <para>
  9744. When a test requires a package built by BitBake, it is possible
  9745. to install that package.
  9746. Installing the package does not require a package manager be
  9747. installed in the device under test (DUT).
  9748. It does, however, require an SSH connection and the target must
  9749. be using the <filename>sshcontrol</filename> class.
  9750. <note>
  9751. This method uses <filename>scp</filename> to copy files
  9752. from the host to the target, which causes permissions and
  9753. special attributes to be lost.
  9754. </note>
  9755. </para>
  9756. <para>
  9757. A JSON file is used to define the packages needed by a test.
  9758. This file must be in the same path as the file used to define
  9759. the tests.
  9760. Furthermore, the filename must map directly to the test
  9761. module name with a <filename>.json</filename> extension.
  9762. </para>
  9763. <para>
  9764. The JSON file must include an object with the test name as
  9765. keys of an object or an array.
  9766. This object (or array of objects) uses the following data:
  9767. <itemizedlist>
  9768. <listitem><para>"pkg" - A mandatory string that is the
  9769. name of the package to be installed.
  9770. </para></listitem>
  9771. <listitem><para>"rm" - An optional boolean, which defaults
  9772. to "false", that specifies to remove the package after
  9773. the test.
  9774. </para></listitem>
  9775. <listitem><para>"extract" - An optional boolean, which
  9776. defaults to "false", that specifies if the package must
  9777. be extracted from the package format.
  9778. When set to "true", the package is not automatically
  9779. installed into the DUT.
  9780. </para></listitem>
  9781. </itemizedlist>
  9782. </para>
  9783. <para>
  9784. Following is an example JSON file that handles test "foo"
  9785. installing package "bar" and test "foobar" installing
  9786. packages "foo" and "bar".
  9787. Once the test is complete, the packages are removed from the
  9788. DUT.
  9789. <literallayout class='monospaced'>
  9790. {
  9791. "foo": {
  9792. "pkg": "bar"
  9793. },
  9794. "foobar": [
  9795. {
  9796. "pkg": "foo",
  9797. "rm": true
  9798. },
  9799. {
  9800. "pkg": "bar",
  9801. "rm": true
  9802. }
  9803. ]
  9804. }
  9805. </literallayout>
  9806. </para>
  9807. </section>
  9808. </section>
  9809. <section id='usingpoky-debugging-tools-and-techniques'>
  9810. <title>Debugging Tools and Techniques</title>
  9811. <para>
  9812. The exact method for debugging build failures depends on the nature
  9813. of the problem and on the system's area from which the bug
  9814. originates.
  9815. Standard debugging practices such as comparison against the last
  9816. known working version with examination of the changes and the
  9817. re-application of steps to identify the one causing the problem are
  9818. valid for the Yocto Project just as they are for any other system.
  9819. Even though it is impossible to detail every possible potential
  9820. failure, this section provides some general tips to aid in
  9821. debugging given a variety of situations.
  9822. <note><title>Tip</title>
  9823. A useful feature for debugging is the error reporting tool.
  9824. Configuring the Yocto Project to use this tool causes the
  9825. OpenEmbedded build system to produce error reporting commands as
  9826. part of the console output.
  9827. You can enter the commands after the build completes to log
  9828. error information into a common database, that can help you
  9829. figure out what might be going wrong.
  9830. For information on how to enable and use this feature, see the
  9831. "<link linkend='using-the-error-reporting-tool'>Using the Error Reporting Tool</link>"
  9832. section.
  9833. </note>
  9834. </para>
  9835. <para>
  9836. The following list shows the debugging topics in the remainder of
  9837. this section:
  9838. <itemizedlist>
  9839. <listitem><para>
  9840. "<link linkend='dev-debugging-viewing-logs-from-failed-tasks'>Viewing Logs from Failed Tasks</link>"
  9841. describes how to find and view logs from tasks that
  9842. failed during the build process.
  9843. </para></listitem>
  9844. <listitem><para>
  9845. "<link linkend='dev-debugging-viewing-variable-values'>Viewing Variable Values</link>"
  9846. describes how to use the BitBake <filename>-e</filename>
  9847. option to examine variable values after a recipe has been
  9848. parsed.
  9849. </para></listitem>
  9850. <listitem><para>
  9851. "<link linkend='viewing-package-information-with-oe-pkgdata-util'>Viewing Package Information with <filename>oe-pkgdata-util</filename></link>"
  9852. describes how to use the
  9853. <filename>oe-pkgdata-util</filename> utility to query
  9854. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  9855. and display package-related information for built
  9856. packages.
  9857. </para></listitem>
  9858. <listitem><para>
  9859. "<link linkend='dev-viewing-dependencies-between-recipes-and-tasks'>Viewing Dependencies Between Recipes and Tasks</link>"
  9860. describes how to use the BitBake <filename>-g</filename>
  9861. option to display recipe dependency information used
  9862. during the build.
  9863. </para></listitem>
  9864. <listitem><para>
  9865. "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  9866. describes how to use the
  9867. <filename>bitbake-dumpsig</filename> command in
  9868. conjunction with key subdirectories in the
  9869. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9870. to determine variable dependencies.
  9871. </para></listitem>
  9872. <listitem><para>
  9873. "<link linkend='dev-debugging-taskrunning'>Running Specific Tasks</link>"
  9874. describes how to use several BitBake options (e.g.
  9875. <filename>-c</filename>, <filename>-C</filename>, and
  9876. <filename>-f</filename>) to run specific tasks in the
  9877. build chain.
  9878. It can be useful to run tasks "out-of-order" when trying
  9879. isolate build issues.
  9880. </para></listitem>
  9881. <listitem><para>
  9882. "<link linkend='dev-debugging-bitbake'>General BitBake Problems</link>"
  9883. describes how to use BitBake's <filename>-D</filename>
  9884. debug output option to reveal more about what BitBake is
  9885. doing during the build.
  9886. </para></listitem>
  9887. <listitem><para>
  9888. "<link linkend='dev-debugging-buildfile'>Building with No Dependencies</link>"
  9889. describes how to use the BitBake <filename>-b</filename>
  9890. option to build a recipe while ignoring dependencies.
  9891. </para></listitem>
  9892. <listitem><para>
  9893. "<link linkend='recipe-logging-mechanisms'>Recipe Logging Mechanisms</link>"
  9894. describes how to use the many recipe logging functions
  9895. to produce debugging output and report errors and warnings.
  9896. </para></listitem>
  9897. <listitem><para>
  9898. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  9899. describes how to debug situations where the build consists
  9900. of several parts that are run simultaneously and when the
  9901. output or result of one part is not ready for use with a
  9902. different part of the build that depends on that output.
  9903. </para></listitem>
  9904. <listitem><para>
  9905. "<link linkend='platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</link>"
  9906. describes how to use GDB to allow you to examine running
  9907. programs, which can help you fix problems.
  9908. </para></listitem>
  9909. <listitem><para>
  9910. "<link linkend='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>Debugging with the GNU Project Debugger (GDB) on the Target</link>"
  9911. describes how to use GDB directly on target hardware for
  9912. debugging.
  9913. </para></listitem>
  9914. <listitem><para>
  9915. "<link linkend='dev-other-debugging-others'>Other Debugging Tips</link>"
  9916. describes miscellaneous debugging tips that can be useful.
  9917. </para></listitem>
  9918. </itemizedlist>
  9919. </para>
  9920. <para>
  9921. For debugging information within the popular
  9922. <trademark class='trade'>Eclipse</trademark> IDE, see the
  9923. "<ulink url='&YOCTO_DOCS_SDK_URL;#adt-eclipse'>Working within Eclipse</ulink>"
  9924. section in the Yocto Project Application Development and the
  9925. Extensible Software Development Kit (eSDK) manual.
  9926. </para>
  9927. <section id='dev-debugging-viewing-logs-from-failed-tasks'>
  9928. <title>Viewing Logs from Failed Tasks</title>
  9929. <para>
  9930. You can find the log for a task in the file
  9931. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>.
  9932. For example, the log for the
  9933. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  9934. task of the QEMU minimal image for the x86 machine
  9935. (<filename>qemux86</filename>) might be in
  9936. <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>.
  9937. To see the commands
  9938. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  9939. ran to generate a log, look at the corresponding
  9940. <filename>run.do_</filename><replaceable>taskname</replaceable>
  9941. file in the same directory.
  9942. </para>
  9943. <para>
  9944. <filename>log.do_</filename><replaceable>taskname</replaceable>
  9945. and
  9946. <filename>run.do_</filename><replaceable>taskname</replaceable>
  9947. are actually symbolic links to
  9948. <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>
  9949. and
  9950. <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>,
  9951. where <replaceable>pid</replaceable> is the PID the task had
  9952. when it ran.
  9953. The symlinks always point to the files corresponding to the most
  9954. recent run.
  9955. </para>
  9956. </section>
  9957. <section id='dev-debugging-viewing-variable-values'>
  9958. <title>Viewing Variable Values</title>
  9959. <para>
  9960. BitBake's <filename>-e</filename> option is used to display
  9961. variable values after parsing.
  9962. The following command displays the variable values after the
  9963. configuration files (i.e. <filename>local.conf</filename>,
  9964. <filename>bblayers.conf</filename>,
  9965. <filename>bitbake.conf</filename> and so forth) have been
  9966. parsed:
  9967. <literallayout class='monospaced'>
  9968. $ bitbake -e
  9969. </literallayout>
  9970. The following command displays variable values after a specific
  9971. recipe has been parsed.
  9972. The variables include those from the configuration as well:
  9973. <literallayout class='monospaced'>
  9974. $ bitbake -e recipename
  9975. </literallayout>
  9976. <note><para>
  9977. Each recipe has its own private set of variables
  9978. (datastore).
  9979. Internally, after parsing the configuration, a copy of the
  9980. resulting datastore is made prior to parsing each recipe.
  9981. This copying implies that variables set in one recipe will
  9982. not be visible to other recipes.</para>
  9983. <para>Likewise, each task within a recipe gets a private
  9984. datastore based on the recipe datastore, which means that
  9985. variables set within one task will not be visible to
  9986. other tasks.</para>
  9987. </note>
  9988. </para>
  9989. <para>
  9990. In the output of <filename>bitbake -e</filename>, each
  9991. variable is preceded by a description of how the variable
  9992. got its value, including temporary values that were later
  9993. overriden.
  9994. This description also includes variable flags (varflags) set on
  9995. the variable.
  9996. The output can be very helpful during debugging.
  9997. </para>
  9998. <para>
  9999. Variables that are exported to the environment are preceded by
  10000. <filename>export</filename> in the output of
  10001. <filename>bitbake -e</filename>.
  10002. See the following example:
  10003. <literallayout class='monospaced'>
  10004. export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
  10005. </literallayout>
  10006. </para>
  10007. <para>
  10008. In addition to variable values, the output of the
  10009. <filename>bitbake -e</filename> and
  10010. <filename>bitbake -e</filename>&nbsp;<replaceable>recipe</replaceable>
  10011. commands includes the following information:
  10012. <itemizedlist>
  10013. <listitem><para>
  10014. The output starts with a tree listing all configuration
  10015. files and classes included globally, recursively listing
  10016. the files they include or inherit in turn.
  10017. Much of the behavior of the OpenEmbedded build system
  10018. (including the behavior of the
  10019. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>)
  10020. is implemented in the
  10021. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink>
  10022. class and the classes it inherits, rather than being
  10023. built into BitBake itself.
  10024. </para></listitem>
  10025. <listitem><para>
  10026. After the variable values, all functions appear in the
  10027. output.
  10028. For shell functions, variables referenced within the
  10029. function body are expanded.
  10030. If a function has been modified using overrides or
  10031. using override-style operators like
  10032. <filename>_append</filename> and
  10033. <filename>_prepend</filename>, then the final assembled
  10034. function body appears in the output.
  10035. </para></listitem>
  10036. </itemizedlist>
  10037. </para>
  10038. </section>
  10039. <section id='viewing-package-information-with-oe-pkgdata-util'>
  10040. <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title>
  10041. <para>
  10042. You can use the <filename>oe-pkgdata-util</filename>
  10043. command-line utility to query
  10044. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  10045. and display various package-related information.
  10046. When you use the utility, you must use it to view information
  10047. on packages that have already been built.
  10048. </para>
  10049. <para>
  10050. Following are a few of the available
  10051. <filename>oe-pkgdata-util</filename> subcommands.
  10052. <note>
  10053. You can use the standard * and ? globbing wildcards as part
  10054. of package names and paths.
  10055. </note>
  10056. <itemizedlist>
  10057. <listitem><para>
  10058. <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>:
  10059. Lists all packages that have been built, optionally
  10060. limiting the match to packages that match
  10061. <replaceable>pattern</replaceable>.
  10062. </para></listitem>
  10063. <listitem><para>
  10064. <filename>oe-pkgdata-util list-pkg-files&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  10065. Lists the files and directories contained in the given
  10066. packages.
  10067. <note>
  10068. <para>
  10069. A different way to view the contents of a package is
  10070. to look at the
  10071. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  10072. directory of the recipe that generates the
  10073. package.
  10074. This directory is created by the
  10075. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  10076. task and has one subdirectory for each package the
  10077. recipe generates, which contains the files stored in
  10078. that package.</para>
  10079. <para>
  10080. If you want to inspect the
  10081. <filename>${WORKDIR}/packages-split</filename>
  10082. directory, make sure that
  10083. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  10084. is not enabled when you build the recipe.
  10085. </para>
  10086. </note>
  10087. </para></listitem>
  10088. <listitem><para>
  10089. <filename>oe-pkgdata-util find-path&nbsp;</filename><replaceable>path</replaceable><filename>&nbsp;...</filename>:
  10090. Lists the names of the packages that contain the given
  10091. paths.
  10092. For example, the following tells us that
  10093. <filename>/usr/share/man/man1/make.1</filename>
  10094. is contained in the <filename>make-doc</filename>
  10095. package:
  10096. <literallayout class='monospaced'>
  10097. $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
  10098. make-doc: /usr/share/man/man1/make.1
  10099. </literallayout>
  10100. </para></listitem>
  10101. <listitem><para>
  10102. <filename>oe-pkgdata-util lookup-recipe&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  10103. Lists the name of the recipes that
  10104. produce the given packages.
  10105. </para></listitem>
  10106. </itemizedlist>
  10107. </para>
  10108. <para>
  10109. For more information on the <filename>oe-pkgdata-util</filename>
  10110. command, use the help facility:
  10111. <literallayout class='monospaced'>
  10112. $ oe-pkgdata-util &dash;&dash;help
  10113. $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help
  10114. </literallayout>
  10115. </para>
  10116. </section>
  10117. <section id='dev-viewing-dependencies-between-recipes-and-tasks'>
  10118. <title>Viewing Dependencies Between Recipes and Tasks</title>
  10119. <para>
  10120. Sometimes it can be hard to see why BitBake wants to build other
  10121. recipes before the one you have specified.
  10122. Dependency information can help you understand why a recipe is
  10123. built.
  10124. </para>
  10125. <para>
  10126. To generate dependency information for a recipe, run the
  10127. following command:
  10128. <literallayout class='monospaced'>
  10129. $ bitbake -g <replaceable>recipename</replaceable>
  10130. </literallayout>
  10131. This command writes the following files in the current
  10132. directory:
  10133. <itemizedlist>
  10134. <listitem><para>
  10135. <filename>pn-buildlist</filename>: A list of
  10136. recipes/targets involved in building
  10137. <replaceable>recipename</replaceable>.
  10138. "Involved" here means that at least one task from the
  10139. recipe needs to run when building
  10140. <replaceable>recipename</replaceable> from scratch.
  10141. Targets that are in
  10142. <ulink url='&YOCTO_DOCS_REF_URL;#var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></ulink>
  10143. are not listed.
  10144. </para></listitem>
  10145. <listitem><para>
  10146. <filename>task-depends.dot</filename>: A graph showing
  10147. dependencies between tasks.
  10148. </para></listitem>
  10149. </itemizedlist>
  10150. </para>
  10151. <para>
  10152. The graphs are in
  10153. <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink>
  10154. format and can be converted to images (e.g. using the
  10155. <filename>dot</filename> tool from
  10156. <ulink url='http://www.graphviz.org/'>Graphviz</ulink>).
  10157. <note><title>Notes</title>
  10158. <itemizedlist>
  10159. <listitem><para>
  10160. DOT files use a plain text format.
  10161. The graphs generated using the
  10162. <filename>bitbake -g</filename> command are often so
  10163. large as to be difficult to read without special
  10164. pruning (e.g. with Bitbake's
  10165. <filename>-I</filename> option) and processing.
  10166. Despite the form and size of the graphs, the
  10167. corresponding <filename>.dot</filename> files can
  10168. still be possible to read and provide useful
  10169. information.
  10170. </para>
  10171. <para>As an example, the
  10172. <filename>task-depends.dot</filename> file contains
  10173. lines such as the following:
  10174. <literallayout class='monospaced'>
  10175. "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
  10176. </literallayout>
  10177. The above example line reveals that the
  10178. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  10179. task in <filename>libxslt</filename> depends on the
  10180. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  10181. task in <filename>libxml2</filename>, which is a
  10182. normal
  10183. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  10184. dependency between the two recipes.
  10185. </para></listitem>
  10186. <listitem><para>
  10187. For an example of how <filename>.dot</filename>
  10188. files can be processed, see the
  10189. <filename>scripts/contrib/graph-tool</filename>
  10190. Python script, which finds and displays paths
  10191. between graph nodes.
  10192. </para></listitem>
  10193. </itemizedlist>
  10194. </note>
  10195. </para>
  10196. <para>
  10197. You can use a different method to view dependency information
  10198. by using the following command:
  10199. <literallayout class='monospaced'>
  10200. $ bitbake -g -u taskexp <replaceable>recipename</replaceable>
  10201. </literallayout>
  10202. This command displays a GUI window from which you can view
  10203. build-time and runtime dependencies for the recipes involved in
  10204. building <replaceable>recipename</replaceable>.
  10205. </para>
  10206. </section>
  10207. <section id='dev-viewing-task-variable-dependencies'>
  10208. <title>Viewing Task Variable Dependencies</title>
  10209. <para>
  10210. As mentioned in the
  10211. "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>"
  10212. section of the BitBake User Manual, BitBake tries to
  10213. automatically determine what variables a task depends on so
  10214. that it can rerun the task if any values of the variables
  10215. change.
  10216. This determination is usually reliable.
  10217. However, if you do things like construct variable names at
  10218. runtime, then you might have to manually declare dependencies
  10219. on those variables using <filename>vardeps</filename> as
  10220. described in the
  10221. "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
  10222. section of the BitBake User Manual.
  10223. </para>
  10224. <para>
  10225. If you are unsure whether a variable dependency is being
  10226. picked up automatically for a given task, you can list the
  10227. variable dependencies BitBake has determined by doing the
  10228. following:
  10229. <orderedlist>
  10230. <listitem><para>
  10231. Build the recipe containing the task:
  10232. <literallayout class='monospaced'>
  10233. $ bitbake <replaceable>recipename</replaceable>
  10234. </literallayout>
  10235. </para></listitem>
  10236. <listitem><para>
  10237. Inside the
  10238. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink>
  10239. directory, find the signature data
  10240. (<filename>sigdata</filename>) file that corresponds
  10241. to the task.
  10242. The <filename>sigdata</filename> files contain a pickled
  10243. Python database of all the metadata that went into
  10244. creating the input checksum for the task.
  10245. As an example, for the
  10246. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  10247. task of the <filename>db</filename> recipe, the
  10248. <filename>sigdata</filename> file might be found in the
  10249. following location:
  10250. <literallayout class='monospaced'>
  10251. ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  10252. </literallayout>
  10253. For tasks that are accelerated through the shared state
  10254. (<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#shared-state-cache'>sstate</ulink>)
  10255. cache, an additional <filename>siginfo</filename> file
  10256. is written into
  10257. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  10258. along with the cached task output.
  10259. The <filename>siginfo</filename> files contain exactly
  10260. the same information as <filename>sigdata</filename>
  10261. files.
  10262. </para></listitem>
  10263. <listitem><para>
  10264. Run <filename>bitbake-dumpsig</filename> on the
  10265. <filename>sigdata</filename> or
  10266. <filename>siginfo</filename> file.
  10267. Here is an example:
  10268. <literallayout class='monospaced'>
  10269. $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  10270. </literallayout>
  10271. In the output of the above command, you will find a
  10272. line like the following, which lists all the (inferred)
  10273. variable dependencies for the task.
  10274. This list also includes indirect dependencies from
  10275. variables depending on other variables, recursively.
  10276. <literallayout class='monospaced'>
  10277. Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
  10278. </literallayout>
  10279. <note>
  10280. Functions (e.g. <filename>base_do_fetch</filename>)
  10281. also count as variable dependencies.
  10282. These functions in turn depend on the variables they
  10283. reference.
  10284. </note>
  10285. The output of <filename>bitbake-dumpsig</filename> also
  10286. includes the value each variable had, a list of
  10287. dependencies for each variable, and
  10288. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink>
  10289. information.
  10290. </para></listitem>
  10291. </orderedlist>
  10292. </para>
  10293. <para>
  10294. There is also a <filename>bitbake-diffsigs</filename> command
  10295. for comparing two <filename>siginfo</filename> or
  10296. <filename>sigdata</filename> files.
  10297. This command can be helpful when trying to figure out what
  10298. changed between two versions of a task.
  10299. If you call <filename>bitbake-diffsigs</filename> with just one
  10300. file, the command behaves like
  10301. <filename>bitbake-dumpsig</filename>.
  10302. </para>
  10303. <para>
  10304. You can also use BitBake to dump out the signature construction
  10305. information without executing tasks by using either of the
  10306. following BitBake command-line options:
  10307. <literallayout class='monospaced'>
  10308. &dash;&dash;dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable>
  10309. -S <replaceable>SIGNATURE_HANDLER</replaceable>
  10310. </literallayout>
  10311. <note>
  10312. Two common values for
  10313. <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and
  10314. "printdiff", which dump only the signature or compare the
  10315. dumped signature with the cached one, respectively.
  10316. </note>
  10317. Using BitBake with either of these options causes BitBake to
  10318. dump out <filename>sigdata</filename> files in the
  10319. <filename>stamps</filename> directory for every task it would
  10320. have executed instead of building the specified target package.
  10321. </para>
  10322. </section>
  10323. <section id='dev-debugging-taskrunning'>
  10324. <title>Running Specific Tasks</title>
  10325. <para>
  10326. Any given recipe consists of a set of tasks.
  10327. The standard BitBake behavior in most cases is:
  10328. <filename>do_fetch</filename>,
  10329. <filename>do_unpack</filename>,
  10330. <filename>do_patch</filename>,
  10331. <filename>do_configure</filename>,
  10332. <filename>do_compile</filename>,
  10333. <filename>do_install</filename>,
  10334. <filename>do_package</filename>,
  10335. <filename>do_package_write_*</filename>, and
  10336. <filename>do_build</filename>.
  10337. The default task is <filename>do_build</filename> and any tasks
  10338. on which it depends build first.
  10339. Some tasks, such as <filename>do_devshell</filename>, are not
  10340. part of the default build chain.
  10341. If you wish to run a task that is not part of the default build
  10342. chain, you can use the <filename>-c</filename> option in
  10343. BitBake.
  10344. Here is an example:
  10345. <literallayout class='monospaced'>
  10346. $ bitbake matchbox-desktop -c devshell
  10347. </literallayout>
  10348. </para>
  10349. <para>
  10350. The <filename>-c</filename> option respects task dependencies,
  10351. which means that all other tasks (including tasks from other
  10352. recipes) that the specified task depends on will be run before
  10353. the task.
  10354. Even when you manually specify a task to run with
  10355. <filename>-c</filename>, BitBake will only run the task if it
  10356. considers it "out of date".
  10357. See the
  10358. "<ulink url='&YOCTO_DOCS_OVERVIEW_URL;#stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</ulink>"
  10359. section in the Yocto Project Overview Manual for how BitBake
  10360. determines whether a task is "out of date".
  10361. </para>
  10362. <para>
  10363. If you want to force an up-to-date task to be rerun (e.g.
  10364. because you made manual modifications to the recipe's
  10365. <ulink linkend='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  10366. that you want to try out), then you can use the
  10367. <filename>-f</filename> option.
  10368. <note>
  10369. The reason <filename>-f</filename> is never required when
  10370. running the
  10371. <ulink linkend='&YOCTO_DOCS_REF_URL;#ref-tasks-devshell'><filename>do_devshell</filename></ulink>
  10372. task is because the
  10373. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename>
  10374. variable flag is already set for the task.
  10375. </note>
  10376. The following example shows one way you can use the
  10377. <filename>-f</filename> option:
  10378. <literallayout class='monospaced'>
  10379. $ bitbake matchbox-desktop
  10380. .
  10381. .
  10382. make some changes to the source code in the work directory
  10383. .
  10384. .
  10385. $ bitbake matchbox-desktop -c compile -f
  10386. $ bitbake matchbox-desktop
  10387. </literallayout>
  10388. </para>
  10389. <para>
  10390. This sequence first builds and then recompiles
  10391. <filename>matchbox-desktop</filename>.
  10392. The last command reruns all tasks (basically the packaging
  10393. tasks) after the compile.
  10394. BitBake recognizes that the <filename>do_compile</filename>
  10395. task was rerun and therefore understands that the other tasks
  10396. also need to be run again.
  10397. </para>
  10398. <para>
  10399. Another, shorter way to rerun a task and all
  10400. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>
  10401. that depend on it is to use the <filename>-C</filename>
  10402. option.
  10403. <note>
  10404. This option is upper-cased and is separate from the
  10405. <filename>-c</filename> option, which is lower-cased.
  10406. </note>
  10407. Using this option invalidates the given task and then runs the
  10408. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-build'><filename>do_build</filename></ulink>
  10409. task, which is the default task if no task is given, and the
  10410. tasks on which it depends.
  10411. You could replace the final two commands in the previous example
  10412. with the following single command:
  10413. <literallayout class='monospaced'>
  10414. $ bitbake matchbox-desktop -C compile
  10415. </literallayout>
  10416. Internally, the <filename>-f</filename> and
  10417. <filename>-C</filename> options work by tainting (modifying) the
  10418. input checksum of the specified task.
  10419. This tainting indirectly causes the task and its
  10420. dependent tasks to be rerun through the normal task dependency
  10421. mechanisms.
  10422. <note>
  10423. BitBake explicitly keeps track of which tasks have been
  10424. tainted in this fashion, and will print warnings such as the
  10425. following for builds involving such tasks:
  10426. <literallayout class='monospaced'>
  10427. WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
  10428. </literallayout>
  10429. The purpose of the warning is to let you know that the work
  10430. directory and build output might not be in the clean state
  10431. they would be in for a "normal" build, depending on what
  10432. actions you took.
  10433. To get rid of such warnings, you can remove the work
  10434. directory and rebuild the recipe, as follows:
  10435. <literallayout class='monospaced'>
  10436. $ bitbake matchbox-desktop -c clean
  10437. $ bitbake matchbox-desktop
  10438. </literallayout>
  10439. </note>
  10440. </para>
  10441. <para>
  10442. You can view a list of tasks in a given package by running the
  10443. <filename>do_listtasks</filename> task as follows:
  10444. <literallayout class='monospaced'>
  10445. $ bitbake matchbox-desktop -c listtasks
  10446. </literallayout>
  10447. The results appear as output to the console and are also in the
  10448. file <filename>${WORKDIR}/temp/log.do_listtasks</filename>.
  10449. </para>
  10450. </section>
  10451. <section id='dev-debugging-bitbake'>
  10452. <title>General BitBake Problems</title>
  10453. <para>
  10454. You can see debug output from BitBake by using the
  10455. <filename>-D</filename> option.
  10456. The debug output gives more information about what BitBake
  10457. is doing and the reason behind it.
  10458. Each <filename>-D</filename> option you use increases the
  10459. logging level.
  10460. The most common usage is <filename>-DDD</filename>.
  10461. </para>
  10462. <para>
  10463. The output from
  10464. <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable>
  10465. can reveal why BitBake chose a certain version of a package or
  10466. why BitBake picked a certain provider.
  10467. This command could also help you in a situation where you think
  10468. BitBake did something unexpected.
  10469. </para>
  10470. </section>
  10471. <section id='dev-debugging-buildfile'>
  10472. <title>Building with No Dependencies</title>
  10473. <para>
  10474. To build a specific recipe (<filename>.bb</filename> file),
  10475. you can use the following command form:
  10476. <literallayout class='monospaced'>
  10477. $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb
  10478. </literallayout>
  10479. This command form does not check for dependencies.
  10480. Consequently, you should use it only when you know existing
  10481. dependencies have been met.
  10482. <note>
  10483. You can also specify fragments of the filename.
  10484. In this case, BitBake checks for a unique match.
  10485. </note>
  10486. </para>
  10487. </section>
  10488. <section id='recipe-logging-mechanisms'>
  10489. <title>Recipe Logging Mechanisms</title>
  10490. <para>
  10491. The Yocto Project provides several logging functions for
  10492. producing debugging output and reporting errors and warnings.
  10493. For Python functions, the following logging functions exist.
  10494. All of these functions log to
  10495. <filename>${T}/log.do_</filename><replaceable>task</replaceable>,
  10496. and can also log to standard output (stdout) with the right
  10497. settings:
  10498. <itemizedlist>
  10499. <listitem><para>
  10500. <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>:
  10501. Writes <replaceable>msg</replaceable> as is to the
  10502. log while also logging to stdout.
  10503. </para></listitem>
  10504. <listitem><para>
  10505. <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>:
  10506. Writes "NOTE: <replaceable>msg</replaceable>" to the
  10507. log.
  10508. Also logs to stdout if BitBake is called with "-v".
  10509. </para></listitem>
  10510. <listitem><para>
  10511. <filename>bb.debug(</filename><replaceable>level</replaceable><filename>,&nbsp;</filename><replaceable>msg</replaceable><filename>)</filename>:
  10512. Writes "DEBUG: <replaceable>msg</replaceable>" to the
  10513. log.
  10514. Also logs to stdout if the log level is greater than or
  10515. equal to <replaceable>level</replaceable>.
  10516. See the
  10517. "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>"
  10518. option in the BitBake User Manual for more information.
  10519. </para></listitem>
  10520. <listitem><para>
  10521. <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>:
  10522. Writes "WARNING: <replaceable>msg</replaceable>" to the
  10523. log while also logging to stdout.
  10524. </para></listitem>
  10525. <listitem><para>
  10526. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>:
  10527. Writes "ERROR: <replaceable>msg</replaceable>" to the
  10528. log while also logging to standard out (stdout).
  10529. <note>
  10530. Calling this function does not cause the task to fail.
  10531. </note>
  10532. </para></listitem>
  10533. <listitem><para>
  10534. <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>:
  10535. This logging function is similar to
  10536. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>
  10537. but also causes the calling task to fail.
  10538. <note>
  10539. <filename>bb.fatal()</filename> raises an exception,
  10540. which means you do not need to put a "return"
  10541. statement after the function.
  10542. </note>
  10543. </para></listitem>
  10544. </itemizedlist>
  10545. </para>
  10546. <para>
  10547. The same logging functions are also available in shell
  10548. functions, under the names
  10549. <filename>bbplain</filename>, <filename>bbnote</filename>,
  10550. <filename>bbdebug</filename>, <filename>bbwarn</filename>,
  10551. <filename>bberror</filename>, and <filename>bbfatal</filename>.
  10552. The
  10553. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-logging'><filename>logging</filename></ulink>
  10554. class implements these functions.
  10555. See that class in the
  10556. <filename>meta/classes</filename> folder of the
  10557. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  10558. for information.
  10559. </para>
  10560. <section id='logging-with-python'>
  10561. <title>Logging With Python</title>
  10562. <para>
  10563. When creating recipes using Python and inserting code that
  10564. handles build logs, keep in mind the goal is to have
  10565. informative logs while keeping the console as "silent" as
  10566. possible.
  10567. Also, if you want status messages in the log, use the
  10568. "debug" loglevel.
  10569. </para>
  10570. <para>
  10571. Following is an example written in Python.
  10572. The code handles logging for a function that determines the
  10573. number of tasks needed to be run.
  10574. See the
  10575. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-listtasks'><filename>do_listtasks</filename></ulink>"
  10576. section for additional information:
  10577. <literallayout class='monospaced'>
  10578. python do_listtasks() {
  10579. bb.debug(2, "Starting to figure out the task list")
  10580. if noteworthy_condition:
  10581. bb.note("There are 47 tasks to run")
  10582. bb.debug(2, "Got to point xyz")
  10583. if warning_trigger:
  10584. bb.warn("Detected warning_trigger, this might be a problem later.")
  10585. if recoverable_error:
  10586. bb.error("Hit recoverable_error, you really need to fix this!")
  10587. if fatal_error:
  10588. bb.fatal("fatal_error detected, unable to print the task list")
  10589. bb.plain("The tasks present are abc")
  10590. bb.debug(2, "Finished figuring out the tasklist")
  10591. }
  10592. </literallayout>
  10593. </para>
  10594. </section>
  10595. <section id='logging-with-bash'>
  10596. <title>Logging With Bash</title>
  10597. <para>
  10598. When creating recipes using Bash and inserting code that
  10599. handles build logs, you have the same goals - informative
  10600. with minimal console output.
  10601. The syntax you use for recipes written in Bash is similar
  10602. to that of recipes written in Python described in the
  10603. previous section.
  10604. </para>
  10605. <para>
  10606. Following is an example written in Bash.
  10607. The code logs the progress of the <filename>do_my_function</filename> function.
  10608. <literallayout class='monospaced'>
  10609. do_my_function() {
  10610. bbdebug 2 "Running do_my_function"
  10611. if [ exceptional_condition ]; then
  10612. bbnote "Hit exceptional_condition"
  10613. fi
  10614. bbdebug 2 "Got to point xyz"
  10615. if [ warning_trigger ]; then
  10616. bbwarn "Detected warning_trigger, this might cause a problem later."
  10617. fi
  10618. if [ recoverable_error ]; then
  10619. bberror "Hit recoverable_error, correcting"
  10620. fi
  10621. if [ fatal_error ]; then
  10622. bbfatal "fatal_error detected"
  10623. fi
  10624. bbdebug 2 "Completed do_my_function"
  10625. }
  10626. </literallayout>
  10627. </para>
  10628. </section>
  10629. </section>
  10630. <section id='debugging-parallel-make-races'>
  10631. <title>Debugging Parallel Make Races</title>
  10632. <para>
  10633. A parallel <filename>make</filename> race occurs when the build
  10634. consists of several parts that are run simultaneously and
  10635. a situation occurs when the output or result of one
  10636. part is not ready for use with a different part of the build
  10637. that depends on that output.
  10638. Parallel make races are annoying and can sometimes be difficult
  10639. to reproduce and fix.
  10640. However, some simple tips and tricks exist that can help
  10641. you debug and fix them.
  10642. This section presents a real-world example of an error
  10643. encountered on the Yocto Project autobuilder and the process
  10644. used to fix it.
  10645. <note>
  10646. If you cannot properly fix a <filename>make</filename> race
  10647. condition, you can work around it by clearing either the
  10648. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  10649. or
  10650. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  10651. variables.
  10652. </note>
  10653. </para>
  10654. <section id='the-failure'>
  10655. <title>The Failure</title>
  10656. <para>
  10657. For this example, assume that you are building an image that
  10658. depends on the "neard" package.
  10659. And, during the build, BitBake runs into problems and
  10660. creates the following output.
  10661. <note>
  10662. This example log file has longer lines artificially
  10663. broken to make the listing easier to read.
  10664. </note>
  10665. If you examine the output or the log file, you see the
  10666. failure during <filename>make</filename>:
  10667. <literallayout class='monospaced'>
  10668. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  10669. | DEBUG: Executing shell function do_compile
  10670. | NOTE: make -j 16
  10671. | make --no-print-directory all-am
  10672. | /bin/mkdir -p include/near
  10673. | /bin/mkdir -p include/near
  10674. | /bin/mkdir -p include/near
  10675. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10676. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  10677. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10678. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  10679. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10680. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  10681. | /bin/mkdir -p include/near
  10682. | /bin/mkdir -p include/near
  10683. | /bin/mkdir -p include/near
  10684. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10685. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  10686. | /bin/mkdir -p include/near
  10687. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10688. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  10689. | /bin/mkdir -p include/near
  10690. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10691. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  10692. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10693. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  10694. | /bin/mkdir -p include/near
  10695. | /bin/mkdir -p include/near
  10696. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10697. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  10698. | /bin/mkdir -p include/near
  10699. | /bin/mkdir -p include/near
  10700. | /bin/mkdir -p include/near
  10701. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10702. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  10703. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10704. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  10705. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10706. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  10707. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10708. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  10709. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  10710. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  10711. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  10712. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  10713. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  10714. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  10715. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  10716. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  10717. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  10718. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  10719. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  10720. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  10721. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  10722. -o tools/snep-send.o tools/snep-send.c
  10723. | In file included from tools/snep-send.c:16:0:
  10724. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  10725. | #include &lt;near/dbus.h&gt;
  10726. | ^
  10727. | compilation terminated.
  10728. | make[1]: *** [tools/snep-send.o] Error 1
  10729. | make[1]: *** Waiting for unfinished jobs....
  10730. | make: *** [all] Error 2
  10731. | ERROR: oe_runmake failed
  10732. </literallayout>
  10733. </para>
  10734. </section>
  10735. <section id='reproducing-the-error'>
  10736. <title>Reproducing the Error</title>
  10737. <para>
  10738. Because race conditions are intermittent, they do not
  10739. manifest themselves every time you do the build.
  10740. In fact, most times the build will complete without problems
  10741. even though the potential race condition exists.
  10742. Thus, once the error surfaces, you need a way to reproduce
  10743. it.
  10744. </para>
  10745. <para>
  10746. In this example, compiling the "neard" package is causing
  10747. the problem.
  10748. So the first thing to do is build "neard" locally.
  10749. Before you start the build, set the
  10750. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  10751. variable in your <filename>local.conf</filename> file to
  10752. a high number (e.g. "-j 20").
  10753. Using a high value for <filename>PARALLEL_MAKE</filename>
  10754. increases the chances of the race condition showing up:
  10755. <literallayout class='monospaced'>
  10756. $ bitbake neard
  10757. </literallayout>
  10758. </para>
  10759. <para>
  10760. Once the local build for "neard" completes, start a
  10761. <filename>devshell</filename> build:
  10762. <literallayout class='monospaced'>
  10763. $ bitbake neard -c devshell
  10764. </literallayout>
  10765. For information on how to use a
  10766. <filename>devshell</filename>, see the
  10767. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  10768. section.
  10769. </para>
  10770. <para>
  10771. In the <filename>devshell</filename>, do the following:
  10772. <literallayout class='monospaced'>
  10773. $ make clean
  10774. $ make tools/snep-send.o
  10775. </literallayout>
  10776. The <filename>devshell</filename> commands cause the failure
  10777. to clearly be visible.
  10778. In this case, a missing dependency exists for the "neard"
  10779. Makefile target.
  10780. Here is some abbreviated, sample output with the
  10781. missing dependency clearly visible at the end:
  10782. <literallayout class='monospaced'>
  10783. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  10784. .
  10785. .
  10786. .
  10787. tools/snep-send.c
  10788. In file included from tools/snep-send.c:16:0:
  10789. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  10790. #include &lt;near/dbus.h&gt;
  10791. ^
  10792. compilation terminated.
  10793. make: *** [tools/snep-send.o] Error 1
  10794. $
  10795. </literallayout>
  10796. </para>
  10797. </section>
  10798. <section id='creating-a-patch-for-the-fix'>
  10799. <title>Creating a Patch for the Fix</title>
  10800. <para>
  10801. Because there is a missing dependency for the Makefile
  10802. target, you need to patch the
  10803. <filename>Makefile.am</filename> file, which is generated
  10804. from <filename>Makefile.in</filename>.
  10805. You can use Quilt to create the patch:
  10806. <literallayout class='monospaced'>
  10807. $ quilt new parallelmake.patch
  10808. Patch patches/parallelmake.patch is now on top
  10809. $ quilt add Makefile.am
  10810. File Makefile.am added to patch patches/parallelmake.patch
  10811. </literallayout>
  10812. For more information on using Quilt, see the
  10813. "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
  10814. section.
  10815. </para>
  10816. <para>
  10817. At this point you need to make the edits to
  10818. <filename>Makefile.am</filename> to add the missing
  10819. dependency.
  10820. For our example, you have to add the following line
  10821. to the file:
  10822. <literallayout class='monospaced'>
  10823. tools/snep-send.$(OBJEXT): include/near/dbus.h
  10824. </literallayout>
  10825. </para>
  10826. <para>
  10827. Once you have edited the file, use the
  10828. <filename>refresh</filename> command to create the patch:
  10829. <literallayout class='monospaced'>
  10830. $ quilt refresh
  10831. Refreshed patch patches/parallelmake.patch
  10832. </literallayout>
  10833. Once the patch file exists, you need to add it back to the
  10834. originating recipe folder.
  10835. Here is an example assuming a top-level
  10836. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  10837. named <filename>poky</filename>:
  10838. <literallayout class='monospaced'>
  10839. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  10840. </literallayout>
  10841. The final thing you need to do to implement the fix in the
  10842. build is to update the "neard" recipe (i.e.
  10843. <filename>neard-0.14.bb</filename>) so that the
  10844. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  10845. statement includes the patch file.
  10846. The recipe file is in the folder above the patch.
  10847. Here is what the edited <filename>SRC_URI</filename>
  10848. statement would look like:
  10849. <literallayout class='monospaced'>
  10850. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  10851. file://neard.in \
  10852. file://neard.service.in \
  10853. file://parallelmake.patch \
  10854. "
  10855. </literallayout>
  10856. </para>
  10857. <para>
  10858. With the patch complete and moved to the correct folder and
  10859. the <filename>SRC_URI</filename> statement updated, you can
  10860. exit the <filename>devshell</filename>:
  10861. <literallayout class='monospaced'>
  10862. $ exit
  10863. </literallayout>
  10864. </para>
  10865. </section>
  10866. <section id='testing-the-build'>
  10867. <title>Testing the Build</title>
  10868. <para>
  10869. With everything in place, you can get back to trying the
  10870. build again locally:
  10871. <literallayout class='monospaced'>
  10872. $ bitbake neard
  10873. </literallayout>
  10874. This build should succeed.
  10875. </para>
  10876. <para>
  10877. Now you can open up a <filename>devshell</filename> again
  10878. and repeat the clean and make operations as follows:
  10879. <literallayout class='monospaced'>
  10880. $ bitbake neard -c devshell
  10881. $ make clean
  10882. $ make tools/snep-send.o
  10883. </literallayout>
  10884. The build should work without issue.
  10885. </para>
  10886. <para>
  10887. As with all solved problems, if they originated upstream,
  10888. you need to submit the fix for the recipe in OE-Core and
  10889. upstream so that the problem is taken care of at its
  10890. source.
  10891. See the
  10892. "<link linkend='how-to-submit-a-change'>Submitting a Change to the Yocto Project</link>"
  10893. section for more information.
  10894. </para>
  10895. </section>
  10896. </section>
  10897. <section id="platdev-gdb-remotedebug">
  10898. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  10899. <para>
  10900. GDB allows you to examine running programs, which in turn helps
  10901. you to understand and fix problems.
  10902. It also allows you to perform post-mortem style analysis of
  10903. program crashes.
  10904. GDB is available as a package within the Yocto Project and is
  10905. installed in SDK images by default.
  10906. See the
  10907. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  10908. chapter in the Yocto Project Reference Manual for a description of
  10909. these images.
  10910. You can find information on GDB at
  10911. <ulink url="http://sourceware.org/gdb/"/>.
  10912. <note><title>Tip</title>
  10913. For best results, install debug (<filename>-dbg</filename>)
  10914. packages for the applications you are going to debug.
  10915. Doing so makes extra debug symbols available that give you
  10916. more meaningful output.
  10917. </note>
  10918. </para>
  10919. <para>
  10920. Sometimes, due to memory or disk space constraints, it is not
  10921. possible to use GDB directly on the remote target to debug
  10922. applications.
  10923. These constraints arise because GDB needs to load the debugging
  10924. information and the binaries of the process being debugged.
  10925. Additionally, GDB needs to perform many computations to locate
  10926. information such as function names, variable names and values,
  10927. stack traces and so forth - even before starting the debugging
  10928. process.
  10929. These extra computations place more load on the target system
  10930. and can alter the characteristics of the program being debugged.
  10931. </para>
  10932. <para>
  10933. To help get past the previously mentioned constraints, you can
  10934. use gdbserver, which runs on the remote target and does not
  10935. load any debugging information from the debugged process.
  10936. Instead, a GDB instance processes the debugging information that
  10937. is run on a remote computer - the host GDB.
  10938. The host GDB then sends control commands to gdbserver to make
  10939. it stop or start the debugged program, as well as read or write
  10940. memory regions of that debugged program.
  10941. All the debugging information loaded and processed as well
  10942. as all the heavy debugging is done by the host GDB.
  10943. Offloading these processes gives the gdbserver running on the
  10944. target a chance to remain small and fast.
  10945. </para>
  10946. <para>
  10947. Because the host GDB is responsible for loading the debugging
  10948. information and for doing the necessary processing to make
  10949. actual debugging happen, you have to make sure the host can
  10950. access the unstripped binaries complete with their debugging
  10951. information and also be sure the target is compiled with no
  10952. optimizations.
  10953. The host GDB must also have local access to all the libraries
  10954. used by the debugged program.
  10955. Because gdbserver does not need any local debugging information,
  10956. the binaries on the remote target can remain stripped.
  10957. However, the binaries must also be compiled without optimization
  10958. so they match the host's binaries.
  10959. </para>
  10960. <para>
  10961. To remain consistent with GDB documentation and terminology,
  10962. the binary being debugged on the remote target machine is
  10963. referred to as the "inferior" binary.
  10964. For documentation on GDB see the
  10965. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  10966. </para>
  10967. <para>
  10968. The following steps show you how to debug using the GNU project
  10969. debugger.
  10970. <orderedlist>
  10971. <listitem><para>
  10972. <emphasis>Configure your build system to construct the
  10973. companion debug filesystem:</emphasis></para>
  10974. <para>In your <filename>local.conf</filename> file, set
  10975. the following:
  10976. <literallayout class='monospaced'>
  10977. IMAGE_GEN_DEBUGFS = "1"
  10978. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  10979. </literallayout>
  10980. These options cause the OpenEmbedded build system
  10981. to generate a special companion filesystem fragment,
  10982. which contains the matching source and debug symbols to
  10983. your deployable filesystem.
  10984. The build system does this by looking at what is in the
  10985. deployed filesystem, and pulling the corresponding
  10986. <filename>-dbg</filename> packages.</para>
  10987. <para>The companion debug filesystem is not a complete
  10988. filesystem, but only contains the debug fragments.
  10989. This filesystem must be combined with the full filesystem
  10990. for debugging.
  10991. Subsequent steps in this procedure show how to combine
  10992. the partial filesystem with the full filesystem.
  10993. </para></listitem>
  10994. <listitem><para>
  10995. <emphasis>Configure the system to include gdbserver in
  10996. the target filesystem:</emphasis></para>
  10997. <para>Make the following addition in either your
  10998. <filename>local.conf</filename> file or in an image
  10999. recipe:
  11000. <literallayout class='monospaced'>
  11001. IMAGE_INSTALL_append = “ gdbserver"
  11002. </literallayout>
  11003. The change makes sure the <filename>gdbserver</filename>
  11004. package is included.
  11005. </para></listitem>
  11006. <listitem><para>
  11007. <emphasis>Build the environment:</emphasis></para>
  11008. <para>Use the following command to construct the image
  11009. and the companion Debug Filesystem:
  11010. <literallayout class='monospaced'>
  11011. $ bitbake <replaceable>image</replaceable>
  11012. </literallayout>
  11013. Build the cross GDB component and make it available
  11014. for debugging.
  11015. Build the SDK that matches the image.
  11016. Building the SDK is best for a production build
  11017. that can be used later for debugging, especially
  11018. during long term maintenance:
  11019. <literallayout class='monospaced'>
  11020. $ bitbake -c populate_sdk <replaceable>image</replaceable>
  11021. </literallayout></para>
  11022. <para>Alternatively, you can build the minimal
  11023. toolchain components that match the target.
  11024. Doing so creates a smaller than typical SDK and only
  11025. contains a minimal set of components with which to
  11026. build simple test applications, as well as run the
  11027. debugger:
  11028. <literallayout class='monospaced'>
  11029. $ bitbake meta-toolchain
  11030. </literallayout></para>
  11031. <para>A final method is to build Gdb itself within
  11032. the build system:
  11033. <literallayout class='monospaced'>
  11034. $ bitbake gdb-cross-<replaceable>architecture</replaceable>
  11035. </literallayout>
  11036. Doing so produces a temporary copy of
  11037. <filename>cross-gdb</filename> you can use for
  11038. debugging during development.
  11039. While this is the quickest approach, the two previous
  11040. methods in this step are better when considering
  11041. long-term maintenance strategies.
  11042. <note>
  11043. If you run
  11044. <filename>bitbake gdb-cross</filename>, the
  11045. OpenEmbedded build system suggests the actual
  11046. image (e.g. <filename>gdb-cross-i586</filename>).
  11047. The suggestion is usually the actual name you want
  11048. to use.
  11049. </note>
  11050. </para></listitem>
  11051. <listitem><para>
  11052. <emphasis>Set up the</emphasis>&nbsp;<filename>debugfs</filename></para>
  11053. <para>Run the following commands to set up the
  11054. <filename>debugfs</filename>:
  11055. <literallayout class='monospaced'>
  11056. $ mkdir debugfs
  11057. $ cd debugfs
  11058. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2
  11059. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2
  11060. </literallayout>
  11061. </para></listitem>
  11062. <listitem><para>
  11063. <emphasis>Set up GDB</emphasis></para>
  11064. <para>Install the SDK (if you built one) and then
  11065. source the correct environment file.
  11066. Sourcing the environment file puts the SDK in your
  11067. <filename>PATH</filename> environment variable.</para>
  11068. <para>If you are using the build system, Gdb is
  11069. located in
  11070. <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb
  11071. </para></listitem>
  11072. <listitem><para>
  11073. <emphasis>Boot the target:</emphasis></para>
  11074. <para>For information on how to run QEMU, see the
  11075. <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>.
  11076. <note>
  11077. Be sure to verify that your host can access the
  11078. target via TCP.
  11079. </note>
  11080. </para></listitem>
  11081. <listitem><para>
  11082. <emphasis>Debug a program:</emphasis></para>
  11083. <para>Debugging a program involves running gdbserver
  11084. on the target and then running Gdb on the host.
  11085. The example in this step debugs
  11086. <filename>gzip</filename>:
  11087. <literallayout class='monospaced'>
  11088. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  11089. </literallayout>
  11090. For additional gdbserver options, see the
  11091. <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>.
  11092. </para>
  11093. <para>After running gdbserver on the target, you need
  11094. to run Gdb on the host and configure it and connect to
  11095. the target.
  11096. Use these commands:
  11097. <literallayout class='monospaced'>
  11098. $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable>
  11099. $ <replaceable>arch</replaceable>-gdb
  11100. (gdb) set sysroot debugfs
  11101. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  11102. (gdb) target remote <replaceable>IP-of-target</replaceable>:1234
  11103. </literallayout>
  11104. At this point, everything should automatically load
  11105. (i.e. matching binaries, symbols and headers).
  11106. <note>
  11107. The Gdb <filename>set</filename> commands in the
  11108. previous example can be placed into the users
  11109. <filename>~/.gdbinit</filename> file.
  11110. Upon starting, Gdb automatically runs whatever
  11111. commands are in that file.
  11112. </note>
  11113. </para></listitem>
  11114. <listitem><para>
  11115. <emphasis>Deploying without a full image
  11116. rebuild:</emphasis></para>
  11117. <para>In many cases, during development you want a
  11118. quick method to deploy a new binary to the target and
  11119. debug it, without waiting for a full image build.
  11120. </para>
  11121. <para>One approach to solving this situation is to
  11122. just build the component you want to debug.
  11123. Once you have built the component, copy the
  11124. executable directly to both the target and the
  11125. host <filename>debugfs</filename>.</para>
  11126. <para>If the binary is processed through the debug
  11127. splitting in OpenEmbedded, you should also
  11128. copy the debug items (i.e. <filename>.debug</filename>
  11129. contents and corresponding
  11130. <filename>/usr/src/debug</filename> files)
  11131. from the work directory.
  11132. Here is an example:
  11133. <literallayout class='monospaced'>
  11134. $ bitbake bash
  11135. $ bitbake -c devshell bash
  11136. $ cd ..
  11137. $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash
  11138. $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs
  11139. </literallayout>
  11140. </para></listitem>
  11141. </orderedlist>
  11142. </para>
  11143. </section>
  11144. <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>
  11145. <title>Debugging with the GNU Project Debugger (GDB) on the Target</title>
  11146. <para>
  11147. The previous section addressed using GDB remotely for debugging
  11148. purposes, which is the most usual case due to the inherent
  11149. hardware limitations on many embedded devices.
  11150. However, debugging in the target hardware itself is also
  11151. possible with more powerful devices.
  11152. This section describes what you need to do in order to support
  11153. using GDB to debug on the target hardware.
  11154. </para>
  11155. <para>
  11156. To support this kind of debugging, you need do the following:
  11157. <itemizedlist>
  11158. <listitem><para>
  11159. Ensure that GDB is on the target.
  11160. You can do this by adding "gdb" to
  11161. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  11162. <literallayout class='monospaced'>
  11163. IMAGE_INSTALL_append = " gdb"
  11164. </literallayout>
  11165. Alternatively, you can add "tools-debug" to
  11166. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  11167. <literallayout class='monospaced'>
  11168. IMAGE_FEATURES_append = " tools-debug"
  11169. </literallayout>
  11170. </para></listitem>
  11171. <listitem><para>
  11172. Ensure that debug symbols are present.
  11173. You can make sure these symbols are present by
  11174. installing <filename>-dbg</filename>:
  11175. <literallayout class='monospaced'>
  11176. IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg"
  11177. </literallayout>
  11178. Alternatively, you can do the following to include all
  11179. the debug symbols:
  11180. <literallayout class='monospaced'>
  11181. IMAGE_FEATURES_append = " dbg-pkgs"
  11182. </literallayout>
  11183. </para></listitem>
  11184. </itemizedlist>
  11185. <note>
  11186. To improve the debug information accuracy, you can reduce
  11187. the level of optimization used by the compiler.
  11188. For example, when adding the following line to your
  11189. <filename>local.conf</filename> file, you will reduce
  11190. optimization from
  11191. <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink>
  11192. of "-O2" to
  11193. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink>
  11194. of "-O -fno-omit-frame-pointer":
  11195. <literallayout class='monospaced'>
  11196. DEBUG_BUILD = "1"
  11197. </literallayout>
  11198. Consider that this will reduce the application's performance
  11199. and is recommended only for debugging purposes.
  11200. </note>
  11201. </para>
  11202. </section>
  11203. <section id='dev-other-debugging-others'>
  11204. <title>Other Debugging Tips</title>
  11205. <para>
  11206. Here are some other tips that you might find useful:
  11207. <itemizedlist>
  11208. <listitem><para>
  11209. When adding new packages, it is worth watching for
  11210. undesirable items making their way into compiler command
  11211. lines.
  11212. For example, you do not want references to local system
  11213. files like
  11214. <filename>/usr/lib/</filename> or
  11215. <filename>/usr/include/</filename>.
  11216. </para></listitem>
  11217. <listitem><para>
  11218. If you want to remove the <filename>psplash</filename>
  11219. boot splashscreen,
  11220. add <filename>psplash=false</filename> to the kernel
  11221. command line.
  11222. Doing so prevents <filename>psplash</filename> from
  11223. loading and thus allows you to see the console.
  11224. It is also possible to switch out of the splashscreen by
  11225. switching the virtual console (e.g. Fn+Left or Fn+Right
  11226. on a Zaurus).
  11227. </para></listitem>
  11228. <listitem><para>
  11229. Removing
  11230. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  11231. (usually <filename>tmp/</filename>, within the
  11232. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>)
  11233. can often fix temporary build issues.
  11234. Removing <filename>TMPDIR</filename> is usually a
  11235. relatively cheap operation, because task output will be
  11236. cached in
  11237. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  11238. (usually <filename>sstate-cache/</filename>, which is
  11239. also in the Build Directory).
  11240. <note>
  11241. Removing <filename>TMPDIR</filename> might be a
  11242. workaround rather than a fix.
  11243. Consequently, trying to determine the underlying
  11244. cause of an issue before removing the directory is
  11245. a good idea.
  11246. </note>
  11247. </para></listitem>
  11248. <listitem><para>
  11249. Understanding how a feature is used in practice within
  11250. existing recipes can be very helpful.
  11251. It is recommended that you configure some method that
  11252. allows you to quickly search through files.</para>
  11253. <para>Using GNU Grep, you can use the following shell
  11254. function to recursively search through common
  11255. recipe-related files, skipping binary files,
  11256. <filename>.git</filename> directories, and the
  11257. Build Directory (assuming its name starts with
  11258. "build"):
  11259. <literallayout class='monospaced'>
  11260. g() {
  11261. grep -Ir \
  11262. --exclude-dir=.git \
  11263. --exclude-dir='build*' \
  11264. --include='*.bb*' \
  11265. --include='*.inc*' \
  11266. --include='*.conf*' \
  11267. --include='*.py*' \
  11268. "$@"
  11269. }
  11270. </literallayout>
  11271. Following are some usage examples:
  11272. <literallayout class='monospaced'>
  11273. $ g FOO # Search recursively for "FOO"
  11274. $ g -i foo # Search recursively for "foo", ignoring case
  11275. $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
  11276. </literallayout>
  11277. If figuring out how some feature works requires a lot of
  11278. searching, it might indicate that the documentation
  11279. should be extended or improved.
  11280. In such cases, consider filing a documentation bug using
  11281. the Yocto Project implementation of
  11282. <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>.
  11283. For general information on how to submit a bug against
  11284. the Yocto Project, see the Yocto Project Bugzilla
  11285. <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink>"
  11286. or the
  11287. <link linkend='submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</link>"
  11288. section.
  11289. <note>
  11290. The manuals might not be the right place to document
  11291. variables that are purely internal and have a
  11292. limited scope (e.g. internal variables used to
  11293. implement a single <filename>.bbclass</filename>
  11294. file).
  11295. </note>
  11296. </para></listitem>
  11297. </itemizedlist>
  11298. </para>
  11299. </section>
  11300. </section>
  11301. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  11302. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  11303. <para>
  11304. One of the concerns for a development organization using open source
  11305. software is how to maintain compliance with various open source
  11306. licensing during the lifecycle of the product.
  11307. While this section does not provide legal advice or
  11308. comprehensively cover all scenarios, it does
  11309. present methods that you can use to
  11310. assist you in meeting the compliance requirements during a software
  11311. release.
  11312. </para>
  11313. <para>
  11314. With hundreds of different open source licenses that the Yocto
  11315. Project tracks, it is difficult to know the requirements of each
  11316. and every license.
  11317. However, the requirements of the major FLOSS licenses can begin
  11318. to be covered by
  11319. assuming that three main areas of concern exist:
  11320. <itemizedlist>
  11321. <listitem><para>Source code must be provided.</para></listitem>
  11322. <listitem><para>License text for the software must be
  11323. provided.</para></listitem>
  11324. <listitem><para>Compilation scripts and modifications to the
  11325. source code must be provided.
  11326. </para></listitem>
  11327. </itemizedlist>
  11328. There are other requirements beyond the scope of these
  11329. three and the methods described in this section
  11330. (e.g. the mechanism through which source code is distributed).
  11331. </para>
  11332. <para>
  11333. As different organizations have different methods of complying with
  11334. open source licensing, this section is not meant to imply that
  11335. there is only one single way to meet your compliance obligations,
  11336. but rather to describe one method of achieving compliance.
  11337. The remainder of this section describes methods supported to meet the
  11338. previously mentioned three requirements.
  11339. Once you take steps to meet these requirements,
  11340. and prior to releasing images, sources, and the build system,
  11341. you should audit all artifacts to ensure completeness.
  11342. <note>
  11343. The Yocto Project generates a license manifest during
  11344. image creation that is located
  11345. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  11346. to assist with any audits.
  11347. </note>
  11348. </para>
  11349. <section id='providing-the-source-code'>
  11350. <title>Providing the Source Code</title>
  11351. <para>
  11352. Compliance activities should begin before you generate the
  11353. final image.
  11354. The first thing you should look at is the requirement that
  11355. tops the list for most compliance groups - providing
  11356. the source.
  11357. The Yocto Project has a few ways of meeting this
  11358. requirement.
  11359. </para>
  11360. <para>
  11361. One of the easiest ways to meet this requirement is
  11362. to provide the entire
  11363. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  11364. used by the build.
  11365. This method, however, has a few issues.
  11366. The most obvious is the size of the directory since it includes
  11367. all sources used in the build and not just the source used in
  11368. the released image.
  11369. It will include toolchain source, and other artifacts, which
  11370. you would not generally release.
  11371. However, the more serious issue for most companies is accidental
  11372. release of proprietary software.
  11373. The Yocto Project provides an
  11374. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  11375. class to help avoid some of these concerns.
  11376. </para>
  11377. <para>
  11378. Before you employ <filename>DL_DIR</filename> or the
  11379. <filename>archiver</filename> class, you need to decide how
  11380. you choose to provide source.
  11381. The source <filename>archiver</filename> class can generate
  11382. tarballs and SRPMs and can create them with various levels of
  11383. compliance in mind.
  11384. </para>
  11385. <para>
  11386. One way of doing this (but certainly not the only way) is to
  11387. release just the source as a tarball.
  11388. You can do this by adding the following to the
  11389. <filename>local.conf</filename> file found in the
  11390. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  11391. <literallayout class='monospaced'>
  11392. INHERIT += "archiver"
  11393. ARCHIVER_MODE[src] = "original"
  11394. </literallayout>
  11395. During the creation of your image, the source from all
  11396. recipes that deploy packages to the image is placed within
  11397. subdirectories of
  11398. <filename>DEPLOY_DIR/sources</filename> based on the
  11399. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  11400. for each recipe.
  11401. Releasing the entire directory enables you to comply with
  11402. requirements concerning providing the unmodified source.
  11403. It is important to note that the size of the directory can
  11404. get large.
  11405. </para>
  11406. <para>
  11407. A way to help mitigate the size issue is to only release
  11408. tarballs for licenses that require the release of
  11409. source.
  11410. Let us assume you are only concerned with GPL code as
  11411. identified by running the following script:
  11412. <literallayout class='monospaced'>
  11413. # Script to archive a subset of packages matching specific license(s)
  11414. # Source and license files are copied into sub folders of package folder
  11415. # Must be run from build folder
  11416. #!/bin/bash
  11417. src_release_dir="source-release"
  11418. mkdir -p $src_release_dir
  11419. for a in tmp/deploy/sources/*; do
  11420. for d in $a/*; do
  11421. # Get package name from path
  11422. p=`basename $d`
  11423. p=${p%-*}
  11424. p=${p%-*}
  11425. # Only archive GPL packages (update *GPL* regex for your license check)
  11426. numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
  11427. if [ $numfiles -gt 1 ]; then
  11428. echo Archiving $p
  11429. mkdir -p $src_release_dir/$p/source
  11430. cp $d/* $src_release_dir/$p/source 2> /dev/null
  11431. mkdir -p $src_release_dir/$p/license
  11432. cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
  11433. fi
  11434. done
  11435. done </literallayout>
  11436. At this point, you could create a tarball from the
  11437. <filename>gpl_source_release</filename> directory and
  11438. provide that to the end user.
  11439. This method would be a step toward achieving compliance
  11440. with section 3a of GPLv2 and with section 6 of GPLv3.
  11441. </para>
  11442. </section>
  11443. <section id='providing-license-text'>
  11444. <title>Providing License Text</title>
  11445. <para>
  11446. One requirement that is often overlooked is inclusion
  11447. of license text.
  11448. This requirement also needs to be dealt with prior to
  11449. generating the final image.
  11450. Some licenses require the license text to accompany
  11451. the binary.
  11452. You can achieve this by adding the following to your
  11453. <filename>local.conf</filename> file:
  11454. <literallayout class='monospaced'>
  11455. COPY_LIC_MANIFEST = "1"
  11456. COPY_LIC_DIRS = "1"
  11457. LICENSE_CREATE_PACKAGE = "1"
  11458. </literallayout>
  11459. Adding these statements to the configuration file ensures
  11460. that the licenses collected during package generation
  11461. are included on your image.
  11462. <note>
  11463. <para>Setting all three variables to "1" results in the
  11464. image having two copies of the same license file.
  11465. One copy resides in
  11466. <filename>/usr/share/common-licenses</filename> and
  11467. the other resides in
  11468. <filename>/usr/share/license</filename>.</para>
  11469. <para>The reason for this behavior is because
  11470. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink>
  11471. and
  11472. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink>
  11473. add a copy of the license when the image is built but do
  11474. not offer a path for adding licenses for newly installed
  11475. packages to an image.
  11476. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink>
  11477. adds a separate package and an upgrade path for adding
  11478. licenses to an image.</para>
  11479. </note>
  11480. </para>
  11481. <para>
  11482. As the source <filename>archiver</filename> class has already
  11483. archived the original
  11484. unmodified source that contains the license files,
  11485. you would have already met the requirements for inclusion
  11486. of the license information with source as defined by the GPL
  11487. and other open source licenses.
  11488. </para>
  11489. </section>
  11490. <section id='providing-compilation-scripts-and-source-code-modifications'>
  11491. <title>Providing Compilation Scripts and Source Code Modifications</title>
  11492. <para>
  11493. At this point, we have addressed all we need to
  11494. prior to generating the image.
  11495. The next two requirements are addressed during the final
  11496. packaging of the release.
  11497. </para>
  11498. <para>
  11499. By releasing the version of the OpenEmbedded build system
  11500. and the layers used during the build, you will be providing both
  11501. compilation scripts and the source code modifications in one
  11502. step.
  11503. </para>
  11504. <para>
  11505. If the deployment team has a
  11506. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  11507. and a distro layer, and those those layers are used to patch,
  11508. compile, package, or modify (in any way) any open source
  11509. software included in your released images, you
  11510. might be required to release those layers under section 3 of
  11511. GPLv2 or section 1 of GPLv3.
  11512. One way of doing that is with a clean
  11513. checkout of the version of the Yocto Project and layers used
  11514. during your build.
  11515. Here is an example:
  11516. <literallayout class='monospaced'>
  11517. # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo
  11518. $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky
  11519. $ cd poky
  11520. # We built using the release_branch for our layers
  11521. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  11522. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  11523. # clean up the .git repos
  11524. $ find . -name ".git" -type d -exec rm -rf {} \;
  11525. </literallayout>
  11526. One thing a development organization might want to consider
  11527. for end-user convenience is to modify
  11528. <filename>meta-poky/conf/bblayers.conf.sample</filename> to
  11529. ensure that when the end user utilizes the released build
  11530. system to build an image, the development organization's
  11531. layers are included in the <filename>bblayers.conf</filename>
  11532. file automatically:
  11533. <literallayout class='monospaced'>
  11534. # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
  11535. # changes incompatibly
  11536. LCONF_VERSION = "6"
  11537. BBPATH = "${TOPDIR}"
  11538. BBFILES ?= ""
  11539. BBLAYERS ?= " \
  11540. ##OEROOT##/meta \
  11541. ##OEROOT##/meta-poky \
  11542. ##OEROOT##/meta-yocto-bsp \
  11543. ##OEROOT##/meta-mylayer \
  11544. "
  11545. </literallayout>
  11546. Creating and providing an archive of the
  11547. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  11548. layers (recipes, configuration files, and so forth)
  11549. enables you to meet your
  11550. requirements to include the scripts to control compilation
  11551. as well as any modifications to the original source.
  11552. </para>
  11553. </section>
  11554. </section>
  11555. <section id='using-the-error-reporting-tool'>
  11556. <title>Using the Error Reporting Tool</title>
  11557. <para>
  11558. The error reporting tool allows you to
  11559. submit errors encountered during builds to a central database.
  11560. Outside of the build environment, you can use a web interface to
  11561. browse errors, view statistics, and query for errors.
  11562. The tool works using a client-server system where the client
  11563. portion is integrated with the installed Yocto Project
  11564. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  11565. (e.g. <filename>poky</filename>).
  11566. The server receives the information collected and saves it in a
  11567. database.
  11568. </para>
  11569. <para>
  11570. A live instance of the error reporting server exists at
  11571. <ulink url='http://errors.yoctoproject.org'></ulink>.
  11572. This server exists so that when you want to get help with
  11573. build failures, you can submit all of the information on the
  11574. failure easily and then point to the URL in your bug report
  11575. or send an email to the mailing list.
  11576. <note>
  11577. If you send error reports to this server, the reports become
  11578. publicly visible.
  11579. </note>
  11580. </para>
  11581. <section id='enabling-and-using-the-tool'>
  11582. <title>Enabling and Using the Tool</title>
  11583. <para>
  11584. By default, the error reporting tool is disabled.
  11585. You can enable it by inheriting the
  11586. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  11587. class by adding the following statement to the end of
  11588. your <filename>local.conf</filename> file in your
  11589. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  11590. <literallayout class='monospaced'>
  11591. INHERIT += "report-error"
  11592. </literallayout>
  11593. </para>
  11594. <para>
  11595. By default, the error reporting feature stores information in
  11596. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  11597. However, you can specify a directory to use by adding the following
  11598. to your <filename>local.conf</filename> file:
  11599. <literallayout class='monospaced'>
  11600. ERR_REPORT_DIR = "path"
  11601. </literallayout>
  11602. Enabling error reporting causes the build process to collect
  11603. the errors and store them in a file as previously described.
  11604. When the build system encounters an error, it includes a
  11605. command as part of the console output.
  11606. You can run the command to send the error file to the server.
  11607. For example, the following command sends the errors to an
  11608. upstream server:
  11609. <literallayout class='monospaced'>
  11610. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  11611. </literallayout>
  11612. In the previous example, the errors are sent to a public
  11613. database available at
  11614. <ulink url='http://errors.yoctoproject.org'></ulink>, which is
  11615. used by the entire community.
  11616. If you specify a particular server, you can send the errors
  11617. to a different database.
  11618. Use the following command for more information on available
  11619. options:
  11620. <literallayout class='monospaced'>
  11621. $ send-error-report --help
  11622. </literallayout>
  11623. </para>
  11624. <para>
  11625. When sending the error file, you are prompted to review the
  11626. data being sent as well as to provide a name and optional
  11627. email address.
  11628. Once you satisfy these prompts, the command returns a link
  11629. from the server that corresponds to your entry in the database.
  11630. For example, here is a typical link:
  11631. <literallayout class='monospaced'>
  11632. http://errors.yoctoproject.org/Errors/Details/9522/
  11633. </literallayout>
  11634. Following the link takes you to a web interface where you can
  11635. browse, query the errors, and view statistics.
  11636. </para>
  11637. </section>
  11638. <section id='disabling-the-tool'>
  11639. <title>Disabling the Tool</title>
  11640. <para>
  11641. To disable the error reporting feature, simply remove or comment
  11642. out the following statement from the end of your
  11643. <filename>local.conf</filename> file in your
  11644. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  11645. <literallayout class='monospaced'>
  11646. INHERIT += "report-error"
  11647. </literallayout>
  11648. </para>
  11649. </section>
  11650. <section id='setting-up-your-own-error-reporting-server'>
  11651. <title>Setting Up Your Own Error Reporting Server</title>
  11652. <para>
  11653. If you want to set up your own error reporting server, you
  11654. can obtain the code from the Git repository at
  11655. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  11656. Instructions on how to set it up are in the README document.
  11657. </para>
  11658. </section>
  11659. </section>
  11660. </chapter>
  11661. <!--
  11662. vim: expandtab tw=80 ts=4
  11663. -->