common-tasks.rst 455 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ************
  3. Common Tasks
  4. ************
  5. This chapter describes fundamental procedures such as creating layers,
  6. adding new software packages, extending or customizing images, porting
  7. work to new hardware (adding a new machine), and so forth. You will find
  8. that the procedures documented here occur often in the development cycle
  9. using the Yocto Project.
  10. Understanding and Creating Layers
  11. =================================
  12. The OpenEmbedded build system supports organizing
  13. :term:`Metadata` into multiple layers.
  14. Layers allow you to isolate different types of customizations from each
  15. other. For introductory information on the Yocto Project Layer Model,
  16. see the
  17. ":ref:`overview-manual/yp-intro:the yocto project layer model`"
  18. section in the Yocto Project Overview and Concepts Manual.
  19. Creating Your Own Layer
  20. -----------------------
  21. It is very easy to create your own layers to use with the OpenEmbedded
  22. build system. The Yocto Project ships with tools that speed up creating
  23. layers. This section describes the steps you perform by hand to create
  24. layers so that you can better understand them. For information about the
  25. layer-creation tools, see the
  26. ":ref:`bsp-guide/bsp:creating a new bsp layer using the \`\`bitbake-layers\`\` script`"
  27. section in the Yocto Project Board Support Package (BSP) Developer's
  28. Guide and the ":ref:`dev-manual/common-tasks:creating a general layer using the \`\`bitbake-layers\`\` script`"
  29. section further down in this manual.
  30. Follow these general steps to create your layer without using tools:
  31. 1. *Check Existing Layers:* Before creating a new layer, you should be
  32. sure someone has not already created a layer containing the Metadata
  33. you need. You can see the :oe_layerindex:`OpenEmbedded Metadata Index <>`
  34. for a list of layers from the OpenEmbedded community that can be used in
  35. the Yocto Project. You could find a layer that is identical or close
  36. to what you need.
  37. 2. *Create a Directory:* Create the directory for your layer. When you
  38. create the layer, be sure to create the directory in an area not
  39. associated with the Yocto Project :term:`Source Directory`
  40. (e.g. the cloned ``poky`` repository).
  41. While not strictly required, prepend the name of the directory with
  42. the string "meta-". For example:
  43. ::
  44. meta-mylayer
  45. meta-GUI_xyz
  46. meta-mymachine
  47. With rare exceptions, a layer's name follows this form:
  48. ::
  49. meta-root_name
  50. Following this layer naming convention can save
  51. you trouble later when tools, components, or variables "assume" your
  52. layer name begins with "meta-". A notable example is in configuration
  53. files as shown in the following step where layer names without the
  54. "meta-" string are appended to several variables used in the
  55. configuration.
  56. 3. *Create a Layer Configuration File:* Inside your new layer folder,
  57. you need to create a ``conf/layer.conf`` file. It is easiest to take
  58. an existing layer configuration file and copy that to your layer's
  59. ``conf`` directory and then modify the file as needed.
  60. The ``meta-yocto-bsp/conf/layer.conf`` file in the Yocto Project
  61. :yocto_git:`Source Repositories </poky/tree/meta-yocto-bsp/conf>`
  62. demonstrates the required syntax. For your layer, you need to replace
  63. "yoctobsp" with a unique identifier for your layer (e.g. "machinexyz"
  64. for a layer named "meta-machinexyz"):
  65. ::
  66. # We have a conf and classes directory, add to BBPATH
  67. BBPATH .= ":${LAYERDIR}"
  68. # We have recipes-* directories, add to BBFILES
  69. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  70. ${LAYERDIR}/recipes-*/*/*.bbappend"
  71. BBFILE_COLLECTIONS += "yoctobsp"
  72. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  73. BBFILE_PRIORITY_yoctobsp = "5"
  74. LAYERVERSION_yoctobsp = "4"
  75. LAYERSERIES_COMPAT_yoctobsp = "dunfell"
  76. Following is an explanation of the layer configuration file:
  77. - :term:`BBPATH`: Adds the layer's
  78. root directory to BitBake's search path. Through the use of the
  79. ``BBPATH`` variable, BitBake locates class files (``.bbclass``),
  80. configuration files, and files that are included with ``include``
  81. and ``require`` statements. For these cases, BitBake uses the
  82. first file that matches the name found in ``BBPATH``. This is
  83. similar to the way the ``PATH`` variable is used for binaries. It
  84. is recommended, therefore, that you use unique class and
  85. configuration filenames in your custom layer.
  86. - :term:`BBFILES`: Defines the
  87. location for all recipes in the layer.
  88. - :term:`BBFILE_COLLECTIONS`:
  89. Establishes the current layer through a unique identifier that is
  90. used throughout the OpenEmbedded build system to refer to the
  91. layer. In this example, the identifier "yoctobsp" is the
  92. representation for the container layer named "meta-yocto-bsp".
  93. - :term:`BBFILE_PATTERN`:
  94. Expands immediately during parsing to provide the directory of the
  95. layer.
  96. - :term:`BBFILE_PRIORITY`:
  97. Establishes a priority to use for recipes in the layer when the
  98. OpenEmbedded build finds recipes of the same name in different
  99. layers.
  100. - :term:`LAYERVERSION`:
  101. Establishes a version number for the layer. You can use this
  102. version number to specify this exact version of the layer as a
  103. dependency when using the
  104. :term:`LAYERDEPENDS`
  105. variable.
  106. - :term:`LAYERDEPENDS`:
  107. Lists all layers on which this layer depends (if any).
  108. - :term:`LAYERSERIES_COMPAT`:
  109. Lists the :yocto_wiki:`Yocto Project </Releases>`
  110. releases for which the current version is compatible. This
  111. variable is a good way to indicate if your particular layer is
  112. current.
  113. 4. *Add Content:* Depending on the type of layer, add the content. If
  114. the layer adds support for a machine, add the machine configuration
  115. in a ``conf/machine/`` file within the layer. If the layer adds
  116. distro policy, add the distro configuration in a ``conf/distro/``
  117. file within the layer. If the layer introduces new recipes, put the
  118. recipes you need in ``recipes-*`` subdirectories within the layer.
  119. .. note::
  120. For an explanation of layer hierarchy that is compliant with the
  121. Yocto Project, see the ":ref:`bsp-guide/bsp:example filesystem layout`"
  122. section in the Yocto Project Board Support Package (BSP) Developer's Guide.
  123. 5. *Optionally Test for Compatibility:* If you want permission to use
  124. the Yocto Project Compatibility logo with your layer or application
  125. that uses your layer, perform the steps to apply for compatibility.
  126. See the
  127. ":ref:`dev-manual/common-tasks:making sure your layer is compatible with yocto project`"
  128. section for more information.
  129. Following Best Practices When Creating Layers
  130. ---------------------------------------------
  131. To create layers that are easier to maintain and that will not impact
  132. builds for other machines, you should consider the information in the
  133. following list:
  134. - *Avoid "Overlaying" Entire Recipes from Other Layers in Your
  135. Configuration:* In other words, do not copy an entire recipe into
  136. your layer and then modify it. Rather, use an append file
  137. (``.bbappend``) to override only those parts of the original recipe
  138. you need to modify.
  139. - *Avoid Duplicating Include Files:* Use append files (``.bbappend``)
  140. for each recipe that uses an include file. Or, if you are introducing
  141. a new recipe that requires the included file, use the path relative
  142. to the original layer directory to refer to the file. For example,
  143. use ``require recipes-core/``\ `package`\ ``/``\ `file`\ ``.inc`` instead
  144. of ``require`` `file`\ ``.inc``. If you're finding you have to overlay
  145. the include file, it could indicate a deficiency in the include file
  146. in the layer to which it originally belongs. If this is the case, you
  147. should try to address that deficiency instead of overlaying the
  148. include file. For example, you could address this by getting the
  149. maintainer of the include file to add a variable or variables to make
  150. it easy to override the parts needing to be overridden.
  151. - *Structure Your Layers:* Proper use of overrides within append files
  152. and placement of machine-specific files within your layer can ensure
  153. that a build is not using the wrong Metadata and negatively impacting
  154. a build for a different machine. Following are some examples:
  155. - *Modify Variables to Support a Different Machine:* Suppose you
  156. have a layer named ``meta-one`` that adds support for building
  157. machine "one". To do so, you use an append file named
  158. ``base-files.bbappend`` and create a dependency on "foo" by
  159. altering the :term:`DEPENDS`
  160. variable:
  161. ::
  162. DEPENDS = "foo"
  163. The dependency is created during any
  164. build that includes the layer ``meta-one``. However, you might not
  165. want this dependency for all machines. For example, suppose you
  166. are building for machine "two" but your ``bblayers.conf`` file has
  167. the ``meta-one`` layer included. During the build, the
  168. ``base-files`` for machine "two" will also have the dependency on
  169. ``foo``.
  170. To make sure your changes apply only when building machine "one",
  171. use a machine override with the ``DEPENDS`` statement:
  172. ::
  173. DEPENDS_one = "foo"
  174. You should follow the same strategy when using ``_append``
  175. and ``_prepend`` operations:
  176. ::
  177. DEPENDS_append_one = " foo"
  178. DEPENDS_prepend_one = "foo "
  179. As an actual example, here's a
  180. snippet from the generic kernel include file ``linux-yocto.inc``,
  181. wherein the kernel compile and link options are adjusted in the
  182. case of a subset of the supported architectures:
  183. ::
  184. DEPENDS_append_aarch64 = " libgcc"
  185. KERNEL_CC_append_aarch64 = " ${TOOLCHAIN_OPTIONS}"
  186. KERNEL_LD_append_aarch64 = " ${TOOLCHAIN_OPTIONS}"
  187. DEPENDS_append_nios2 = " libgcc"
  188. KERNEL_CC_append_nios2 = " ${TOOLCHAIN_OPTIONS}"
  189. KERNEL_LD_append_nios2 = " ${TOOLCHAIN_OPTIONS}"
  190. DEPENDS_append_arc = " libgcc"
  191. KERNEL_CC_append_arc = " ${TOOLCHAIN_OPTIONS}"
  192. KERNEL_LD_append_arc = " ${TOOLCHAIN_OPTIONS}"
  193. KERNEL_FEATURES_append_qemuall=" features/debug/printk.scc"
  194. .. note::
  195. Avoiding "+=" and "=+" and using machine-specific ``_append``
  196. and ``_prepend`` operations is recommended as well.
  197. - *Place Machine-Specific Files in Machine-Specific Locations:* When
  198. you have a base recipe, such as ``base-files.bb``, that contains a
  199. :term:`SRC_URI` statement to a
  200. file, you can use an append file to cause the build to use your
  201. own version of the file. For example, an append file in your layer
  202. at ``meta-one/recipes-core/base-files/base-files.bbappend`` could
  203. extend :term:`FILESPATH` using :term:`FILESEXTRAPATHS` as follows:
  204. ::
  205. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  206. The build for machine "one" will pick up your machine-specific file as
  207. long as you have the file in
  208. ``meta-one/recipes-core/base-files/base-files/``. However, if you
  209. are building for a different machine and the ``bblayers.conf``
  210. file includes the ``meta-one`` layer and the location of your
  211. machine-specific file is the first location where that file is
  212. found according to ``FILESPATH``, builds for all machines will
  213. also use that machine-specific file.
  214. You can make sure that a machine-specific file is used for a
  215. particular machine by putting the file in a subdirectory specific
  216. to the machine. For example, rather than placing the file in
  217. ``meta-one/recipes-core/base-files/base-files/`` as shown above,
  218. put it in ``meta-one/recipes-core/base-files/base-files/one/``.
  219. Not only does this make sure the file is used only when building
  220. for machine "one", but the build process locates the file more
  221. quickly.
  222. In summary, you need to place all files referenced from
  223. ``SRC_URI`` in a machine-specific subdirectory within the layer in
  224. order to restrict those files to machine-specific builds.
  225. - *Perform Steps to Apply for Yocto Project Compatibility:* If you want
  226. permission to use the Yocto Project Compatibility logo with your
  227. layer or application that uses your layer, perform the steps to apply
  228. for compatibility. See the
  229. ":ref:`dev-manual/common-tasks:making sure your layer is compatible with yocto project`"
  230. section for more information.
  231. - *Follow the Layer Naming Convention:* Store custom layers in a Git
  232. repository that use the ``meta-layer_name`` format.
  233. - *Group Your Layers Locally:* Clone your repository alongside other
  234. cloned ``meta`` directories from the :term:`Source Directory`.
  235. Making Sure Your Layer is Compatible With Yocto Project
  236. -------------------------------------------------------
  237. When you create a layer used with the Yocto Project, it is advantageous
  238. to make sure that the layer interacts well with existing Yocto Project
  239. layers (i.e. the layer is compatible with the Yocto Project). Ensuring
  240. compatibility makes the layer easy to be consumed by others in the Yocto
  241. Project community and could allow you permission to use the Yocto
  242. Project Compatible Logo.
  243. .. note::
  244. Only Yocto Project member organizations are permitted to use the
  245. Yocto Project Compatible Logo. The logo is not available for general
  246. use. For information on how to become a Yocto Project member
  247. organization, see the :yocto_home:`Yocto Project Website <>`.
  248. The Yocto Project Compatibility Program consists of a layer application
  249. process that requests permission to use the Yocto Project Compatibility
  250. Logo for your layer and application. The process consists of two parts:
  251. 1. Successfully passing a script (``yocto-check-layer``) that when run
  252. against your layer, tests it against constraints based on experiences
  253. of how layers have worked in the real world and where pitfalls have
  254. been found. Getting a "PASS" result from the script is required for
  255. successful compatibility registration.
  256. 2. Completion of an application acceptance form, which you can find at
  257. :yocto_home:`/webform/yocto-project-compatible-registration`.
  258. To be granted permission to use the logo, you need to satisfy the
  259. following:
  260. - Be able to check the box indicating that you got a "PASS" when
  261. running the script against your layer.
  262. - Answer "Yes" to the questions on the form or have an acceptable
  263. explanation for any questions answered "No".
  264. - Be a Yocto Project Member Organization.
  265. The remainder of this section presents information on the registration
  266. form and on the ``yocto-check-layer`` script.
  267. Yocto Project Compatible Program Application
  268. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  269. Use the form to apply for your layer's approval. Upon successful
  270. application, you can use the Yocto Project Compatibility Logo with your
  271. layer and the application that uses your layer.
  272. To access the form, use this link:
  273. :yocto_home:`/webform/yocto-project-compatible-registration`.
  274. Follow the instructions on the form to complete your application.
  275. The application consists of the following sections:
  276. - *Contact Information:* Provide your contact information as the fields
  277. require. Along with your information, provide the released versions
  278. of the Yocto Project for which your layer is compatible.
  279. - *Acceptance Criteria:* Provide "Yes" or "No" answers for each of the
  280. items in the checklist. Space exists at the bottom of the form for
  281. any explanations for items for which you answered "No".
  282. - *Recommendations:* Provide answers for the questions regarding Linux
  283. kernel use and build success.
  284. ``yocto-check-layer`` Script
  285. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  286. The ``yocto-check-layer`` script provides you a way to assess how
  287. compatible your layer is with the Yocto Project. You should run this
  288. script prior to using the form to apply for compatibility as described
  289. in the previous section. You need to achieve a "PASS" result in order to
  290. have your application form successfully processed.
  291. The script divides tests into three areas: COMMON, BSP, and DISTRO. For
  292. example, given a distribution layer (DISTRO), the layer must pass both
  293. the COMMON and DISTRO related tests. Furthermore, if your layer is a BSP
  294. layer, the layer must pass the COMMON and BSP set of tests.
  295. To execute the script, enter the following commands from your build
  296. directory:
  297. ::
  298. $ source oe-init-build-env
  299. $ yocto-check-layer your_layer_directory
  300. Be sure to provide the actual directory for your
  301. layer as part of the command.
  302. Entering the command causes the script to determine the type of layer
  303. and then to execute a set of specific tests against the layer. The
  304. following list overviews the test:
  305. - ``common.test_readme``: Tests if a ``README`` file exists in the
  306. layer and the file is not empty.
  307. - ``common.test_parse``: Tests to make sure that BitBake can parse the
  308. files without error (i.e. ``bitbake -p``).
  309. - ``common.test_show_environment``: Tests that the global or per-recipe
  310. environment is in order without errors (i.e. ``bitbake -e``).
  311. - ``common.test_world``: Verifies that ``bitbake world`` works.
  312. - ``common.test_signatures``: Tests to be sure that BSP and DISTRO
  313. layers do not come with recipes that change signatures.
  314. - ``common.test_layerseries_compat``: Verifies layer compatibility is
  315. set properly.
  316. - ``bsp.test_bsp_defines_machines``: Tests if a BSP layer has machine
  317. configurations.
  318. - ``bsp.test_bsp_no_set_machine``: Tests to ensure a BSP layer does not
  319. set the machine when the layer is added.
  320. - ``bsp.test_machine_world``: Verifies that ``bitbake world`` works
  321. regardless of which machine is selected.
  322. - ``bsp.test_machine_signatures``: Verifies that building for a
  323. particular machine affects only the signature of tasks specific to
  324. that machine.
  325. - ``distro.test_distro_defines_distros``: Tests if a DISTRO layer has
  326. distro configurations.
  327. - ``distro.test_distro_no_set_distros``: Tests to ensure a DISTRO layer
  328. does not set the distribution when the layer is added.
  329. Enabling Your Layer
  330. -------------------
  331. Before the OpenEmbedded build system can use your new layer, you need to
  332. enable it. To enable your layer, simply add your layer's path to the
  333. ``BBLAYERS`` variable in your ``conf/bblayers.conf`` file, which is
  334. found in the :term:`Build Directory`.
  335. The following example shows how to enable a layer named
  336. ``meta-mylayer``:
  337. ::
  338. # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
  339. # changes incompatibly
  340. POKY_BBLAYERS_CONF_VERSION = "2"
  341. BBPATH = "${TOPDIR}"
  342. BBFILES ?= ""
  343. BBLAYERS ?= " \
  344. /home/user/poky/meta \
  345. /home/user/poky/meta-poky \
  346. /home/user/poky/meta-yocto-bsp \
  347. /home/user/poky/meta-mylayer \
  348. "
  349. BitBake parses each ``conf/layer.conf`` file from the top down as
  350. specified in the ``BBLAYERS`` variable within the ``conf/bblayers.conf``
  351. file. During the processing of each ``conf/layer.conf`` file, BitBake
  352. adds the recipes, classes and configurations contained within the
  353. particular layer to the source directory.
  354. Using .bbappend Files in Your Layer
  355. -----------------------------------
  356. A recipe that appends Metadata to another recipe is called a BitBake
  357. append file. A BitBake append file uses the ``.bbappend`` file type
  358. suffix, while the corresponding recipe to which Metadata is being
  359. appended uses the ``.bb`` file type suffix.
  360. You can use a ``.bbappend`` file in your layer to make additions or
  361. changes to the content of another layer's recipe without having to copy
  362. the other layer's recipe into your layer. Your ``.bbappend`` file
  363. resides in your layer, while the main ``.bb`` recipe file to which you
  364. are appending Metadata resides in a different layer.
  365. Being able to append information to an existing recipe not only avoids
  366. duplication, but also automatically applies recipe changes from a
  367. different layer into your layer. If you were copying recipes, you would
  368. have to manually merge changes as they occur.
  369. When you create an append file, you must use the same root name as the
  370. corresponding recipe file. For example, the append file
  371. ``someapp_3.1.bbappend`` must apply to ``someapp_3.1.bb``. This
  372. means the original recipe and append file names are version
  373. number-specific. If the corresponding recipe is renamed to update to a
  374. newer version, you must also rename and possibly update the
  375. corresponding ``.bbappend`` as well. During the build process, BitBake
  376. displays an error on starting if it detects a ``.bbappend`` file that
  377. does not have a corresponding recipe with a matching name. See the
  378. :term:`BB_DANGLINGAPPENDS_WARNONLY`
  379. variable for information on how to handle this error.
  380. As an example, consider the main formfactor recipe and a corresponding
  381. formfactor append file both from the :term:`Source Directory`.
  382. Here is the main
  383. formfactor recipe, which is named ``formfactor_0.0.bb`` and located in
  384. the "meta" layer at ``meta/recipes-bsp/formfactor``:
  385. ::
  386. SUMMARY = "Device formfactor information"
  387. DESCRIPTION = "A formfactor configuration file provides information about the \
  388. target hardware for which the image is being built and information that the \
  389. build system cannot obtain from other sources such as the kernel."
  390. SECTION = "base"
  391. LICENSE = "MIT"
  392. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  393. PR = "r45"
  394. SRC_URI = "file://config file://machconfig"
  395. S = "${WORKDIR}"
  396. PACKAGE_ARCH = "${MACHINE_ARCH}"
  397. INHIBIT_DEFAULT_DEPS = "1"
  398. do_install() {
  399. # Install file only if it has contents
  400. install -d ${D}${sysconfdir}/formfactor/
  401. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  402. if [ -s "${S}/machconfig" ]; then
  403. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  404. fi
  405. }
  406. In the main recipe, note the :term:`SRC_URI`
  407. variable, which tells the OpenEmbedded build system where to find files
  408. during the build.
  409. Following is the append file, which is named ``formfactor_0.0.bbappend``
  410. and is from the Raspberry Pi BSP Layer named ``meta-raspberrypi``. The
  411. file is in the layer at ``recipes-bsp/formfactor``:
  412. ::
  413. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  414. By default, the build system uses the
  415. :term:`FILESPATH` variable to
  416. locate files. This append file extends the locations by setting the
  417. :term:`FILESEXTRAPATHS`
  418. variable. Setting this variable in the ``.bbappend`` file is the most
  419. reliable and recommended method for adding directories to the search
  420. path used by the build system to find files.
  421. The statement in this example extends the directories to include
  422. ``${``\ :term:`THISDIR`\ ``}/${``\ :term:`PN`\ ``}``,
  423. which resolves to a directory named ``formfactor`` in the same directory
  424. in which the append file resides (i.e.
  425. ``meta-raspberrypi/recipes-bsp/formfactor``. This implies that you must
  426. have the supporting directory structure set up that will contain any
  427. files or patches you will be including from the layer.
  428. Using the immediate expansion assignment operator ``:=`` is important
  429. because of the reference to ``THISDIR``. The trailing colon character is
  430. important as it ensures that items in the list remain colon-separated.
  431. .. note::
  432. BitBake automatically defines the ``THISDIR`` variable. You should
  433. never set this variable yourself. Using "_prepend" as part of the
  434. ``FILESEXTRAPATHS`` ensures your path will be searched prior to other
  435. paths in the final list.
  436. Also, not all append files add extra files. Many append files simply
  437. exist to add build options (e.g. ``systemd``). For these cases, your
  438. append file would not even use the ``FILESEXTRAPATHS`` statement.
  439. Prioritizing Your Layer
  440. -----------------------
  441. Each layer is assigned a priority value. Priority values control which
  442. layer takes precedence if there are recipe files with the same name in
  443. multiple layers. For these cases, the recipe file from the layer with a
  444. higher priority number takes precedence. Priority values also affect the
  445. order in which multiple ``.bbappend`` files for the same recipe are
  446. applied. You can either specify the priority manually, or allow the
  447. build system to calculate it based on the layer's dependencies.
  448. To specify the layer's priority manually, use the
  449. :term:`BBFILE_PRIORITY`
  450. variable and append the layer's root name:
  451. ::
  452. BBFILE_PRIORITY_mylayer = "1"
  453. .. note::
  454. It is possible for a recipe with a lower version number
  455. :term:`PV` in a layer that has a higher
  456. priority to take precedence.
  457. Also, the layer priority does not currently affect the precedence
  458. order of ``.conf`` or ``.bbclass`` files. Future versions of BitBake
  459. might address this.
  460. Managing Layers
  461. ---------------
  462. You can use the BitBake layer management tool ``bitbake-layers`` to
  463. provide a view into the structure of recipes across a multi-layer
  464. project. Being able to generate output that reports on configured layers
  465. with their paths and priorities and on ``.bbappend`` files and their
  466. applicable recipes can help to reveal potential problems.
  467. For help on the BitBake layer management tool, use the following
  468. command:
  469. ::
  470. $ bitbake-layers --help
  471. NOTE: Starting bitbake server...
  472. usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ...
  473. BitBake layers utility
  474. optional arguments:
  475. -d, --debug Enable debug output
  476. -q, --quiet Print only errors
  477. -F, --force Force add without recipe parse verification
  478. --color COLOR Colorize output (where COLOR is auto, always, never)
  479. -h, --help show this help message and exit
  480. subcommands:
  481. <subcommand>
  482. layerindex-fetch Fetches a layer from a layer index along with its
  483. dependent layers, and adds them to conf/bblayers.conf.
  484. layerindex-show-depends
  485. Find layer dependencies from layer index.
  486. add-layer Add one or more layers to bblayers.conf.
  487. remove-layer Remove one or more layers from bblayers.conf.
  488. flatten flatten layer configuration into a separate output
  489. directory.
  490. show-layers show current configured layers.
  491. show-overlayed list overlayed recipes (where the same recipe exists
  492. in another layer)
  493. show-recipes list available recipes, showing the layer they are
  494. provided by
  495. show-appends list bbappend files and recipe files they apply to
  496. show-cross-depends Show dependencies between recipes that cross layer
  497. boundaries.
  498. create-layer Create a basic layer
  499. Use bitbake-layers <subcommand> --help to get help on a specific command
  500. The following list describes the available commands:
  501. - ``help:`` Displays general help or help on a specified command.
  502. - ``show-layers:`` Shows the current configured layers.
  503. - ``show-overlayed:`` Lists overlayed recipes. A recipe is overlayed
  504. when a recipe with the same name exists in another layer that has a
  505. higher layer priority.
  506. - ``show-recipes:`` Lists available recipes and the layers that
  507. provide them.
  508. - ``show-appends:`` Lists ``.bbappend`` files and the recipe files to
  509. which they apply.
  510. - ``show-cross-depends:`` Lists dependency relationships between
  511. recipes that cross layer boundaries.
  512. - ``add-layer:`` Adds a layer to ``bblayers.conf``.
  513. - ``remove-layer:`` Removes a layer from ``bblayers.conf``
  514. - ``flatten:`` Flattens the layer configuration into a separate
  515. output directory. Flattening your layer configuration builds a
  516. "flattened" directory that contains the contents of all layers, with
  517. any overlayed recipes removed and any ``.bbappend`` files appended to
  518. the corresponding recipes. You might have to perform some manual
  519. cleanup of the flattened layer as follows:
  520. - Non-recipe files (such as patches) are overwritten. The flatten
  521. command shows a warning for these files.
  522. - Anything beyond the normal layer setup has been added to the
  523. ``layer.conf`` file. Only the lowest priority layer's
  524. ``layer.conf`` is used.
  525. - Overridden and appended items from ``.bbappend`` files need to be
  526. cleaned up. The contents of each ``.bbappend`` end up in the
  527. flattened recipe. However, if there are appended or changed
  528. variable values, you need to tidy these up yourself. Consider the
  529. following example. Here, the ``bitbake-layers`` command adds the
  530. line ``#### bbappended ...`` so that you know where the following
  531. lines originate:
  532. ::
  533. ...
  534. DESCRIPTION = "A useful utility"
  535. ...
  536. EXTRA_OECONF = "--enable-something"
  537. ...
  538. #### bbappended from meta-anotherlayer ####
  539. DESCRIPTION = "Customized utility"
  540. EXTRA_OECONF += "--enable-somethingelse"
  541. Ideally, you would tidy up these utilities as follows:
  542. ::
  543. ...
  544. DESCRIPTION = "Customized utility"
  545. ...
  546. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  547. ...
  548. - ``layerindex-fetch``: Fetches a layer from a layer index, along
  549. with its dependent layers, and adds the layers to the
  550. ``conf/bblayers.conf`` file.
  551. - ``layerindex-show-depends``: Finds layer dependencies from the
  552. layer index.
  553. - ``create-layer``: Creates a basic layer.
  554. Creating a General Layer Using the ``bitbake-layers`` Script
  555. ------------------------------------------------------------
  556. The ``bitbake-layers`` script with the ``create-layer`` subcommand
  557. simplifies creating a new general layer.
  558. .. note::
  559. - For information on BSP layers, see the ":ref:`bsp-guide/bsp:bsp layers`"
  560. section in the Yocto
  561. Project Board Specific (BSP) Developer's Guide.
  562. - In order to use a layer with the OpenEmbedded build system, you
  563. need to add the layer to your ``bblayers.conf`` configuration
  564. file. See the ":ref:`dev-manual/common-tasks:adding a layer using the \`\`bitbake-layers\`\` script`"
  565. section for more information.
  566. The default mode of the script's operation with this subcommand is to
  567. create a layer with the following:
  568. - A layer priority of 6.
  569. - A ``conf`` subdirectory that contains a ``layer.conf`` file.
  570. - A ``recipes-example`` subdirectory that contains a further
  571. subdirectory named ``example``, which contains an ``example.bb``
  572. recipe file.
  573. - A ``COPYING.MIT``, which is the license statement for the layer. The
  574. script assumes you want to use the MIT license, which is typical for
  575. most layers, for the contents of the layer itself.
  576. - A ``README`` file, which is a file describing the contents of your
  577. new layer.
  578. In its simplest form, you can use the following command form to create a
  579. layer. The command creates a layer whose name corresponds to
  580. "your_layer_name" in the current directory:
  581. ::
  582. $ bitbake-layers create-layer your_layer_name
  583. As an example, the following command creates a layer named ``meta-scottrif``
  584. in your home directory:
  585. ::
  586. $ cd /usr/home
  587. $ bitbake-layers create-layer meta-scottrif
  588. NOTE: Starting bitbake server...
  589. Add your new layer with 'bitbake-layers add-layer meta-scottrif'
  590. If you want to set the priority of the layer to other than the default
  591. value of "6", you can either use the ``--priority`` option or you
  592. can edit the
  593. :term:`BBFILE_PRIORITY` value
  594. in the ``conf/layer.conf`` after the script creates it. Furthermore, if
  595. you want to give the example recipe file some name other than the
  596. default, you can use the ``--example-recipe-name`` option.
  597. The easiest way to see how the ``bitbake-layers create-layer`` command
  598. works is to experiment with the script. You can also read the usage
  599. information by entering the following:
  600. ::
  601. $ bitbake-layers create-layer --help
  602. NOTE: Starting bitbake server...
  603. usage: bitbake-layers create-layer [-h] [--priority PRIORITY]
  604. [--example-recipe-name EXAMPLERECIPE]
  605. layerdir
  606. Create a basic layer
  607. positional arguments:
  608. layerdir Layer directory to create
  609. optional arguments:
  610. -h, --help show this help message and exit
  611. --priority PRIORITY, -p PRIORITY
  612. Layer directory to create
  613. --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE
  614. Filename of the example recipe
  615. Adding a Layer Using the ``bitbake-layers`` Script
  616. --------------------------------------------------
  617. Once you create your general layer, you must add it to your
  618. ``bblayers.conf`` file. Adding the layer to this configuration file
  619. makes the OpenEmbedded build system aware of your layer so that it can
  620. search it for metadata.
  621. Add your layer by using the ``bitbake-layers add-layer`` command:
  622. ::
  623. $ bitbake-layers add-layer your_layer_name
  624. Here is an example that adds a
  625. layer named ``meta-scottrif`` to the configuration file. Following the
  626. command that adds the layer is another ``bitbake-layers`` command that
  627. shows the layers that are in your ``bblayers.conf`` file:
  628. ::
  629. $ bitbake-layers add-layer meta-scottrif
  630. NOTE: Starting bitbake server...
  631. Parsing recipes: 100% |##########################################################| Time: 0:00:49
  632. Parsing of 1441 .bb files complete (0 cached, 1441 parsed). 2055 targets, 56 skipped, 0 masked, 0 errors.
  633. $ bitbake-layers show-layers
  634. NOTE: Starting bitbake server...
  635. layer path priority
  636. ==========================================================================
  637. meta /home/scottrif/poky/meta 5
  638. meta-poky /home/scottrif/poky/meta-poky 5
  639. meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5
  640. workspace /home/scottrif/poky/build/workspace 99
  641. meta-scottrif /home/scottrif/poky/build/meta-scottrif 6
  642. Adding the layer to this file
  643. enables the build system to locate the layer during the build.
  644. .. note::
  645. During a build, the OpenEmbedded build system looks in the layers
  646. from the top of the list down to the bottom in that order.
  647. Customizing Images
  648. ==================
  649. You can customize images to satisfy particular requirements. This
  650. section describes several methods and provides guidelines for each.
  651. Customizing Images Using ``local.conf``
  652. ---------------------------------------
  653. Probably the easiest way to customize an image is to add a package by
  654. way of the ``local.conf`` configuration file. Because it is limited to
  655. local use, this method generally only allows you to add packages and is
  656. not as flexible as creating your own customized image. When you add
  657. packages using local variables this way, you need to realize that these
  658. variable changes are in effect for every build and consequently affect
  659. all images, which might not be what you require.
  660. To add a package to your image using the local configuration file, use
  661. the ``IMAGE_INSTALL`` variable with the ``_append`` operator:
  662. ::
  663. IMAGE_INSTALL_append = " strace"
  664. Use of the syntax is important -
  665. specifically, the space between the quote and the package name, which is
  666. ``strace`` in this example. This space is required since the ``_append``
  667. operator does not add the space.
  668. Furthermore, you must use ``_append`` instead of the ``+=`` operator if
  669. you want to avoid ordering issues. The reason for this is because doing
  670. so unconditionally appends to the variable and avoids ordering problems
  671. due to the variable being set in image recipes and ``.bbclass`` files
  672. with operators like ``?=``. Using ``_append`` ensures the operation
  673. takes effect.
  674. As shown in its simplest use, ``IMAGE_INSTALL_append`` affects all
  675. images. It is possible to extend the syntax so that the variable applies
  676. to a specific image only. Here is an example:
  677. ::
  678. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  679. This example adds ``strace`` to the ``core-image-minimal`` image only.
  680. You can add packages using a similar approach through the
  681. ``CORE_IMAGE_EXTRA_INSTALL`` variable. If you use this variable, only
  682. ``core-image-*`` images are affected.
  683. Customizing Images Using Custom ``IMAGE_FEATURES`` and ``EXTRA_IMAGE_FEATURES``
  684. -------------------------------------------------------------------------------
  685. Another method for customizing your image is to enable or disable
  686. high-level image features by using the
  687. :term:`IMAGE_FEATURES` and
  688. :term:`EXTRA_IMAGE_FEATURES`
  689. variables. Although the functions for both variables are nearly
  690. equivalent, best practices dictate using ``IMAGE_FEATURES`` from within
  691. a recipe and using ``EXTRA_IMAGE_FEATURES`` from within your
  692. ``local.conf`` file, which is found in the
  693. :term:`Build Directory`.
  694. To understand how these features work, the best reference is
  695. ``meta/classes/core-image.bbclass``. This class lists out the available
  696. ``IMAGE_FEATURES`` of which most map to package groups while some, such
  697. as ``debug-tweaks`` and ``read-only-rootfs``, resolve as general
  698. configuration settings.
  699. In summary, the file looks at the contents of the ``IMAGE_FEATURES``
  700. variable and then maps or configures the feature accordingly. Based on
  701. this information, the build system automatically adds the appropriate
  702. packages or configurations to the
  703. :term:`IMAGE_INSTALL` variable.
  704. Effectively, you are enabling extra features by extending the class or
  705. creating a custom class for use with specialized image ``.bb`` files.
  706. Use the ``EXTRA_IMAGE_FEATURES`` variable from within your local
  707. configuration file. Using a separate area from which to enable features
  708. with this variable helps you avoid overwriting the features in the image
  709. recipe that are enabled with ``IMAGE_FEATURES``. The value of
  710. ``EXTRA_IMAGE_FEATURES`` is added to ``IMAGE_FEATURES`` within
  711. ``meta/conf/bitbake.conf``.
  712. To illustrate how you can use these variables to modify your image,
  713. consider an example that selects the SSH server. The Yocto Project ships
  714. with two SSH servers you can use with your images: Dropbear and OpenSSH.
  715. Dropbear is a minimal SSH server appropriate for resource-constrained
  716. environments, while OpenSSH is a well-known standard SSH server
  717. implementation. By default, the ``core-image-sato`` image is configured
  718. to use Dropbear. The ``core-image-full-cmdline`` and ``core-image-lsb``
  719. images both include OpenSSH. The ``core-image-minimal`` image does not
  720. contain an SSH server.
  721. You can customize your image and change these defaults. Edit the
  722. ``IMAGE_FEATURES`` variable in your recipe or use the
  723. ``EXTRA_IMAGE_FEATURES`` in your ``local.conf`` file so that it
  724. configures the image you are working with to include
  725. ``ssh-server-dropbear`` or ``ssh-server-openssh``.
  726. .. note::
  727. See the ":ref:`ref-manual/features:image features`" section in the Yocto
  728. Project Reference Manual for a complete list of image features that ship
  729. with the Yocto Project.
  730. Customizing Images Using Custom .bb Files
  731. -----------------------------------------
  732. You can also customize an image by creating a custom recipe that defines
  733. additional software as part of the image. The following example shows
  734. the form for the two lines you need:
  735. ::
  736. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  737. inherit core-image
  738. Defining the software using a custom recipe gives you total control over
  739. the contents of the image. It is important to use the correct names of
  740. packages in the ``IMAGE_INSTALL`` variable. You must use the
  741. OpenEmbedded notation and not the Debian notation for the names (e.g.
  742. ``glibc-dev`` instead of ``libc6-dev``).
  743. The other method for creating a custom image is to base it on an
  744. existing image. For example, if you want to create an image based on
  745. ``core-image-sato`` but add the additional package ``strace`` to the
  746. image, copy the ``meta/recipes-sato/images/core-image-sato.bb`` to a new
  747. ``.bb`` and add the following line to the end of the copy:
  748. ::
  749. IMAGE_INSTALL += "strace"
  750. Customizing Images Using Custom Package Groups
  751. ----------------------------------------------
  752. For complex custom images, the best approach for customizing an image is
  753. to create a custom package group recipe that is used to build the image
  754. or images. A good example of a package group recipe is
  755. ``meta/recipes-core/packagegroups/packagegroup-base.bb``.
  756. If you examine that recipe, you see that the ``PACKAGES`` variable lists
  757. the package group packages to produce. The ``inherit packagegroup``
  758. statement sets appropriate default values and automatically adds
  759. ``-dev``, ``-dbg``, and ``-ptest`` complementary packages for each
  760. package specified in the ``PACKAGES`` statement.
  761. .. note::
  762. The ``inherit packagegroup`` line should be located near the top of the
  763. recipe, certainly before the ``PACKAGES`` statement.
  764. For each package you specify in ``PACKAGES``, you can use ``RDEPENDS``
  765. and ``RRECOMMENDS`` entries to provide a list of packages the parent
  766. task package should contain. You can see examples of these further down
  767. in the ``packagegroup-base.bb`` recipe.
  768. Here is a short, fabricated example showing the same basic pieces for a
  769. hypothetical packagegroup defined in ``packagegroup-custom.bb``, where
  770. the variable ``PN`` is the standard way to abbreviate the reference to
  771. the full packagegroup name ``packagegroup-custom``:
  772. ::
  773. DESCRIPTION = "My Custom Package Groups"
  774. inherit packagegroup
  775. PACKAGES = "\
  776. ${PN}-apps \
  777. ${PN}-tools \
  778. "
  779. RDEPENDS_${PN}-apps = "\
  780. dropbear \
  781. portmap \
  782. psplash"
  783. RDEPENDS_${PN}-tools = "\
  784. oprofile \
  785. oprofileui-server \
  786. lttng-tools"
  787. RRECOMMENDS_${PN}-tools = "\
  788. kernel-module-oprofile"
  789. In the previous example, two package group packages are created with
  790. their dependencies and their recommended package dependencies listed:
  791. ``packagegroup-custom-apps``, and ``packagegroup-custom-tools``. To
  792. build an image using these package group packages, you need to add
  793. ``packagegroup-custom-apps`` and/or ``packagegroup-custom-tools`` to
  794. ``IMAGE_INSTALL``. For other forms of image dependencies see the other
  795. areas of this section.
  796. Customizing an Image Hostname
  797. -----------------------------
  798. By default, the configured hostname (i.e. ``/etc/hostname``) in an image
  799. is the same as the machine name. For example, if
  800. :term:`MACHINE` equals "qemux86", the
  801. configured hostname written to ``/etc/hostname`` is "qemux86".
  802. You can customize this name by altering the value of the "hostname"
  803. variable in the ``base-files`` recipe using either an append file or a
  804. configuration file. Use the following in an append file:
  805. ::
  806. hostname = "myhostname"
  807. Use the following in a configuration file:
  808. ::
  809. hostname_pn-base-files = "myhostname"
  810. Changing the default value of the variable "hostname" can be useful in
  811. certain situations. For example, suppose you need to do extensive
  812. testing on an image and you would like to easily identify the image
  813. under test from existing images with typical default hostnames. In this
  814. situation, you could change the default hostname to "testme", which
  815. results in all the images using the name "testme". Once testing is
  816. complete and you do not need to rebuild the image for test any longer,
  817. you can easily reset the default hostname.
  818. Another point of interest is that if you unset the variable, the image
  819. will have no default hostname in the filesystem. Here is an example that
  820. unsets the variable in a configuration file:
  821. ::
  822. hostname_pn-base-files = ""
  823. Having no default hostname in the filesystem is suitable for
  824. environments that use dynamic hostnames such as virtual machines.
  825. Writing a New Recipe
  826. ====================
  827. Recipes (``.bb`` files) are fundamental components in the Yocto Project
  828. environment. Each software component built by the OpenEmbedded build
  829. system requires a recipe to define the component. This section describes
  830. how to create, write, and test a new recipe.
  831. .. note::
  832. For information on variables that are useful for recipes and for
  833. information about recipe naming issues, see the
  834. ":ref:`ref-manual/varlocality:recipes`" section of the Yocto Project
  835. Reference Manual.
  836. Overview
  837. --------
  838. The following figure shows the basic process for creating a new recipe.
  839. The remainder of the section provides details for the steps.
  840. .. image:: figures/recipe-workflow.png
  841. :align: center
  842. Locate or Automatically Create a Base Recipe
  843. --------------------------------------------
  844. You can always write a recipe from scratch. However, three choices exist
  845. that can help you quickly get a start on a new recipe:
  846. - ``devtool add``: A command that assists in creating a recipe and an
  847. environment conducive to development.
  848. - ``recipetool create``: A command provided by the Yocto Project that
  849. automates creation of a base recipe based on the source files.
  850. - *Existing Recipes:* Location and modification of an existing recipe
  851. that is similar in function to the recipe you need.
  852. .. note::
  853. For information on recipe syntax, see the
  854. ":ref:`dev-manual/common-tasks:recipe syntax`" section.
  855. Creating the Base Recipe Using ``devtool add``
  856. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  857. The ``devtool add`` command uses the same logic for auto-creating the
  858. recipe as ``recipetool create``, which is listed below. Additionally,
  859. however, ``devtool add`` sets up an environment that makes it easy for
  860. you to patch the source and to make changes to the recipe as is often
  861. necessary when adding a recipe to build a new piece of software to be
  862. included in a build.
  863. You can find a complete description of the ``devtool add`` command in
  864. the ":ref:`sdk-manual/extensible:a closer look at \`\`devtool add\`\``" section
  865. in the Yocto Project Application Development and the Extensible Software
  866. Development Kit (eSDK) manual.
  867. Creating the Base Recipe Using ``recipetool create``
  868. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  869. ``recipetool create`` automates creation of a base recipe given a set of
  870. source code files. As long as you can extract or point to the source
  871. files, the tool will construct a recipe and automatically configure all
  872. pre-build information into the recipe. For example, suppose you have an
  873. application that builds using Autotools. Creating the base recipe using
  874. ``recipetool`` results in a recipe that has the pre-build dependencies,
  875. license requirements, and checksums configured.
  876. To run the tool, you just need to be in your
  877. :term:`Build Directory` and have sourced the
  878. build environment setup script (i.e.
  879. :ref:`structure-core-script`).
  880. To get help on the tool, use the following command:
  881. ::
  882. $ recipetool -h
  883. NOTE: Starting bitbake server...
  884. usage: recipetool [-d] [-q] [--color COLOR] [-h] <subcommand> ...
  885. OpenEmbedded recipe tool
  886. options:
  887. -d, --debug Enable debug output
  888. -q, --quiet Print only errors
  889. --color COLOR Colorize output (where COLOR is auto, always, never)
  890. -h, --help show this help message and exit
  891. subcommands:
  892. create Create a new recipe
  893. newappend Create a bbappend for the specified target in the specified
  894. layer
  895. setvar Set a variable within a recipe
  896. appendfile Create/update a bbappend to replace a target file
  897. appendsrcfiles Create/update a bbappend to add or replace source files
  898. appendsrcfile Create/update a bbappend to add or replace a source file
  899. Use recipetool <subcommand> --help to get help on a specific command
  900. Running ``recipetool create -o OUTFILE`` creates the base recipe and
  901. locates it properly in the layer that contains your source files.
  902. Following are some syntax examples:
  903. - Use this syntax to generate a recipe based on source. Once generated,
  904. the recipe resides in the existing source code layer:
  905. ::
  906. recipetool create -o OUTFILE source
  907. - Use this syntax to generate a recipe using code that
  908. you extract from source. The extracted code is placed in its own layer
  909. defined by ``EXTERNALSRC``.
  910. ::
  911. recipetool create -o OUTFILE -x EXTERNALSRC source
  912. - Use this syntax to generate a recipe based on source. The options
  913. direct ``recipetool`` to generate debugging information. Once generated,
  914. the recipe resides in the existing source code layer:
  915. ::
  916. recipetool create -d -o OUTFILE source
  917. Locating and Using a Similar Recipe
  918. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  919. Before writing a recipe from scratch, it is often useful to discover
  920. whether someone else has already written one that meets (or comes close
  921. to meeting) your needs. The Yocto Project and OpenEmbedded communities
  922. maintain many recipes that might be candidates for what you are doing.
  923. You can find a good central index of these recipes in the
  924. :oe_layerindex:`OpenEmbedded Layer Index <>`.
  925. Working from an existing recipe or a skeleton recipe is the best way to
  926. get started. Here are some points on both methods:
  927. - *Locate and modify a recipe that is close to what you want to do:*
  928. This method works when you are familiar with the current recipe
  929. space. The method does not work so well for those new to the Yocto
  930. Project or writing recipes.
  931. Some risks associated with this method are using a recipe that has
  932. areas totally unrelated to what you are trying to accomplish with
  933. your recipe, not recognizing areas of the recipe that you might have
  934. to add from scratch, and so forth. All these risks stem from
  935. unfamiliarity with the existing recipe space.
  936. - *Use and modify the following skeleton recipe:* If for some reason
  937. you do not want to use ``recipetool`` and you cannot find an existing
  938. recipe that is close to meeting your needs, you can use the following
  939. structure to provide the fundamental areas of a new recipe.
  940. ::
  941. DESCRIPTION = ""
  942. HOMEPAGE = ""
  943. LICENSE = ""
  944. SECTION = ""
  945. DEPENDS = ""
  946. LIC_FILES_CHKSUM = ""
  947. SRC_URI = ""
  948. Storing and Naming the Recipe
  949. -----------------------------
  950. Once you have your base recipe, you should put it in your own layer and
  951. name it appropriately. Locating it correctly ensures that the
  952. OpenEmbedded build system can find it when you use BitBake to process
  953. the recipe.
  954. - *Storing Your Recipe:* The OpenEmbedded build system locates your
  955. recipe through the layer's ``conf/layer.conf`` file and the
  956. :term:`BBFILES` variable. This
  957. variable sets up a path from which the build system can locate
  958. recipes. Here is the typical use:
  959. ::
  960. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  961. ${LAYERDIR}/recipes-*/*/*.bbappend"
  962. Consequently, you need to be sure you locate your new recipe inside
  963. your layer such that it can be found.
  964. You can find more information on how layers are structured in the
  965. ":ref:`dev-manual/common-tasks:understanding and creating layers`" section.
  966. - *Naming Your Recipe:* When you name your recipe, you need to follow
  967. this naming convention:
  968. ::
  969. basename_version.bb
  970. Use lower-cased characters and do not include the reserved suffixes
  971. ``-native``, ``-cross``, ``-initial``, or ``-dev`` casually (i.e. do not use
  972. them as part of your recipe name unless the string applies). Here are some
  973. examples:
  974. .. code-block:: none
  975. cups_1.7.0.bb
  976. gawk_4.0.2.bb
  977. irssi_0.8.16-rc1.bb
  978. Running a Build on the Recipe
  979. -----------------------------
  980. Creating a new recipe is usually an iterative process that requires
  981. using BitBake to process the recipe multiple times in order to
  982. progressively discover and add information to the recipe file.
  983. Assuming you have sourced the build environment setup script (i.e.
  984. :ref:`structure-core-script`) and you are in
  985. the :term:`Build Directory`, use
  986. BitBake to process your recipe. All you need to provide is the
  987. ``basename`` of the recipe as described in the previous section:
  988. ::
  989. $ bitbake basename
  990. During the build, the OpenEmbedded build system creates a temporary work
  991. directory for each recipe
  992. (``${``\ :term:`WORKDIR`\ ``}``)
  993. where it keeps extracted source files, log files, intermediate
  994. compilation and packaging files, and so forth.
  995. The path to the per-recipe temporary work directory depends on the
  996. context in which it is being built. The quickest way to find this path
  997. is to have BitBake return it by running the following:
  998. ::
  999. $ bitbake -e basename | grep ^WORKDIR=
  1000. As an example, assume a Source Directory
  1001. top-level folder named ``poky``, a default Build Directory at
  1002. ``poky/build``, and a ``qemux86-poky-linux`` machine target system.
  1003. Furthermore, suppose your recipe is named ``foo_1.3.0.bb``. In this
  1004. case, the work directory the build system uses to build the package
  1005. would be as follows:
  1006. ::
  1007. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1008. Inside this directory you can find sub-directories such as ``image``,
  1009. ``packages-split``, and ``temp``. After the build, you can examine these
  1010. to determine how well the build went.
  1011. .. note::
  1012. You can find log files for each task in the recipe's ``temp``
  1013. directory (e.g. ``poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp``).
  1014. Log files are named ``log.taskname`` (e.g. ``log.do_configure``,
  1015. ``log.do_fetch``, and ``log.do_compile``).
  1016. You can find more information about the build process in
  1017. ":doc:`/overview-manual/development-environment`"
  1018. chapter of the Yocto Project Overview and Concepts Manual.
  1019. Fetching Code
  1020. -------------
  1021. The first thing your recipe must do is specify how to fetch the source
  1022. files. Fetching is controlled mainly through the
  1023. :term:`SRC_URI` variable. Your recipe
  1024. must have a ``SRC_URI`` variable that points to where the source is
  1025. located. For a graphical representation of source locations, see the
  1026. ":ref:`overview-manual/concepts:sources`" section in
  1027. the Yocto Project Overview and Concepts Manual.
  1028. The :ref:`ref-tasks-fetch` task uses
  1029. the prefix of each entry in the ``SRC_URI`` variable value to determine
  1030. which :ref:`fetcher <bitbake:bitbake-user-manual/bitbake-user-manual-fetching:fetchers>` to use to get your
  1031. source files. It is the ``SRC_URI`` variable that triggers the fetcher.
  1032. The :ref:`ref-tasks-patch` task uses
  1033. the variable after source is fetched to apply patches. The OpenEmbedded
  1034. build system uses
  1035. :term:`FILESOVERRIDES` for
  1036. scanning directory locations for local files in ``SRC_URI``.
  1037. The ``SRC_URI`` variable in your recipe must define each unique location
  1038. for your source files. It is good practice to not hard-code version
  1039. numbers in a URL used in ``SRC_URI``. Rather than hard-code these
  1040. values, use ``${``\ :term:`PV`\ ``}``,
  1041. which causes the fetch process to use the version specified in the
  1042. recipe filename. Specifying the version in this manner means that
  1043. upgrading the recipe to a future version is as simple as renaming the
  1044. recipe to match the new version.
  1045. Here is a simple example from the
  1046. ``meta/recipes-devtools/strace/strace_5.5.bb`` recipe where the source
  1047. comes from a single tarball. Notice the use of the
  1048. :term:`PV` variable:
  1049. ::
  1050. SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
  1051. Files mentioned in ``SRC_URI`` whose names end in a typical archive
  1052. extension (e.g. ``.tar``, ``.tar.gz``, ``.tar.bz2``, ``.zip``, and so
  1053. forth), are automatically extracted during the
  1054. :ref:`ref-tasks-unpack` task. For
  1055. another example that specifies these types of files, see the
  1056. ":ref:`dev-manual/common-tasks:autotooled package`" section.
  1057. Another way of specifying source is from an SCM. For Git repositories,
  1058. you must specify :term:`SRCREV` and
  1059. you should specify :term:`PV` to include
  1060. the revision with :term:`SRCPV`. Here
  1061. is an example from the recipe
  1062. ``meta/recipes-kernel/blktrace/blktrace_git.bb``:
  1063. ::
  1064. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1065. PR = "r6"
  1066. PV = "1.0.5+git${SRCPV}"
  1067. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1068. file://ldflags.patch"
  1069. If your ``SRC_URI`` statement includes URLs pointing to individual files
  1070. fetched from a remote server other than a version control system,
  1071. BitBake attempts to verify the files against checksums defined in your
  1072. recipe to ensure they have not been tampered with or otherwise modified
  1073. since the recipe was written. Two checksums are used:
  1074. ``SRC_URI[md5sum]`` and ``SRC_URI[sha256sum]``.
  1075. If your ``SRC_URI`` variable points to more than a single URL (excluding
  1076. SCM URLs), you need to provide the ``md5`` and ``sha256`` checksums for
  1077. each URL. For these cases, you provide a name for each URL as part of
  1078. the ``SRC_URI`` and then reference that name in the subsequent checksum
  1079. statements. Here is an example combining lines from the files
  1080. ``git.inc`` and ``git_2.24.1.bb``:
  1081. ::
  1082. SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \
  1083. ${KERNELORG_MIRROR}/software/scm/git/git-manpages-${PV}.tar.gz;name=manpages"
  1084. SRC_URI[tarball.md5sum] = "166bde96adbbc11c8843d4f8f4f9811b"
  1085. SRC_URI[tarball.sha256sum] = "ad5334956301c86841eb1e5b1bb20884a6bad89a10a6762c958220c7cf64da02"
  1086. SRC_URI[manpages.md5sum] = "31c2272a8979022497ba3d4202df145d"
  1087. SRC_URI[manpages.sha256sum] = "9a7ae3a093bea39770eb96ca3e5b40bff7af0b9f6123f089d7821d0e5b8e1230"
  1088. Proper values for ``md5`` and ``sha256`` checksums might be available
  1089. with other signatures on the download page for the upstream source (e.g.
  1090. ``md5``, ``sha1``, ``sha256``, ``GPG``, and so forth). Because the
  1091. OpenEmbedded build system only deals with ``sha256sum`` and ``md5sum``,
  1092. you should verify all the signatures you find by hand.
  1093. If no ``SRC_URI`` checksums are specified when you attempt to build the
  1094. recipe, or you provide an incorrect checksum, the build will produce an
  1095. error for each missing or incorrect checksum. As part of the error
  1096. message, the build system provides the checksum string corresponding to
  1097. the fetched file. Once you have the correct checksums, you can copy and
  1098. paste them into your recipe and then run the build again to continue.
  1099. .. note::
  1100. As mentioned, if the upstream source provides signatures for
  1101. verifying the downloaded source code, you should verify those
  1102. manually before setting the checksum values in the recipe and
  1103. continuing with the build.
  1104. This final example is a bit more complicated and is from the
  1105. ``meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb`` recipe. The
  1106. example's ``SRC_URI`` statement identifies multiple files as the source
  1107. files for the recipe: a tarball, a patch file, a desktop file, and an
  1108. icon.
  1109. ::
  1110. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1111. file://xwc.patch \
  1112. file://rxvt.desktop \
  1113. file://rxvt.png"
  1114. When you specify local files using the ``file://`` URI protocol, the
  1115. build system fetches files from the local machine. The path is relative
  1116. to the :term:`FILESPATH` variable
  1117. and searches specific directories in a certain order:
  1118. ``${``\ :term:`BP`\ ``}``,
  1119. ``${``\ :term:`BPN`\ ``}``, and
  1120. ``files``. The directories are assumed to be subdirectories of the
  1121. directory in which the recipe or append file resides. For another
  1122. example that specifies these types of files, see the
  1123. ":ref:`dev-manual/common-tasks:single .c file package (hello world!)`" section.
  1124. The previous example also specifies a patch file. Patch files are files
  1125. whose names usually end in ``.patch`` or ``.diff`` but can end with
  1126. compressed suffixes such as ``diff.gz`` and ``patch.bz2``, for example.
  1127. The build system automatically applies patches as described in the
  1128. ":ref:`dev-manual/common-tasks:patching code`" section.
  1129. Unpacking Code
  1130. --------------
  1131. During the build, the
  1132. :ref:`ref-tasks-unpack` task unpacks
  1133. the source with ``${``\ :term:`S`\ ``}``
  1134. pointing to where it is unpacked.
  1135. If you are fetching your source files from an upstream source archived
  1136. tarball and the tarball's internal structure matches the common
  1137. convention of a top-level subdirectory named
  1138. ``${``\ :term:`BPN`\ ``}-${``\ :term:`PV`\ ``}``,
  1139. then you do not need to set ``S``. However, if ``SRC_URI`` specifies to
  1140. fetch source from an archive that does not use this convention, or from
  1141. an SCM like Git or Subversion, your recipe needs to define ``S``.
  1142. If processing your recipe using BitBake successfully unpacks the source
  1143. files, you need to be sure that the directory pointed to by ``${S}``
  1144. matches the structure of the source.
  1145. Patching Code
  1146. -------------
  1147. Sometimes it is necessary to patch code after it has been fetched. Any
  1148. files mentioned in ``SRC_URI`` whose names end in ``.patch`` or
  1149. ``.diff`` or compressed versions of these suffixes (e.g. ``diff.gz`` are
  1150. treated as patches. The
  1151. :ref:`ref-tasks-patch` task
  1152. automatically applies these patches.
  1153. The build system should be able to apply patches with the "-p1" option
  1154. (i.e. one directory level in the path will be stripped off). If your
  1155. patch needs to have more directory levels stripped off, specify the
  1156. number of levels using the "striplevel" option in the ``SRC_URI`` entry
  1157. for the patch. Alternatively, if your patch needs to be applied in a
  1158. specific subdirectory that is not specified in the patch file, use the
  1159. "patchdir" option in the entry.
  1160. As with all local files referenced in
  1161. :term:`SRC_URI` using ``file://``,
  1162. you should place patch files in a directory next to the recipe either
  1163. named the same as the base name of the recipe
  1164. (:term:`BP` and
  1165. :term:`BPN`) or "files".
  1166. Licensing
  1167. ---------
  1168. Your recipe needs to have both the
  1169. :term:`LICENSE` and
  1170. :term:`LIC_FILES_CHKSUM`
  1171. variables:
  1172. - ``LICENSE``: This variable specifies the license for the software.
  1173. If you do not know the license under which the software you are
  1174. building is distributed, you should go to the source code and look
  1175. for that information. Typical files containing this information
  1176. include ``COPYING``, ``LICENSE``, and ``README`` files. You could
  1177. also find the information near the top of a source file. For example,
  1178. given a piece of software licensed under the GNU General Public
  1179. License version 2, you would set ``LICENSE`` as follows:
  1180. ::
  1181. LICENSE = "GPLv2"
  1182. The licenses you specify within ``LICENSE`` can have any name as long
  1183. as you do not use spaces, since spaces are used as separators between
  1184. license names. For standard licenses, use the names of the files in
  1185. ``meta/files/common-licenses/`` or the ``SPDXLICENSEMAP`` flag names
  1186. defined in ``meta/conf/licenses.conf``.
  1187. - ``LIC_FILES_CHKSUM``: The OpenEmbedded build system uses this
  1188. variable to make sure the license text has not changed. If it has,
  1189. the build produces an error and it affords you the chance to figure
  1190. it out and correct the problem.
  1191. You need to specify all applicable licensing files for the software.
  1192. At the end of the configuration step, the build process will compare
  1193. the checksums of the files to be sure the text has not changed. Any
  1194. differences result in an error with the message containing the
  1195. current checksum. For more explanation and examples of how to set the
  1196. ``LIC_FILES_CHKSUM`` variable, see the
  1197. ":ref:`dev-manual/common-tasks:tracking license changes`" section.
  1198. To determine the correct checksum string, you can list the
  1199. appropriate files in the ``LIC_FILES_CHKSUM`` variable with incorrect
  1200. md5 strings, attempt to build the software, and then note the
  1201. resulting error messages that will report the correct md5 strings.
  1202. See the ":ref:`dev-manual/common-tasks:fetching code`" section for
  1203. additional information.
  1204. Here is an example that assumes the software has a ``COPYING`` file:
  1205. ::
  1206. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  1207. When you try to build the
  1208. software, the build system will produce an error and give you the
  1209. correct string that you can substitute into the recipe file for a
  1210. subsequent build.
  1211. Dependencies
  1212. ------------
  1213. Most software packages have a short list of other packages that they
  1214. require, which are called dependencies. These dependencies fall into two
  1215. main categories: build-time dependencies, which are required when the
  1216. software is built; and runtime dependencies, which are required to be
  1217. installed on the target in order for the software to run.
  1218. Within a recipe, you specify build-time dependencies using the
  1219. :term:`DEPENDS` variable. Although
  1220. nuances exist, items specified in ``DEPENDS`` should be names of other
  1221. recipes. It is important that you specify all build-time dependencies
  1222. explicitly.
  1223. Another consideration is that configure scripts might automatically
  1224. check for optional dependencies and enable corresponding functionality
  1225. if those dependencies are found. If you wish to make a recipe that is
  1226. more generally useful (e.g. publish the recipe in a layer for others to
  1227. use), instead of hard-disabling the functionality, you can use the
  1228. :term:`PACKAGECONFIG` variable to allow functionality and the
  1229. corresponding dependencies to be enabled and disabled easily by other
  1230. users of the recipe.
  1231. Similar to build-time dependencies, you specify runtime dependencies
  1232. through a variable -
  1233. :term:`RDEPENDS`, which is
  1234. package-specific. All variables that are package-specific need to have
  1235. the name of the package added to the end as an override. Since the main
  1236. package for a recipe has the same name as the recipe, and the recipe's
  1237. name can be found through the
  1238. ``${``\ :term:`PN`\ ``}`` variable, then
  1239. you specify the dependencies for the main package by setting
  1240. ``RDEPENDS_${PN}``. If the package were named ``${PN}-tools``, then you
  1241. would set ``RDEPENDS_${PN}-tools``, and so forth.
  1242. Some runtime dependencies will be set automatically at packaging time.
  1243. These dependencies include any shared library dependencies (i.e. if a
  1244. package "example" contains "libexample" and another package "mypackage"
  1245. contains a binary that links to "libexample" then the OpenEmbedded build
  1246. system will automatically add a runtime dependency to "mypackage" on
  1247. "example"). See the
  1248. ":ref:`overview-manual/concepts:automatically added runtime dependencies`"
  1249. section in the Yocto Project Overview and Concepts Manual for further
  1250. details.
  1251. Configuring the Recipe
  1252. ----------------------
  1253. Most software provides some means of setting build-time configuration
  1254. options before compilation. Typically, setting these options is
  1255. accomplished by running a configure script with options, or by modifying
  1256. a build configuration file.
  1257. .. note::
  1258. As of Yocto Project Release 1.7, some of the core recipes that
  1259. package binary configuration scripts now disable the scripts due to
  1260. the scripts previously requiring error-prone path substitution. The
  1261. OpenEmbedded build system uses ``pkg-config`` now, which is much more
  1262. robust. You can find a list of the ``*-config`` scripts that are disabled
  1263. in the ":ref:`migration-1.7-binary-configuration-scripts-disabled`" section
  1264. in the Yocto Project Reference Manual.
  1265. A major part of build-time configuration is about checking for
  1266. build-time dependencies and possibly enabling optional functionality as
  1267. a result. You need to specify any build-time dependencies for the
  1268. software you are building in your recipe's
  1269. :term:`DEPENDS` value, in terms of
  1270. other recipes that satisfy those dependencies. You can often find
  1271. build-time or runtime dependencies described in the software's
  1272. documentation.
  1273. The following list provides configuration items of note based on how
  1274. your software is built:
  1275. - *Autotools:* If your source files have a ``configure.ac`` file, then
  1276. your software is built using Autotools. If this is the case, you just
  1277. need to worry about modifying the configuration.
  1278. When using Autotools, your recipe needs to inherit the
  1279. :ref:`autotools <ref-classes-autotools>` class
  1280. and your recipe does not have to contain a
  1281. :ref:`ref-tasks-configure` task.
  1282. However, you might still want to make some adjustments. For example,
  1283. you can set
  1284. :term:`EXTRA_OECONF` or
  1285. :term:`PACKAGECONFIG_CONFARGS`
  1286. to pass any needed configure options that are specific to the recipe.
  1287. - *CMake:* If your source files have a ``CMakeLists.txt`` file, then
  1288. your software is built using CMake. If this is the case, you just
  1289. need to worry about modifying the configuration.
  1290. When you use CMake, your recipe needs to inherit the
  1291. :ref:`cmake <ref-classes-cmake>` class and your
  1292. recipe does not have to contain a
  1293. :ref:`ref-tasks-configure` task.
  1294. You can make some adjustments by setting
  1295. :term:`EXTRA_OECMAKE` to
  1296. pass any needed configure options that are specific to the recipe.
  1297. .. note::
  1298. If you need to install one or more custom CMake toolchain files
  1299. that are supplied by the application you are building, install the
  1300. files to ``${D}${datadir}/cmake/Modules`` during ``do_install``.
  1301. - *Other:* If your source files do not have a ``configure.ac`` or
  1302. ``CMakeLists.txt`` file, then your software is built using some
  1303. method other than Autotools or CMake. If this is the case, you
  1304. normally need to provide a
  1305. :ref:`ref-tasks-configure` task
  1306. in your recipe unless, of course, there is nothing to configure.
  1307. Even if your software is not being built by Autotools or CMake, you
  1308. still might not need to deal with any configuration issues. You need
  1309. to determine if configuration is even a required step. You might need
  1310. to modify a Makefile or some configuration file used for the build to
  1311. specify necessary build options. Or, perhaps you might need to run a
  1312. provided, custom configure script with the appropriate options.
  1313. For the case involving a custom configure script, you would run
  1314. ``./configure --help`` and look for the options you need to set.
  1315. Once configuration succeeds, it is always good practice to look at the
  1316. ``log.do_configure`` file to ensure that the appropriate options have
  1317. been enabled and no additional build-time dependencies need to be added
  1318. to ``DEPENDS``. For example, if the configure script reports that it
  1319. found something not mentioned in ``DEPENDS``, or that it did not find
  1320. something that it needed for some desired optional functionality, then
  1321. you would need to add those to ``DEPENDS``. Looking at the log might
  1322. also reveal items being checked for, enabled, or both that you do not
  1323. want, or items not being found that are in ``DEPENDS``, in which case
  1324. you would need to look at passing extra options to the configure script
  1325. as needed. For reference information on configure options specific to
  1326. the software you are building, you can consult the output of the
  1327. ``./configure --help`` command within ``${S}`` or consult the software's
  1328. upstream documentation.
  1329. Using Headers to Interface with Devices
  1330. ---------------------------------------
  1331. If your recipe builds an application that needs to communicate with some
  1332. device or needs an API into a custom kernel, you will need to provide
  1333. appropriate header files. Under no circumstances should you ever modify
  1334. the existing
  1335. ``meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc`` file.
  1336. These headers are used to build ``libc`` and must not be compromised
  1337. with custom or machine-specific header information. If you customize
  1338. ``libc`` through modified headers all other applications that use
  1339. ``libc`` thus become affected.
  1340. .. note::
  1341. Never copy and customize the ``libc`` header file (i.e.
  1342. ``meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc``).
  1343. The correct way to interface to a device or custom kernel is to use a
  1344. separate package that provides the additional headers for the driver or
  1345. other unique interfaces. When doing so, your application also becomes
  1346. responsible for creating a dependency on that specific provider.
  1347. Consider the following:
  1348. - Never modify ``linux-libc-headers.inc``. Consider that file to be
  1349. part of the ``libc`` system, and not something you use to access the
  1350. kernel directly. You should access ``libc`` through specific ``libc``
  1351. calls.
  1352. - Applications that must talk directly to devices should either provide
  1353. necessary headers themselves, or establish a dependency on a special
  1354. headers package that is specific to that driver.
  1355. For example, suppose you want to modify an existing header that adds I/O
  1356. control or network support. If the modifications are used by a small
  1357. number programs, providing a unique version of a header is easy and has
  1358. little impact. When doing so, bear in mind the guidelines in the
  1359. previous list.
  1360. .. note::
  1361. If for some reason your changes need to modify the behavior of the ``libc``,
  1362. and subsequently all other applications on the system, use a ``.bbappend``
  1363. to modify the ``linux-kernel-headers.inc`` file. However, take care to not
  1364. make the changes machine specific.
  1365. Consider a case where your kernel is older and you need an older
  1366. ``libc`` ABI. The headers installed by your recipe should still be a
  1367. standard mainline kernel, not your own custom one.
  1368. When you use custom kernel headers you need to get them from
  1369. :term:`STAGING_KERNEL_DIR`,
  1370. which is the directory with kernel headers that are required to build
  1371. out-of-tree modules. Your recipe will also need the following:
  1372. ::
  1373. do_configure[depends] += "virtual/kernel:do_shared_workdir"
  1374. Compilation
  1375. -----------
  1376. During a build, the ``do_compile`` task happens after source is fetched,
  1377. unpacked, and configured. If the recipe passes through ``do_compile``
  1378. successfully, nothing needs to be done.
  1379. However, if the compile step fails, you need to diagnose the failure.
  1380. Here are some common issues that cause failures.
  1381. .. note::
  1382. For cases where improper paths are detected for configuration files
  1383. or for when libraries/headers cannot be found, be sure you are using
  1384. the more robust ``pkg-config``. See the note in section
  1385. ":ref:`dev-manual/common-tasks:Configuring the Recipe`" for additional information.
  1386. - *Parallel build failures:* These failures manifest themselves as
  1387. intermittent errors, or errors reporting that a file or directory
  1388. that should be created by some other part of the build process could
  1389. not be found. This type of failure can occur even if, upon
  1390. inspection, the file or directory does exist after the build has
  1391. failed, because that part of the build process happened in the wrong
  1392. order.
  1393. To fix the problem, you need to either satisfy the missing dependency
  1394. in the Makefile or whatever script produced the Makefile, or (as a
  1395. workaround) set :term:`PARALLEL_MAKE` to an empty string:
  1396. ::
  1397. PARALLEL_MAKE = ""
  1398. For information on parallel Makefile issues, see the
  1399. ":ref:`dev-manual/common-tasks:debugging parallel make races`" section.
  1400. - *Improper host path usage:* This failure applies to recipes building
  1401. for the target or ``nativesdk`` only. The failure occurs when the
  1402. compilation process uses improper headers, libraries, or other files
  1403. from the host system when cross-compiling for the target.
  1404. To fix the problem, examine the ``log.do_compile`` file to identify
  1405. the host paths being used (e.g. ``/usr/include``, ``/usr/lib``, and
  1406. so forth) and then either add configure options, apply a patch, or do
  1407. both.
  1408. - *Failure to find required libraries/headers:* If a build-time
  1409. dependency is missing because it has not been declared in
  1410. :term:`DEPENDS`, or because the
  1411. dependency exists but the path used by the build process to find the
  1412. file is incorrect and the configure step did not detect it, the
  1413. compilation process could fail. For either of these failures, the
  1414. compilation process notes that files could not be found. In these
  1415. cases, you need to go back and add additional options to the
  1416. configure script as well as possibly add additional build-time
  1417. dependencies to ``DEPENDS``.
  1418. Occasionally, it is necessary to apply a patch to the source to
  1419. ensure the correct paths are used. If you need to specify paths to
  1420. find files staged into the sysroot from other recipes, use the
  1421. variables that the OpenEmbedded build system provides (e.g.
  1422. ``STAGING_BINDIR``, ``STAGING_INCDIR``, ``STAGING_DATADIR``, and so
  1423. forth).
  1424. Installing
  1425. ----------
  1426. During ``do_install``, the task copies the built files along with their
  1427. hierarchy to locations that would mirror their locations on the target
  1428. device. The installation process copies files from the
  1429. ``${``\ :term:`S`\ ``}``,
  1430. ``${``\ :term:`B`\ ``}``, and
  1431. ``${``\ :term:`WORKDIR`\ ``}``
  1432. directories to the ``${``\ :term:`D`\ ``}``
  1433. directory to create the structure as it should appear on the target
  1434. system.
  1435. How your software is built affects what you must do to be sure your
  1436. software is installed correctly. The following list describes what you
  1437. must do for installation depending on the type of build system used by
  1438. the software being built:
  1439. - *Autotools and CMake:* If the software your recipe is building uses
  1440. Autotools or CMake, the OpenEmbedded build system understands how to
  1441. install the software. Consequently, you do not have to have a
  1442. ``do_install`` task as part of your recipe. You just need to make
  1443. sure the install portion of the build completes with no issues.
  1444. However, if you wish to install additional files not already being
  1445. installed by ``make install``, you should do this using a
  1446. ``do_install_append`` function using the install command as described
  1447. in the "Manual" bulleted item later in this list.
  1448. - *Other (using* ``make install``\ *)*: You need to define a ``do_install``
  1449. function in your recipe. The function should call
  1450. ``oe_runmake install`` and will likely need to pass in the
  1451. destination directory as well. How you pass that path is dependent on
  1452. how the ``Makefile`` being run is written (e.g. ``DESTDIR=${D}``,
  1453. ``PREFIX=${D}``, ``INSTALLROOT=${D}``, and so forth).
  1454. For an example recipe using ``make install``, see the
  1455. ":ref:`dev-manual/common-tasks:makefile-based package`" section.
  1456. - *Manual:* You need to define a ``do_install`` function in your
  1457. recipe. The function must first use ``install -d`` to create the
  1458. directories under
  1459. ``${``\ :term:`D`\ ``}``. Once the
  1460. directories exist, your function can use ``install`` to manually
  1461. install the built software into the directories.
  1462. You can find more information on ``install`` at
  1463. https://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html.
  1464. For the scenarios that do not use Autotools or CMake, you need to track
  1465. the installation and diagnose and fix any issues until everything
  1466. installs correctly. You need to look in the default location of
  1467. ``${D}``, which is ``${WORKDIR}/image``, to be sure your files have been
  1468. installed correctly.
  1469. .. note::
  1470. - During the installation process, you might need to modify some of
  1471. the installed files to suit the target layout. For example, you
  1472. might need to replace hard-coded paths in an initscript with
  1473. values of variables provided by the build system, such as
  1474. replacing ``/usr/bin/`` with ``${bindir}``. If you do perform such
  1475. modifications during ``do_install``, be sure to modify the
  1476. destination file after copying rather than before copying.
  1477. Modifying after copying ensures that the build system can
  1478. re-execute ``do_install`` if needed.
  1479. - ``oe_runmake install``, which can be run directly or can be run
  1480. indirectly by the
  1481. :ref:`autotools <ref-classes-autotools>` and
  1482. :ref:`cmake <ref-classes-cmake>` classes,
  1483. runs ``make install`` in parallel. Sometimes, a Makefile can have
  1484. missing dependencies between targets that can result in race
  1485. conditions. If you experience intermittent failures during
  1486. ``do_install``, you might be able to work around them by disabling
  1487. parallel Makefile installs by adding the following to the recipe:
  1488. ::
  1489. PARALLEL_MAKEINST = ""
  1490. See :term:`PARALLEL_MAKEINST` for additional information.
  1491. - If you need to install one or more custom CMake toolchain files
  1492. that are supplied by the application you are building, install the
  1493. files to ``${D}${datadir}/cmake/Modules`` during
  1494. :ref:`ref-tasks-install`.
  1495. Enabling System Services
  1496. ------------------------
  1497. If you want to install a service, which is a process that usually starts
  1498. on boot and runs in the background, then you must include some
  1499. additional definitions in your recipe.
  1500. If you are adding services and the service initialization script or the
  1501. service file itself is not installed, you must provide for that
  1502. installation in your recipe using a ``do_install_append`` function. If
  1503. your recipe already has a ``do_install`` function, update the function
  1504. near its end rather than adding an additional ``do_install_append``
  1505. function.
  1506. When you create the installation for your services, you need to
  1507. accomplish what is normally done by ``make install``. In other words,
  1508. make sure your installation arranges the output similar to how it is
  1509. arranged on the target system.
  1510. The OpenEmbedded build system provides support for starting services two
  1511. different ways:
  1512. - *SysVinit:* SysVinit is a system and service manager that manages the
  1513. init system used to control the very basic functions of your system.
  1514. The init program is the first program started by the Linux kernel
  1515. when the system boots. Init then controls the startup, running and
  1516. shutdown of all other programs.
  1517. To enable a service using SysVinit, your recipe needs to inherit the
  1518. :ref:`update-rc.d <ref-classes-update-rc.d>`
  1519. class. The class helps facilitate safely installing the package on
  1520. the target.
  1521. You will need to set the
  1522. :term:`INITSCRIPT_PACKAGES`,
  1523. :term:`INITSCRIPT_NAME`,
  1524. and
  1525. :term:`INITSCRIPT_PARAMS`
  1526. variables within your recipe.
  1527. - *systemd:* System Management Daemon (systemd) was designed to replace
  1528. SysVinit and to provide enhanced management of services. For more
  1529. information on systemd, see the systemd homepage at
  1530. https://freedesktop.org/wiki/Software/systemd/.
  1531. To enable a service using systemd, your recipe needs to inherit the
  1532. :ref:`systemd <ref-classes-systemd>` class. See
  1533. the ``systemd.bbclass`` file located in your :term:`Source Directory`
  1534. section for
  1535. more information.
  1536. Packaging
  1537. ---------
  1538. Successful packaging is a combination of automated processes performed
  1539. by the OpenEmbedded build system and some specific steps you need to
  1540. take. The following list describes the process:
  1541. - *Splitting Files*: The ``do_package`` task splits the files produced
  1542. by the recipe into logical components. Even software that produces a
  1543. single binary might still have debug symbols, documentation, and
  1544. other logical components that should be split out. The ``do_package``
  1545. task ensures that files are split up and packaged correctly.
  1546. - *Running QA Checks*: The
  1547. :ref:`insane <ref-classes-insane>` class adds a
  1548. step to the package generation process so that output quality
  1549. assurance checks are generated by the OpenEmbedded build system. This
  1550. step performs a range of checks to be sure the build's output is free
  1551. of common problems that show up during runtime. For information on
  1552. these checks, see the
  1553. :ref:`insane <ref-classes-insane>` class and
  1554. the ":ref:`ref-manual/qa-checks:qa error and warning messages`"
  1555. chapter in the Yocto Project Reference Manual.
  1556. - *Hand-Checking Your Packages*: After you build your software, you
  1557. need to be sure your packages are correct. Examine the
  1558. ``${``\ :term:`WORKDIR`\ ``}/packages-split``
  1559. directory and make sure files are where you expect them to be. If you
  1560. discover problems, you can set
  1561. :term:`PACKAGES`,
  1562. :term:`FILES`,
  1563. ``do_install(_append)``, and so forth as needed.
  1564. - *Splitting an Application into Multiple Packages*: If you need to
  1565. split an application into several packages, see the
  1566. ":ref:`dev-manual/common-tasks:splitting an application into multiple packages`"
  1567. section for an example.
  1568. - *Installing a Post-Installation Script*: For an example showing how
  1569. to install a post-installation script, see the
  1570. ":ref:`dev-manual/common-tasks:post-installation scripts`" section.
  1571. - *Marking Package Architecture*: Depending on what your recipe is
  1572. building and how it is configured, it might be important to mark the
  1573. packages produced as being specific to a particular machine, or to
  1574. mark them as not being specific to a particular machine or
  1575. architecture at all.
  1576. By default, packages apply to any machine with the same architecture
  1577. as the target machine. When a recipe produces packages that are
  1578. machine-specific (e.g. the
  1579. :term:`MACHINE` value is passed
  1580. into the configure script or a patch is applied only for a particular
  1581. machine), you should mark them as such by adding the following to the
  1582. recipe:
  1583. ::
  1584. PACKAGE_ARCH = "${MACHINE_ARCH}"
  1585. On the other hand, if the recipe produces packages that do not
  1586. contain anything specific to the target machine or architecture at
  1587. all (e.g. recipes that simply package script files or configuration
  1588. files), you should use the
  1589. :ref:`allarch <ref-classes-allarch>` class to
  1590. do this for you by adding this to your recipe:
  1591. ::
  1592. inherit allarch
  1593. Ensuring that the package architecture is correct is not critical
  1594. while you are doing the first few builds of your recipe. However, it
  1595. is important in order to ensure that your recipe rebuilds (or does
  1596. not rebuild) appropriately in response to changes in configuration,
  1597. and to ensure that you get the appropriate packages installed on the
  1598. target machine, particularly if you run separate builds for more than
  1599. one target machine.
  1600. Sharing Files Between Recipes
  1601. -----------------------------
  1602. Recipes often need to use files provided by other recipes on the build
  1603. host. For example, an application linking to a common library needs
  1604. access to the library itself and its associated headers. The way this
  1605. access is accomplished is by populating a sysroot with files. Each
  1606. recipe has two sysroots in its work directory, one for target files
  1607. (``recipe-sysroot``) and one for files that are native to the build host
  1608. (``recipe-sysroot-native``).
  1609. .. note::
  1610. You could find the term "staging" used within the Yocto project
  1611. regarding files populating sysroots (e.g. the :term:`STAGING_DIR`
  1612. variable).
  1613. Recipes should never populate the sysroot directly (i.e. write files
  1614. into sysroot). Instead, files should be installed into standard
  1615. locations during the
  1616. :ref:`ref-tasks-install` task within
  1617. the ``${``\ :term:`D`\ ``}`` directory. The
  1618. reason for this limitation is that almost all files that populate the
  1619. sysroot are cataloged in manifests in order to ensure the files can be
  1620. removed later when a recipe is either modified or removed. Thus, the
  1621. sysroot is able to remain free from stale files.
  1622. A subset of the files installed by the :ref:`ref-tasks-install` task are
  1623. used by the :ref:`ref-tasks-populate_sysroot` task as defined by the the
  1624. :term:`SYSROOT_DIRS` variable to automatically populate the sysroot. It
  1625. is possible to modify the list of directories that populate the sysroot.
  1626. The following example shows how you could add the ``/opt`` directory to
  1627. the list of directories within a recipe:
  1628. ::
  1629. SYSROOT_DIRS += "/opt"
  1630. .. note::
  1631. The `/sysroot-only` is to be used by recipes that generate artifacts
  1632. that are not included in the target filesystem, allowing them to share
  1633. these artifacts without needing to use the ``DEPLOY_DIR``.
  1634. For a more complete description of the :ref:`ref-tasks-populate_sysroot`
  1635. task and its associated functions, see the
  1636. :ref:`staging <ref-classes-staging>` class.
  1637. Using Virtual Providers
  1638. -----------------------
  1639. Prior to a build, if you know that several different recipes provide the
  1640. same functionality, you can use a virtual provider (i.e. ``virtual/*``)
  1641. as a placeholder for the actual provider. The actual provider is
  1642. determined at build-time.
  1643. A common scenario where a virtual provider is used would be for the
  1644. kernel recipe. Suppose you have three kernel recipes whose
  1645. :term:`PN` values map to ``kernel-big``,
  1646. ``kernel-mid``, and ``kernel-small``. Furthermore, each of these recipes
  1647. in some way uses a :term:`PROVIDES`
  1648. statement that essentially identifies itself as being able to provide
  1649. ``virtual/kernel``. Here is one way through the
  1650. :ref:`kernel <ref-classes-kernel>` class:
  1651. ::
  1652. PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }"
  1653. Any recipe that inherits the ``kernel`` class is
  1654. going to utilize a ``PROVIDES`` statement that identifies that recipe as
  1655. being able to provide the ``virtual/kernel`` item.
  1656. Now comes the time to actually build an image and you need a kernel
  1657. recipe, but which one? You can configure your build to call out the
  1658. kernel recipe you want by using the :term:`PREFERRED_PROVIDER` variable. As
  1659. an example, consider the :yocto_git:`x86-base.inc
  1660. </poky/tree/meta/conf/machine/include/x86-base.inc>` include file, which is a
  1661. machine (i.e. :term:`MACHINE`) configuration file. This include file is the
  1662. reason all x86-based machines use the ``linux-yocto`` kernel. Here are the
  1663. relevant lines from the include file:
  1664. ::
  1665. PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto"
  1666. PREFERRED_VERSION_linux-yocto ??= "4.15%"
  1667. When you use a virtual provider, you do not have to "hard code" a recipe
  1668. name as a build dependency. You can use the
  1669. :term:`DEPENDS` variable to state the
  1670. build is dependent on ``virtual/kernel`` for example:
  1671. ::
  1672. DEPENDS = "virtual/kernel"
  1673. During the build, the OpenEmbedded build system picks
  1674. the correct recipe needed for the ``virtual/kernel`` dependency based on
  1675. the ``PREFERRED_PROVIDER`` variable. If you want to use the small kernel
  1676. mentioned at the beginning of this section, configure your build as
  1677. follows:
  1678. ::
  1679. PREFERRED_PROVIDER_virtual/kernel ??= "kernel-small"
  1680. .. note::
  1681. Any recipe that ``PROVIDES`` a ``virtual/*`` item that is ultimately not
  1682. selected through ``PREFERRED_PROVIDER`` does not get built. Preventing these
  1683. recipes from building is usually the desired behavior since this mechanism's
  1684. purpose is to select between mutually exclusive alternative providers.
  1685. The following lists specific examples of virtual providers:
  1686. - ``virtual/kernel``: Provides the name of the kernel recipe to use
  1687. when building a kernel image.
  1688. - ``virtual/bootloader``: Provides the name of the bootloader to use
  1689. when building an image.
  1690. - ``virtual/libgbm``: Provides ``gbm.pc``.
  1691. - ``virtual/egl``: Provides ``egl.pc`` and possibly ``wayland-egl.pc``.
  1692. - ``virtual/libgl``: Provides ``gl.pc`` (i.e. libGL).
  1693. - ``virtual/libgles1``: Provides ``glesv1_cm.pc`` (i.e. libGLESv1_CM).
  1694. - ``virtual/libgles2``: Provides ``glesv2.pc`` (i.e. libGLESv2).
  1695. .. note::
  1696. Virtual providers only apply to build time dependencies specified with
  1697. :term:`PROVIDES` and :term:`DEPENDS`. They do not apply to runtime
  1698. dependencies specified with :term:`RPROVIDES` and :term:`RDEPENDS`.
  1699. Properly Versioning Pre-Release Recipes
  1700. ---------------------------------------
  1701. Sometimes the name of a recipe can lead to versioning problems when the
  1702. recipe is upgraded to a final release. For example, consider the
  1703. ``irssi_0.8.16-rc1.bb`` recipe file in the list of example recipes in
  1704. the ":ref:`dev-manual/common-tasks:storing and naming the recipe`" section.
  1705. This recipe is at a release candidate stage (i.e. "rc1"). When the recipe is
  1706. released, the recipe filename becomes ``irssi_0.8.16.bb``. The version
  1707. change from ``0.8.16-rc1`` to ``0.8.16`` is seen as a decrease by the
  1708. build system and package managers, so the resulting packages will not
  1709. correctly trigger an upgrade.
  1710. In order to ensure the versions compare properly, the recommended
  1711. convention is to set :term:`PV` within the
  1712. recipe to "previous_version+current_version". You can use an additional
  1713. variable so that you can use the current version elsewhere. Here is an
  1714. example:
  1715. ::
  1716. REALPV = "0.8.16-rc1"
  1717. PV = "0.8.15+${REALPV}"
  1718. Post-Installation Scripts
  1719. -------------------------
  1720. Post-installation scripts run immediately after installing a package on
  1721. the target or during image creation when a package is included in an
  1722. image. To add a post-installation script to a package, add a
  1723. ``pkg_postinst_``\ `PACKAGENAME`\ ``()`` function to the recipe file
  1724. (``.bb``) and replace `PACKAGENAME` with the name of the package you want
  1725. to attach to the ``postinst`` script. To apply the post-installation
  1726. script to the main package for the recipe, which is usually what is
  1727. required, specify
  1728. ``${``\ :term:`PN`\ ``}`` in place of
  1729. PACKAGENAME.
  1730. A post-installation function has the following structure:
  1731. ::
  1732. pkg_postinst_PACKAGENAME() {
  1733. # Commands to carry out
  1734. }
  1735. The script defined in the post-installation function is called when the
  1736. root filesystem is created. If the script succeeds, the package is
  1737. marked as installed.
  1738. .. note::
  1739. Any RPM post-installation script that runs on the target should
  1740. return a 0 exit code. RPM does not allow non-zero exit codes for
  1741. these scripts, and the RPM package manager will cause the package to
  1742. fail installation on the target.
  1743. Sometimes it is necessary for the execution of a post-installation
  1744. script to be delayed until the first boot. For example, the script might
  1745. need to be executed on the device itself. To delay script execution
  1746. until boot time, you must explicitly mark post installs to defer to the
  1747. target. You can use ``pkg_postinst_ontarget()`` or call
  1748. ``postinst_intercept delay_to_first_boot`` from ``pkg_postinst()``. Any
  1749. failure of a ``pkg_postinst()`` script (including exit 1) triggers an
  1750. error during the
  1751. :ref:`ref-tasks-rootfs` task.
  1752. If you have recipes that use ``pkg_postinst`` function and they require
  1753. the use of non-standard native tools that have dependencies during
  1754. rootfs construction, you need to use the
  1755. :term:`PACKAGE_WRITE_DEPS`
  1756. variable in your recipe to list these tools. If you do not use this
  1757. variable, the tools might be missing and execution of the
  1758. post-installation script is deferred until first boot. Deferring the
  1759. script to first boot is undesirable and for read-only rootfs impossible.
  1760. .. note::
  1761. Equivalent support for pre-install, pre-uninstall, and post-uninstall
  1762. scripts exist by way of ``pkg_preinst``, ``pkg_prerm``, and ``pkg_postrm``,
  1763. respectively. These scrips work in exactly the same way as does
  1764. ``pkg_postinst`` with the exception that they run at different times. Also,
  1765. because of when they run, they are not applicable to being run at image
  1766. creation time like ``pkg_postinst``.
  1767. Testing
  1768. -------
  1769. The final step for completing your recipe is to be sure that the
  1770. software you built runs correctly. To accomplish runtime testing, add
  1771. the build's output packages to your image and test them on the target.
  1772. For information on how to customize your image by adding specific
  1773. packages, see ":ref:`dev-manual/common-tasks:customizing images`" section.
  1774. Examples
  1775. --------
  1776. To help summarize how to write a recipe, this section provides some
  1777. examples given various scenarios:
  1778. - Recipes that use local files
  1779. - Using an Autotooled package
  1780. - Using a Makefile-based package
  1781. - Splitting an application into multiple packages
  1782. - Adding binaries to an image
  1783. Single .c File Package (Hello World!)
  1784. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1785. Building an application from a single file that is stored locally (e.g.
  1786. under ``files``) requires a recipe that has the file listed in the
  1787. ``SRC_URI`` variable. Additionally, you need to manually write the
  1788. ``do_compile`` and ``do_install`` tasks. The ``S`` variable defines the
  1789. directory containing the source code, which is set to
  1790. :term:`WORKDIR` in this case - the
  1791. directory BitBake uses for the build.
  1792. ::
  1793. SUMMARY = "Simple helloworld application"
  1794. SECTION = "examples"
  1795. LICENSE = "MIT"
  1796. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  1797. SRC_URI = "file://helloworld.c"
  1798. S = "${WORKDIR}"
  1799. do_compile() {
  1800. ${CC} ${LDFLAGS} helloworld.c -o helloworld
  1801. }
  1802. do_install() {
  1803. install -d ${D}${bindir}
  1804. install -m 0755 helloworld ${D}${bindir}
  1805. }
  1806. By default, the ``helloworld``, ``helloworld-dbg``, and
  1807. ``helloworld-dev`` packages are built. For information on how to
  1808. customize the packaging process, see the
  1809. ":ref:`dev-manual/common-tasks:splitting an application into multiple packages`"
  1810. section.
  1811. Autotooled Package
  1812. ~~~~~~~~~~~~~~~~~~
  1813. Applications that use Autotools such as ``autoconf`` and ``automake``
  1814. require a recipe that has a source archive listed in ``SRC_URI`` and
  1815. also inherit the
  1816. :ref:`autotools <ref-classes-autotools>` class,
  1817. which contains the definitions of all the steps needed to build an
  1818. Autotool-based application. The result of the build is automatically
  1819. packaged. And, if the application uses NLS for localization, packages
  1820. with local information are generated (one package per language).
  1821. Following is one example: (``hello_2.3.bb``)
  1822. ::
  1823. SUMMARY = "GNU Helloworld application"
  1824. SECTION = "examples"
  1825. LICENSE = "GPLv2+"
  1826. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  1827. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  1828. inherit autotools gettext
  1829. The variable ``LIC_FILES_CHKSUM`` is used to track source license
  1830. changes as described in the
  1831. ":ref:`dev-manual/common-tasks:tracking license changes`" section in
  1832. the Yocto Project Overview and Concepts Manual. You can quickly create
  1833. Autotool-based recipes in a manner similar to the previous example.
  1834. Makefile-Based Package
  1835. ~~~~~~~~~~~~~~~~~~~~~~
  1836. Applications that use GNU ``make`` also require a recipe that has the
  1837. source archive listed in ``SRC_URI``. You do not need to add a
  1838. ``do_compile`` step since by default BitBake starts the ``make`` command
  1839. to compile the application. If you need additional ``make`` options, you
  1840. should store them in the
  1841. :term:`EXTRA_OEMAKE` or
  1842. :term:`PACKAGECONFIG_CONFARGS`
  1843. variables. BitBake passes these options into the GNU ``make``
  1844. invocation. Note that a ``do_install`` task is still required.
  1845. Otherwise, BitBake runs an empty ``do_install`` task by default.
  1846. Some applications might require extra parameters to be passed to the
  1847. compiler. For example, the application might need an additional header
  1848. path. You can accomplish this by adding to the ``CFLAGS`` variable. The
  1849. following example shows this:
  1850. ::
  1851. CFLAGS_prepend = "-I ${S}/include "
  1852. In the following example, ``mtd-utils`` is a makefile-based package:
  1853. ::
  1854. SUMMARY = "Tools for managing memory technology devices"
  1855. SECTION = "base"
  1856. DEPENDS = "zlib lzo e2fsprogs util-linux"
  1857. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  1858. LICENSE = "GPLv2+"
  1859. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  1860. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  1861. # Use the latest version at 26 Oct, 2013
  1862. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  1863. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  1864. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  1865. "
  1866. PV = "1.5.1+git${SRCPV}"
  1867. S = "${WORKDIR}/git"
  1868. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  1869. do_install () {
  1870. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  1871. }
  1872. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  1873. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  1874. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  1875. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  1876. PARALLEL_MAKE = ""
  1877. BBCLASSEXTEND = "native"
  1878. Splitting an Application into Multiple Packages
  1879. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1880. You can use the variables ``PACKAGES`` and ``FILES`` to split an
  1881. application into multiple packages.
  1882. Following is an example that uses the ``libxpm`` recipe. By default,
  1883. this recipe generates a single package that contains the library along
  1884. with a few binaries. You can modify the recipe to split the binaries
  1885. into separate packages:
  1886. ::
  1887. require xorg-lib-common.inc
  1888. SUMMARY = "Xpm: X Pixmap extension library"
  1889. LICENSE = "BSD"
  1890. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  1891. DEPENDS += "libxext libsm libxt"
  1892. PE = "1"
  1893. XORG_PN = "libXpm"
  1894. PACKAGES =+ "sxpm cxpm"
  1895. FILES_cxpm = "${bindir}/cxpm"
  1896. FILES_sxpm = "${bindir}/sxpm"
  1897. In the previous example, we want to ship the ``sxpm`` and ``cxpm``
  1898. binaries in separate packages. Since ``bindir`` would be packaged into
  1899. the main ``PN`` package by default, we prepend the ``PACKAGES`` variable
  1900. so additional package names are added to the start of list. This results
  1901. in the extra ``FILES_*`` variables then containing information that
  1902. define which files and directories go into which packages. Files
  1903. included by earlier packages are skipped by latter packages. Thus, the
  1904. main ``PN`` package does not include the above listed files.
  1905. Packaging Externally Produced Binaries
  1906. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1907. Sometimes, you need to add pre-compiled binaries to an image. For
  1908. example, suppose that binaries for proprietary code exist, which are
  1909. created by a particular division of a company. Your part of the company
  1910. needs to use those binaries as part of an image that you are building
  1911. using the OpenEmbedded build system. Since you only have the binaries
  1912. and not the source code, you cannot use a typical recipe that expects to
  1913. fetch the source specified in
  1914. :term:`SRC_URI` and then compile it.
  1915. One method is to package the binaries and then install them as part of
  1916. the image. Generally, it is not a good idea to package binaries since,
  1917. among other things, it can hinder the ability to reproduce builds and
  1918. could lead to compatibility problems with ABI in the future. However,
  1919. sometimes you have no choice.
  1920. The easiest solution is to create a recipe that uses the
  1921. :ref:`bin_package <ref-classes-bin-package>` class
  1922. and to be sure that you are using default locations for build artifacts.
  1923. In most cases, the ``bin_package`` class handles "skipping" the
  1924. configure and compile steps as well as sets things up to grab packages
  1925. from the appropriate area. In particular, this class sets ``noexec`` on
  1926. both the :ref:`ref-tasks-configure`
  1927. and :ref:`ref-tasks-compile` tasks,
  1928. sets ``FILES_${PN}`` to "/" so that it picks up all files, and sets up a
  1929. :ref:`ref-tasks-install` task, which
  1930. effectively copies all files from ``${S}`` to ``${D}``. The
  1931. ``bin_package`` class works well when the files extracted into ``${S}``
  1932. are already laid out in the way they should be laid out on the target.
  1933. For more information on these variables, see the
  1934. :term:`FILES`,
  1935. :term:`PN`,
  1936. :term:`S`, and
  1937. :term:`D` variables in the Yocto Project
  1938. Reference Manual's variable glossary.
  1939. .. note::
  1940. - Using :term:`DEPENDS` is a good
  1941. idea even for components distributed in binary form, and is often
  1942. necessary for shared libraries. For a shared library, listing the
  1943. library dependencies in ``DEPENDS`` makes sure that the libraries
  1944. are available in the staging sysroot when other recipes link
  1945. against the library, which might be necessary for successful
  1946. linking.
  1947. - Using ``DEPENDS`` also allows runtime dependencies between
  1948. packages to be added automatically. See the
  1949. ":ref:`overview-manual/concepts:automatically added runtime dependencies`"
  1950. section in the Yocto Project Overview and Concepts Manual for more
  1951. information.
  1952. If you cannot use the ``bin_package`` class, you need to be sure you are
  1953. doing the following:
  1954. - Create a recipe where the
  1955. :ref:`ref-tasks-configure` and
  1956. :ref:`ref-tasks-compile` tasks do
  1957. nothing: It is usually sufficient to just not define these tasks in
  1958. the recipe, because the default implementations do nothing unless a
  1959. Makefile is found in
  1960. ``${``\ :term:`S`\ ``}``.
  1961. If ``${S}`` might contain a Makefile, or if you inherit some class
  1962. that replaces ``do_configure`` and ``do_compile`` with custom
  1963. versions, then you can use the
  1964. ``[``\ :ref:`noexec <bitbake-user-manual/bitbake-user-manual-metadata:variable flags>`\ ``]``
  1965. flag to turn the tasks into no-ops, as follows:
  1966. ::
  1967. do_configure[noexec] = "1"
  1968. do_compile[noexec] = "1"
  1969. Unlike
  1970. :ref:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata:deleting a task`,
  1971. using the flag preserves the dependency chain from the
  1972. :ref:`ref-tasks-fetch`,
  1973. :ref:`ref-tasks-unpack`, and
  1974. :ref:`ref-tasks-patch` tasks to the
  1975. :ref:`ref-tasks-install` task.
  1976. - Make sure your ``do_install`` task installs the binaries
  1977. appropriately.
  1978. - Ensure that you set up :term:`FILES`
  1979. (usually
  1980. ``FILES_${``\ :term:`PN`\ ``}``) to
  1981. point to the files you have installed, which of course depends on
  1982. where you have installed them and whether those files are in
  1983. different locations than the defaults.
  1984. .. note::
  1985. If image prelinking is enabled (e.g. "image-prelink" is in :term:`USER_CLASSES`
  1986. which it is by default), prelink will change the binaries in the generated images
  1987. and this often catches people out. Remove that class to ensure binaries are
  1988. preserved exactly if that is necessary.
  1989. Following Recipe Style Guidelines
  1990. ---------------------------------
  1991. When writing recipes, it is good to conform to existing style
  1992. guidelines. The :oe_wiki:`OpenEmbedded Styleguide </Styleguide>` wiki page
  1993. provides rough guidelines for preferred recipe style.
  1994. It is common for existing recipes to deviate a bit from this style.
  1995. However, aiming for at least a consistent style is a good idea. Some
  1996. practices, such as omitting spaces around ``=`` operators in assignments
  1997. or ordering recipe components in an erratic way, are widely seen as poor
  1998. style.
  1999. Recipe Syntax
  2000. -------------
  2001. Understanding recipe file syntax is important for writing recipes. The
  2002. following list overviews the basic items that make up a BitBake recipe
  2003. file. For more complete BitBake syntax descriptions, see the
  2004. ":doc:`bitbake-user-manual/bitbake-user-manual-metadata`"
  2005. chapter of the BitBake User Manual.
  2006. - *Variable Assignments and Manipulations:* Variable assignments allow
  2007. a value to be assigned to a variable. The assignment can be static
  2008. text or might include the contents of other variables. In addition to
  2009. the assignment, appending and prepending operations are also
  2010. supported.
  2011. The following example shows some of the ways you can use variables in
  2012. recipes:
  2013. ::
  2014. S = "${WORKDIR}/postfix-${PV}"
  2015. CFLAGS += "-DNO_ASM"
  2016. SRC_URI_append = " file://fixup.patch"
  2017. - *Functions:* Functions provide a series of actions to be performed.
  2018. You usually use functions to override the default implementation of a
  2019. task function or to complement a default function (i.e. append or
  2020. prepend to an existing function). Standard functions use ``sh`` shell
  2021. syntax, although access to OpenEmbedded variables and internal
  2022. methods are also available.
  2023. The following is an example function from the ``sed`` recipe:
  2024. ::
  2025. do_install () {
  2026. autotools_do_install
  2027. install -d ${D}${base_bindir}
  2028. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  2029. rmdir ${D}${bindir}/
  2030. }
  2031. It is
  2032. also possible to implement new functions that are called between
  2033. existing tasks as long as the new functions are not replacing or
  2034. complementing the default functions. You can implement functions in
  2035. Python instead of shell. Both of these options are not seen in the
  2036. majority of recipes.
  2037. - *Keywords:* BitBake recipes use only a few keywords. You use keywords
  2038. to include common functions (``inherit``), load parts of a recipe
  2039. from other files (``include`` and ``require``) and export variables
  2040. to the environment (``export``).
  2041. The following example shows the use of some of these keywords:
  2042. ::
  2043. export POSTCONF = "${STAGING_BINDIR}/postconf"
  2044. inherit autoconf
  2045. require otherfile.inc
  2046. - *Comments (#):* Any lines that begin with the hash character (``#``)
  2047. are treated as comment lines and are ignored:
  2048. ::
  2049. # This is a comment
  2050. This next list summarizes the most important and most commonly used
  2051. parts of the recipe syntax. For more information on these parts of the
  2052. syntax, you can reference the
  2053. :doc:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata` chapter
  2054. in the BitBake User Manual.
  2055. - *Line Continuation (\\):* Use the backward slash (``\``) character to
  2056. split a statement over multiple lines. Place the slash character at
  2057. the end of the line that is to be continued on the next line:
  2058. ::
  2059. VAR = "A really long \
  2060. line"
  2061. .. note::
  2062. You cannot have any characters including spaces or tabs after the
  2063. slash character.
  2064. - *Using Variables (${VARNAME}):* Use the ``${VARNAME}`` syntax to
  2065. access the contents of a variable:
  2066. ::
  2067. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  2068. .. note::
  2069. It is important to understand that the value of a variable
  2070. expressed in this form does not get substituted automatically. The
  2071. expansion of these expressions happens on-demand later (e.g.
  2072. usually when a function that makes reference to the variable
  2073. executes). This behavior ensures that the values are most
  2074. appropriate for the context in which they are finally used. On the
  2075. rare occasion that you do need the variable expression to be
  2076. expanded immediately, you can use the
  2077. :=
  2078. operator instead of
  2079. =
  2080. when you make the assignment, but this is not generally needed.
  2081. - *Quote All Assignments ("value"):* Use double quotes around values in
  2082. all variable assignments (e.g. ``"value"``). Following is an example:
  2083. ::
  2084. VAR1 = "${OTHERVAR}"
  2085. VAR2 = "The version is ${PV}"
  2086. - *Conditional Assignment (?=):* Conditional assignment is used to
  2087. assign a value to a variable, but only when the variable is currently
  2088. unset. Use the question mark followed by the equal sign (``?=``) to
  2089. make a "soft" assignment used for conditional assignment. Typically,
  2090. "soft" assignments are used in the ``local.conf`` file for variables
  2091. that are allowed to come through from the external environment.
  2092. Here is an example where ``VAR1`` is set to "New value" if it is
  2093. currently empty. However, if ``VAR1`` has already been set, it
  2094. remains unchanged:
  2095. ::
  2096. VAR1 ?= "New value"
  2097. In this next example, ``VAR1`` is left with the value "Original value":
  2098. ::
  2099. VAR1 = "Original value"
  2100. VAR1 ?= "New value"
  2101. - *Appending (+=):* Use the plus character followed by the equals sign
  2102. (``+=``) to append values to existing variables.
  2103. .. note::
  2104. This operator adds a space between the existing content of the
  2105. variable and the new content.
  2106. Here is an example:
  2107. ::
  2108. SRC_URI += "file://fix-makefile.patch"
  2109. - *Prepending (=+):* Use the equals sign followed by the plus character
  2110. (``=+``) to prepend values to existing variables.
  2111. .. note::
  2112. This operator adds a space between the new content and the
  2113. existing content of the variable.
  2114. Here is an example:
  2115. ::
  2116. VAR =+ "Starts"
  2117. - *Appending (_append):* Use the ``_append`` operator to append values
  2118. to existing variables. This operator does not add any additional
  2119. space. Also, the operator is applied after all the ``+=``, and ``=+``
  2120. operators have been applied and after all ``=`` assignments have
  2121. occurred.
  2122. The following example shows the space being explicitly added to the
  2123. start to ensure the appended value is not merged with the existing
  2124. value:
  2125. ::
  2126. SRC_URI_append = " file://fix-makefile.patch"
  2127. You can also use
  2128. the ``_append`` operator with overrides, which results in the actions
  2129. only being performed for the specified target or machine:
  2130. ::
  2131. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  2132. - *Prepending (_prepend):* Use the ``_prepend`` operator to prepend
  2133. values to existing variables. This operator does not add any
  2134. additional space. Also, the operator is applied after all the ``+=``,
  2135. and ``=+`` operators have been applied and after all ``=``
  2136. assignments have occurred.
  2137. The following example shows the space being explicitly added to the
  2138. end to ensure the prepended value is not merged with the existing
  2139. value:
  2140. ::
  2141. CFLAGS_prepend = "-I${S}/myincludes "
  2142. You can also use the
  2143. ``_prepend`` operator with overrides, which results in the actions
  2144. only being performed for the specified target or machine:
  2145. ::
  2146. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  2147. - *Overrides:* You can use overrides to set a value conditionally,
  2148. typically based on how the recipe is being built. For example, to set
  2149. the :term:`KBRANCH` variable's
  2150. value to "standard/base" for any target
  2151. :term:`MACHINE`, except for
  2152. qemuarm where it should be set to "standard/arm-versatile-926ejs",
  2153. you would do the following:
  2154. ::
  2155. KBRANCH = "standard/base"
  2156. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  2157. Overrides are also used to separate
  2158. alternate values of a variable in other situations. For example, when
  2159. setting variables such as
  2160. :term:`FILES` and
  2161. :term:`RDEPENDS` that are
  2162. specific to individual packages produced by a recipe, you should
  2163. always use an override that specifies the name of the package.
  2164. - *Indentation:* Use spaces for indentation rather than tabs. For
  2165. shell functions, both currently work. However, it is a policy
  2166. decision of the Yocto Project to use tabs in shell functions. Realize
  2167. that some layers have a policy to use spaces for all indentation.
  2168. - *Using Python for Complex Operations:* For more advanced processing,
  2169. it is possible to use Python code during variable assignments (e.g.
  2170. search and replacement on a variable).
  2171. You indicate Python code using the ``${@python_code}`` syntax for the
  2172. variable assignment:
  2173. ::
  2174. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  2175. - *Shell Function Syntax:* Write shell functions as if you were writing
  2176. a shell script when you describe a list of actions to take. You
  2177. should ensure that your script works with a generic ``sh`` and that
  2178. it does not require any ``bash`` or other shell-specific
  2179. functionality. The same considerations apply to various system
  2180. utilities (e.g. ``sed``, ``grep``, ``awk``, and so forth) that you
  2181. might wish to use. If in doubt, you should check with multiple
  2182. implementations - including those from BusyBox.
  2183. Adding a New Machine
  2184. ====================
  2185. Adding a new machine to the Yocto Project is a straightforward process.
  2186. This section describes how to add machines that are similar to those
  2187. that the Yocto Project already supports.
  2188. .. note::
  2189. Although well within the capabilities of the Yocto Project, adding a
  2190. totally new architecture might require changes to ``gcc``/``glibc``
  2191. and to the site information, which is beyond the scope of this
  2192. manual.
  2193. For a complete example that shows how to add a new machine, see the
  2194. ":ref:`bsp-guide/bsp:creating a new bsp layer using the \`\`bitbake-layers\`\` script`"
  2195. section in the Yocto Project Board Support Package (BSP) Developer's
  2196. Guide.
  2197. Adding the Machine Configuration File
  2198. -------------------------------------
  2199. To add a new machine, you need to add a new machine configuration file
  2200. to the layer's ``conf/machine`` directory. This configuration file
  2201. provides details about the device you are adding.
  2202. The OpenEmbedded build system uses the root name of the machine
  2203. configuration file to reference the new machine. For example, given a
  2204. machine configuration file named ``crownbay.conf``, the build system
  2205. recognizes the machine as "crownbay".
  2206. The most important variables you must set in your machine configuration
  2207. file or include from a lower-level configuration file are as follows:
  2208. - ``TARGET_ARCH`` (e.g. "arm")
  2209. - ``PREFERRED_PROVIDER_virtual/kernel``
  2210. - ``MACHINE_FEATURES`` (e.g. "apm screen wifi")
  2211. You might also need these variables:
  2212. - ``SERIAL_CONSOLES`` (e.g. "115200;ttyS0 115200;ttyS1")
  2213. - ``KERNEL_IMAGETYPE`` (e.g. "zImage")
  2214. - ``IMAGE_FSTYPES`` (e.g. "tar.gz jffs2")
  2215. You can find full details on these variables in the reference section.
  2216. You can leverage existing machine ``.conf`` files from
  2217. ``meta-yocto-bsp/conf/machine/``.
  2218. Adding a Kernel for the Machine
  2219. -------------------------------
  2220. The OpenEmbedded build system needs to be able to build a kernel for the
  2221. machine. You need to either create a new kernel recipe for this machine,
  2222. or extend an existing kernel recipe. You can find several kernel recipe
  2223. examples in the Source Directory at ``meta/recipes-kernel/linux`` that
  2224. you can use as references.
  2225. If you are creating a new kernel recipe, normal recipe-writing rules
  2226. apply for setting up a ``SRC_URI``. Thus, you need to specify any
  2227. necessary patches and set ``S`` to point at the source code. You need to
  2228. create a ``do_configure`` task that configures the unpacked kernel with
  2229. a ``defconfig`` file. You can do this by using a ``make defconfig``
  2230. command or, more commonly, by copying in a suitable ``defconfig`` file
  2231. and then running ``make oldconfig``. By making use of ``inherit kernel``
  2232. and potentially some of the ``linux-*.inc`` files, most other
  2233. functionality is centralized and the defaults of the class normally work
  2234. well.
  2235. If you are extending an existing kernel recipe, it is usually a matter
  2236. of adding a suitable ``defconfig`` file. The file needs to be added into
  2237. a location similar to ``defconfig`` files used for other machines in a
  2238. given kernel recipe. A possible way to do this is by listing the file in
  2239. the ``SRC_URI`` and adding the machine to the expression in
  2240. ``COMPATIBLE_MACHINE``:
  2241. ::
  2242. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  2243. For more information on ``defconfig`` files, see the
  2244. ":ref:`kernel-dev/common:changing the configuration`"
  2245. section in the Yocto Project Linux Kernel Development Manual.
  2246. Adding a Formfactor Configuration File
  2247. --------------------------------------
  2248. A formfactor configuration file provides information about the target
  2249. hardware for which the image is being built and information that the
  2250. build system cannot obtain from other sources such as the kernel. Some
  2251. examples of information contained in a formfactor configuration file
  2252. include framebuffer orientation, whether or not the system has a
  2253. keyboard, the positioning of the keyboard in relation to the screen, and
  2254. the screen resolution.
  2255. The build system uses reasonable defaults in most cases. However, if
  2256. customization is necessary, you need to create a ``machconfig`` file in
  2257. the ``meta/recipes-bsp/formfactor/files`` directory. This directory
  2258. contains directories for specific machines such as ``qemuarm`` and
  2259. ``qemux86``. For information about the settings available and the
  2260. defaults, see the ``meta/recipes-bsp/formfactor/files/config`` file
  2261. found in the same area.
  2262. Following is an example for "qemuarm" machine:
  2263. ::
  2264. HAVE_TOUCHSCREEN=1
  2265. HAVE_KEYBOARD=1
  2266. DISPLAY_CAN_ROTATE=0
  2267. DISPLAY_ORIENTATION=0
  2268. #DISPLAY_WIDTH_PIXELS=640
  2269. #DISPLAY_HEIGHT_PIXELS=480
  2270. #DISPLAY_BPP=16
  2271. DISPLAY_DPI=150
  2272. DISPLAY_SUBPIXEL_ORDER=vrgb
  2273. Upgrading Recipes
  2274. =================
  2275. Over time, upstream developers publish new versions for software built
  2276. by layer recipes. It is recommended to keep recipes up-to-date with
  2277. upstream version releases.
  2278. While several methods exist that allow you upgrade a recipe, you might
  2279. consider checking on the upgrade status of a recipe first. You can do so
  2280. using the ``devtool check-upgrade-status`` command. See the
  2281. ":ref:`devtool-checking-on-the-upgrade-status-of-a-recipe`"
  2282. section in the Yocto Project Reference Manual for more information.
  2283. The remainder of this section describes three ways you can upgrade a
  2284. recipe. You can use the Automated Upgrade Helper (AUH) to set up
  2285. automatic version upgrades. Alternatively, you can use
  2286. ``devtool upgrade`` to set up semi-automatic version upgrades. Finally,
  2287. you can manually upgrade a recipe by editing the recipe itself.
  2288. Using the Auto Upgrade Helper (AUH)
  2289. -----------------------------------
  2290. The AUH utility works in conjunction with the OpenEmbedded build system
  2291. in order to automatically generate upgrades for recipes based on new
  2292. versions being published upstream. Use AUH when you want to create a
  2293. service that performs the upgrades automatically and optionally sends
  2294. you an email with the results.
  2295. AUH allows you to update several recipes with a single use. You can also
  2296. optionally perform build and integration tests using images with the
  2297. results saved to your hard drive and emails of results optionally sent
  2298. to recipe maintainers. Finally, AUH creates Git commits with appropriate
  2299. commit messages in the layer's tree for the changes made to recipes.
  2300. .. note::
  2301. Conditions do exist when you should not use AUH to upgrade recipes
  2302. and you should instead use either ``devtool upgrade`` or upgrade your
  2303. recipes manually:
  2304. - When AUH cannot complete the upgrade sequence. This situation
  2305. usually results because custom patches carried by the recipe
  2306. cannot be automatically rebased to the new version. In this case,
  2307. ``devtool upgrade`` allows you to manually resolve conflicts.
  2308. - When for any reason you want fuller control over the upgrade
  2309. process. For example, when you want special arrangements for
  2310. testing.
  2311. The following steps describe how to set up the AUH utility:
  2312. 1. *Be Sure the Development Host is Set Up:* You need to be sure that
  2313. your development host is set up to use the Yocto Project. For
  2314. information on how to set up your host, see the
  2315. ":ref:`dev-manual/start:Preparing the Build Host`" section.
  2316. 2. *Make Sure Git is Configured:* The AUH utility requires Git to be
  2317. configured because AUH uses Git to save upgrades. Thus, you must have
  2318. Git user and email configured. The following command shows your
  2319. configurations:
  2320. ::
  2321. $ git config --list
  2322. If you do not have the user and
  2323. email configured, you can use the following commands to do so:
  2324. ::
  2325. $ git config --global user.name some_name
  2326. $ git config --global user.email username@domain.com
  2327. 3. *Clone the AUH Repository:* To use AUH, you must clone the repository
  2328. onto your development host. The following command uses Git to create
  2329. a local copy of the repository on your system:
  2330. ::
  2331. $ git clone git://git.yoctoproject.org/auto-upgrade-helper
  2332. Cloning into 'auto-upgrade-helper'... remote: Counting objects: 768, done.
  2333. remote: Compressing objects: 100% (300/300), done.
  2334. remote: Total 768 (delta 499), reused 703 (delta 434)
  2335. Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done.
  2336. Resolving deltas: 100% (499/499), done.
  2337. Checking connectivity... done.
  2338. AUH is not part of the :term:`OpenEmbedded-Core (OE-Core)` or
  2339. :term:`Poky` repositories.
  2340. 4. *Create a Dedicated Build Directory:* Run the
  2341. :ref:`structure-core-script`
  2342. script to create a fresh build directory that you use exclusively for
  2343. running the AUH utility:
  2344. ::
  2345. $ cd poky
  2346. $ source oe-init-build-env your_AUH_build_directory
  2347. Re-using an existing build directory and its configurations is not
  2348. recommended as existing settings could cause AUH to fail or behave
  2349. undesirably.
  2350. 5. *Make Configurations in Your Local Configuration File:* Several
  2351. settings need to exist in the ``local.conf`` file in the build
  2352. directory you just created for AUH. Make these following
  2353. configurations:
  2354. - If you want to enable :ref:`Build
  2355. History <dev-manual/common-tasks:maintaining build output quality>`,
  2356. which is optional, you need the following lines in the
  2357. ``conf/local.conf`` file:
  2358. ::
  2359. INHERIT =+ "buildhistory"
  2360. BUILDHISTORY_COMMIT = "1"
  2361. With this configuration and a successful
  2362. upgrade, a build history "diff" file appears in the
  2363. ``upgrade-helper/work/recipe/buildhistory-diff.txt`` file found in
  2364. your build directory.
  2365. - If you want to enable testing through the
  2366. :ref:`testimage <ref-classes-testimage*>`
  2367. class, which is optional, you need to have the following set in
  2368. your ``conf/local.conf`` file:
  2369. ::
  2370. INHERIT += "testimage"
  2371. .. note::
  2372. If your distro does not enable by default ptest, which Poky
  2373. does, you need the following in your ``local.conf`` file:
  2374. ::
  2375. DISTRO_FEATURES_append = " ptest"
  2376. 6. *Optionally Start a vncserver:* If you are running in a server
  2377. without an X11 session, you need to start a vncserver:
  2378. ::
  2379. $ vncserver :1
  2380. $ export DISPLAY=:1
  2381. 7. *Create and Edit an AUH Configuration File:* You need to have the
  2382. ``upgrade-helper/upgrade-helper.conf`` configuration file in your
  2383. build directory. You can find a sample configuration file in the
  2384. :yocto_git:`AUH source repository </auto-upgrade-helper/tree/>`.
  2385. Read through the sample file and make configurations as needed. For
  2386. example, if you enabled build history in your ``local.conf`` as
  2387. described earlier, you must enable it in ``upgrade-helper.conf``.
  2388. Also, if you are using the default ``maintainers.inc`` file supplied
  2389. with Poky and located in ``meta-yocto`` and you do not set a
  2390. "maintainers_whitelist" or "global_maintainer_override" in the
  2391. ``upgrade-helper.conf`` configuration, and you specify "-e all" on
  2392. the AUH command-line, the utility automatically sends out emails to
  2393. all the default maintainers. Please avoid this.
  2394. This next set of examples describes how to use the AUH:
  2395. - *Upgrading a Specific Recipe:* To upgrade a specific recipe, use the
  2396. following form:
  2397. ::
  2398. $ upgrade-helper.py recipe_name
  2399. For example, this command upgrades the ``xmodmap`` recipe:
  2400. ::
  2401. $ upgrade-helper.py xmodmap
  2402. - *Upgrading a Specific Recipe to a Particular Version:* To upgrade a
  2403. specific recipe to a particular version, use the following form:
  2404. ::
  2405. $ upgrade-helper.py recipe_name -t version
  2406. For example, this command upgrades the ``xmodmap`` recipe to version 1.2.3:
  2407. ::
  2408. $ upgrade-helper.py xmodmap -t 1.2.3
  2409. - *Upgrading all Recipes to the Latest Versions and Suppressing Email
  2410. Notifications:* To upgrade all recipes to their most recent versions
  2411. and suppress the email notifications, use the following command:
  2412. ::
  2413. $ upgrade-helper.py all
  2414. - *Upgrading all Recipes to the Latest Versions and Send Email
  2415. Notifications:* To upgrade all recipes to their most recent versions
  2416. and send email messages to maintainers for each attempted recipe as
  2417. well as a status email, use the following command:
  2418. ::
  2419. $ upgrade-helper.py -e all
  2420. Once you have run the AUH utility, you can find the results in the AUH
  2421. build directory:
  2422. ::
  2423. ${BUILDDIR}/upgrade-helper/timestamp
  2424. The AUH utility
  2425. also creates recipe update commits from successful upgrade attempts in
  2426. the layer tree.
  2427. You can easily set up to run the AUH utility on a regular basis by using
  2428. a cron job. See the
  2429. :yocto_git:`weeklyjob.sh </auto-upgrade-helper/tree/weeklyjob.sh>`
  2430. file distributed with the utility for an example.
  2431. Using ``devtool upgrade``
  2432. -------------------------
  2433. As mentioned earlier, an alternative method for upgrading recipes to
  2434. newer versions is to use
  2435. :doc:`devtool upgrade </ref-manual/devtool-reference>`.
  2436. You can read about ``devtool upgrade`` in general in the
  2437. ":ref:`sdk-manual/extensible:use \`\`devtool upgrade\`\` to create a version of the recipe that supports a newer version of the software`"
  2438. section in the Yocto Project Application Development and the Extensible
  2439. Software Development Kit (eSDK) Manual.
  2440. To see all the command-line options available with ``devtool upgrade``,
  2441. use the following help command:
  2442. ::
  2443. $ devtool upgrade -h
  2444. If you want to find out what version a recipe is currently at upstream
  2445. without any attempt to upgrade your local version of the recipe, you can
  2446. use the following command:
  2447. ::
  2448. $ devtool latest-version recipe_name
  2449. As mentioned in the previous section describing AUH, ``devtool upgrade``
  2450. works in a less-automated manner than AUH. Specifically,
  2451. ``devtool upgrade`` only works on a single recipe that you name on the
  2452. command line, cannot perform build and integration testing using images,
  2453. and does not automatically generate commits for changes in the source
  2454. tree. Despite all these "limitations", ``devtool upgrade`` updates the
  2455. recipe file to the new upstream version and attempts to rebase custom
  2456. patches contained by the recipe as needed.
  2457. .. note::
  2458. AUH uses much of ``devtool upgrade`` behind the scenes making AUH somewhat
  2459. of a "wrapper" application for ``devtool upgrade``.
  2460. A typical scenario involves having used Git to clone an upstream
  2461. repository that you use during build operations. Because you have built the
  2462. recipe in the past, the layer is likely added to your
  2463. configuration already. If for some reason, the layer is not added, you
  2464. could add it easily using the
  2465. ":ref:`bitbake-layers <bsp-guide/bsp:creating a new bsp layer using the \`\`bitbake-layers\`\` script>`"
  2466. script. For example, suppose you use the ``nano.bb`` recipe from the
  2467. ``meta-oe`` layer in the ``meta-openembedded`` repository. For this
  2468. example, assume that the layer has been cloned into following area:
  2469. ::
  2470. /home/scottrif/meta-openembedded
  2471. The following command from your
  2472. :term:`Build Directory` adds the layer to
  2473. your build configuration (i.e. ``${BUILDDIR}/conf/bblayers.conf``):
  2474. ::
  2475. $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe
  2476. NOTE: Starting bitbake server...
  2477. Parsing recipes: 100% |##########################################| Time: 0:00:55
  2478. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  2479. Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00
  2480. Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00
  2481. Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00
  2482. Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00
  2483. For this example, assume that the ``nano.bb`` recipe that
  2484. is upstream has a 2.9.3 version number. However, the version in the
  2485. local repository is 2.7.4. The following command from your build
  2486. directory automatically upgrades the recipe for you:
  2487. .. note::
  2488. Using the ``-V`` option is not necessary. Omitting the version number causes
  2489. ``devtool upgrade`` to upgrade the recipe to the most recent version.
  2490. ::
  2491. $ devtool upgrade nano -V 2.9.3
  2492. NOTE: Starting bitbake server...
  2493. NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace
  2494. Parsing recipes: 100% |##########################################| Time: 0:00:46
  2495. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  2496. NOTE: Extracting current version source...
  2497. NOTE: Resolving any missing task queue dependencies
  2498. .
  2499. .
  2500. .
  2501. NOTE: Executing SetScene Tasks
  2502. NOTE: Executing RunQueue Tasks
  2503. NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded.
  2504. Adding changed files: 100% |#####################################| Time: 0:00:00
  2505. NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano
  2506. NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb
  2507. Continuing with this example, you can use ``devtool build`` to build the
  2508. newly upgraded recipe:
  2509. ::
  2510. $ devtool build nano
  2511. NOTE: Starting bitbake server...
  2512. Loading cache: 100% |################################################################################################| Time: 0:00:01
  2513. Loaded 2040 entries from dependency cache.
  2514. Parsing recipes: 100% |##############################################################################################| Time: 0:00:00
  2515. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  2516. NOTE: Resolving any missing task queue dependencies
  2517. .
  2518. .
  2519. .
  2520. NOTE: Executing SetScene Tasks
  2521. NOTE: Executing RunQueue Tasks
  2522. NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano
  2523. NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded.
  2524. Within the ``devtool upgrade`` workflow, opportunity
  2525. exists to deploy and test your rebuilt software. For this example,
  2526. however, running ``devtool finish`` cleans up the workspace once the
  2527. source in your workspace is clean. This usually means using Git to stage
  2528. and submit commits for the changes generated by the upgrade process.
  2529. Once the tree is clean, you can clean things up in this example with the
  2530. following command from the ``${BUILDDIR}/workspace/sources/nano``
  2531. directory:
  2532. ::
  2533. $ devtool finish nano meta-oe
  2534. NOTE: Starting bitbake server...
  2535. Loading cache: 100% |################################################################################################| Time: 0:00:00
  2536. Loaded 2040 entries from dependency cache.
  2537. Parsing recipes: 100% |##############################################################################################| Time: 0:00:01
  2538. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  2539. NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch
  2540. NOTE: Updating recipe nano_2.9.3.bb
  2541. NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb
  2542. NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano
  2543. NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually
  2544. Using the ``devtool finish`` command cleans up the workspace and creates a patch
  2545. file based on your commits. The tool puts all patch files back into the
  2546. source directory in a sub-directory named ``nano`` in this case.
  2547. Manually Upgrading a Recipe
  2548. ---------------------------
  2549. If for some reason you choose not to upgrade recipes using
  2550. :ref:`dev-manual/common-tasks:Using the Auto Upgrade Helper (AUH)` or
  2551. by :ref:`dev-manual/common-tasks:Using \`\`devtool upgrade\`\``,
  2552. you can manually edit the recipe files to upgrade the versions.
  2553. .. note::
  2554. Manually updating multiple recipes scales poorly and involves many
  2555. steps. The recommendation to upgrade recipe versions is through AUH
  2556. or ``devtool upgrade``, both of which automate some steps and provide
  2557. guidance for others needed for the manual process.
  2558. To manually upgrade recipe versions, follow these general steps:
  2559. 1. *Change the Version:* Rename the recipe such that the version (i.e.
  2560. the :term:`PV` part of the recipe name)
  2561. changes appropriately. If the version is not part of the recipe name,
  2562. change the value as it is set for ``PV`` within the recipe itself.
  2563. 2. *Update* ``SRCREV`` *if Needed*: If the source code your recipe builds
  2564. is fetched from Git or some other version control system, update
  2565. :term:`SRCREV` to point to the
  2566. commit hash that matches the new version.
  2567. 3. *Build the Software:* Try to build the recipe using BitBake. Typical
  2568. build failures include the following:
  2569. - License statements were updated for the new version. For this
  2570. case, you need to review any changes to the license and update the
  2571. values of :term:`LICENSE` and
  2572. :term:`LIC_FILES_CHKSUM`
  2573. as needed.
  2574. .. note::
  2575. License changes are often inconsequential. For example, the
  2576. license text's copyright year might have changed.
  2577. - Custom patches carried by the older version of the recipe might
  2578. fail to apply to the new version. For these cases, you need to
  2579. review the failures. Patches might not be necessary for the new
  2580. version of the software if the upgraded version has fixed those
  2581. issues. If a patch is necessary and failing, you need to rebase it
  2582. into the new version.
  2583. 4. *Optionally Attempt to Build for Several Architectures:* Once you
  2584. successfully build the new software for a given architecture, you
  2585. could test the build for other architectures by changing the
  2586. :term:`MACHINE` variable and
  2587. rebuilding the software. This optional step is especially important
  2588. if the recipe is to be released publicly.
  2589. 5. *Check the Upstream Change Log or Release Notes:* Checking both these
  2590. reveals if new features exist that could break
  2591. backwards-compatibility. If so, you need to take steps to mitigate or
  2592. eliminate that situation.
  2593. 6. *Optionally Create a Bootable Image and Test:* If you want, you can
  2594. test the new software by booting it onto actual hardware.
  2595. 7. *Create a Commit with the Change in the Layer Repository:* After all
  2596. builds work and any testing is successful, you can create commits for
  2597. any changes in the layer holding your upgraded recipe.
  2598. Finding Temporary Source Code
  2599. =============================
  2600. You might find it helpful during development to modify the temporary
  2601. source code used by recipes to build packages. For example, suppose you
  2602. are developing a patch and you need to experiment a bit to figure out
  2603. your solution. After you have initially built the package, you can
  2604. iteratively tweak the source code, which is located in the
  2605. :term:`Build Directory`, and then you can
  2606. force a re-compile and quickly test your altered code. Once you settle
  2607. on a solution, you can then preserve your changes in the form of
  2608. patches.
  2609. During a build, the unpacked temporary source code used by recipes to
  2610. build packages is available in the Build Directory as defined by the
  2611. :term:`S` variable. Below is the default
  2612. value for the ``S`` variable as defined in the
  2613. ``meta/conf/bitbake.conf`` configuration file in the
  2614. :term:`Source Directory`:
  2615. ::
  2616. S = "${WORKDIR}/${BP}"
  2617. You should be aware that many recipes override the
  2618. ``S`` variable. For example, recipes that fetch their source from Git
  2619. usually set ``S`` to ``${WORKDIR}/git``.
  2620. .. note::
  2621. The :term:`BP` represents the base recipe name, which consists of the name
  2622. and version:
  2623. ::
  2624. BP = "${BPN}-${PV}"
  2625. The path to the work directory for the recipe
  2626. (:term:`WORKDIR`) is defined as
  2627. follows:
  2628. ::
  2629. ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
  2630. The actual directory depends on several things:
  2631. - :term:`TMPDIR`: The top-level build
  2632. output directory.
  2633. - :term:`MULTIMACH_TARGET_SYS`:
  2634. The target system identifier.
  2635. - :term:`PN`: The recipe name.
  2636. - :term:`EXTENDPE`: The epoch - (if
  2637. :term:`PE` is not specified, which is
  2638. usually the case for most recipes, then ``EXTENDPE`` is blank).
  2639. - :term:`PV`: The recipe version.
  2640. - :term:`PR`: The recipe revision.
  2641. As an example, assume a Source Directory top-level folder named
  2642. ``poky``, a default Build Directory at ``poky/build``, and a
  2643. ``qemux86-poky-linux`` machine target system. Furthermore, suppose your
  2644. recipe is named ``foo_1.3.0.bb``. In this case, the work directory the
  2645. build system uses to build the package would be as follows:
  2646. ::
  2647. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  2648. Using Quilt in Your Workflow
  2649. ============================
  2650. `Quilt <https://savannah.nongnu.org/projects/quilt>`__ is a powerful tool
  2651. that allows you to capture source code changes without having a clean
  2652. source tree. This section outlines the typical workflow you can use to
  2653. modify source code, test changes, and then preserve the changes in the
  2654. form of a patch all using Quilt.
  2655. .. note::
  2656. With regard to preserving changes to source files, if you clean a
  2657. recipe or have ``rm_work`` enabled, the
  2658. :ref:`devtool workflow <sdk-manual/extensible:using \`\`devtool\`\` in your sdk workflow>`
  2659. as described in the Yocto Project Application Development and the
  2660. Extensible Software Development Kit (eSDK) manual is a safer
  2661. development flow than the flow that uses Quilt.
  2662. Follow these general steps:
  2663. 1. *Find the Source Code:* Temporary source code used by the
  2664. OpenEmbedded build system is kept in the
  2665. :term:`Build Directory`. See the
  2666. ":ref:`dev-manual/common-tasks:finding temporary source code`" section to
  2667. learn how to locate the directory that has the temporary source code for a
  2668. particular package.
  2669. 2. *Change Your Working Directory:* You need to be in the directory that
  2670. has the temporary source code. That directory is defined by the
  2671. :term:`S` variable.
  2672. 3. *Create a New Patch:* Before modifying source code, you need to
  2673. create a new patch. To create a new patch file, use ``quilt new`` as
  2674. below:
  2675. ::
  2676. $ quilt new my_changes.patch
  2677. 4. *Notify Quilt and Add Files:* After creating the patch, you need to
  2678. notify Quilt about the files you plan to edit. You notify Quilt by
  2679. adding the files to the patch you just created:
  2680. ::
  2681. $ quilt add file1.c file2.c file3.c
  2682. 5. *Edit the Files:* Make your changes in the source code to the files
  2683. you added to the patch.
  2684. 6. *Test Your Changes:* Once you have modified the source code, the
  2685. easiest way to test your changes is by calling the ``do_compile``
  2686. task as shown in the following example:
  2687. ::
  2688. $ bitbake -c compile -f package
  2689. The ``-f`` or ``--force`` option forces the specified task to
  2690. execute. If you find problems with your code, you can just keep
  2691. editing and re-testing iteratively until things work as expected.
  2692. .. note::
  2693. All the modifications you make to the temporary source code disappear
  2694. once you run the ``do_clean`` or ``do_cleanall`` tasks using BitBake
  2695. (i.e. ``bitbake -c clean package`` and ``bitbake -c cleanall package``).
  2696. Modifications will also disappear if you use the ``rm_work`` feature as
  2697. described in the
  2698. ":ref:`dev-manual/common-tasks:conserving disk space during builds`"
  2699. section.
  2700. 7. *Generate the Patch:* Once your changes work as expected, you need to
  2701. use Quilt to generate the final patch that contains all your
  2702. modifications.
  2703. ::
  2704. $ quilt refresh
  2705. At this point, the
  2706. ``my_changes.patch`` file has all your edits made to the ``file1.c``,
  2707. ``file2.c``, and ``file3.c`` files.
  2708. You can find the resulting patch file in the ``patches/``
  2709. subdirectory of the source (``S``) directory.
  2710. 8. *Copy the Patch File:* For simplicity, copy the patch file into a
  2711. directory named ``files``, which you can create in the same directory
  2712. that holds the recipe (``.bb``) file or the append (``.bbappend``)
  2713. file. Placing the patch here guarantees that the OpenEmbedded build
  2714. system will find the patch. Next, add the patch into the ``SRC_URI``
  2715. of the recipe. Here is an example:
  2716. ::
  2717. SRC_URI += "file://my_changes.patch"
  2718. Using a Development Shell
  2719. =========================
  2720. When debugging certain commands or even when just editing packages,
  2721. ``devshell`` can be a useful tool. When you invoke ``devshell``, all
  2722. tasks up to and including
  2723. :ref:`ref-tasks-patch` are run for the
  2724. specified target. Then, a new terminal is opened and you are placed in
  2725. ``${``\ :term:`S`\ ``}``, the source
  2726. directory. In the new terminal, all the OpenEmbedded build-related
  2727. environment variables are still defined so you can use commands such as
  2728. ``configure`` and ``make``. The commands execute just as if the
  2729. OpenEmbedded build system were executing them. Consequently, working
  2730. this way can be helpful when debugging a build or preparing software to
  2731. be used with the OpenEmbedded build system.
  2732. Following is an example that uses ``devshell`` on a target named
  2733. ``matchbox-desktop``:
  2734. ::
  2735. $ bitbake matchbox-desktop -c devshell
  2736. This command spawns a terminal with a shell prompt within the
  2737. OpenEmbedded build environment. The
  2738. :term:`OE_TERMINAL` variable
  2739. controls what type of shell is opened.
  2740. For spawned terminals, the following occurs:
  2741. - The ``PATH`` variable includes the cross-toolchain.
  2742. - The ``pkgconfig`` variables find the correct ``.pc`` files.
  2743. - The ``configure`` command finds the Yocto Project site files as well
  2744. as any other necessary files.
  2745. Within this environment, you can run configure or compile commands as if
  2746. they were being run by the OpenEmbedded build system itself. As noted
  2747. earlier, the working directory also automatically changes to the Source
  2748. Directory (:term:`S`).
  2749. To manually run a specific task using ``devshell``, run the
  2750. corresponding ``run.*`` script in the
  2751. ``${``\ :term:`WORKDIR`\ ``}/temp``
  2752. directory (e.g., ``run.do_configure.``\ `pid`). If a task's script does
  2753. not exist, which would be the case if the task was skipped by way of the
  2754. sstate cache, you can create the task by first running it outside of the
  2755. ``devshell``:
  2756. ::
  2757. $ bitbake -c task
  2758. .. note::
  2759. - Execution of a task's ``run.*`` script and BitBake's execution of
  2760. a task are identical. In other words, running the script re-runs
  2761. the task just as it would be run using the ``bitbake -c`` command.
  2762. - Any ``run.*`` file that does not have a ``.pid`` extension is a
  2763. symbolic link (symlink) to the most recent version of that file.
  2764. Remember, that the ``devshell`` is a mechanism that allows you to get
  2765. into the BitBake task execution environment. And as such, all commands
  2766. must be called just as BitBake would call them. That means you need to
  2767. provide the appropriate options for cross-compilation and so forth as
  2768. applicable.
  2769. When you are finished using ``devshell``, exit the shell or close the
  2770. terminal window.
  2771. .. note::
  2772. - It is worth remembering that when using ``devshell`` you need to
  2773. use the full compiler name such as ``arm-poky-linux-gnueabi-gcc``
  2774. instead of just using ``gcc``. The same applies to other
  2775. applications such as ``binutils``, ``libtool`` and so forth.
  2776. BitBake sets up environment variables such as ``CC`` to assist
  2777. applications, such as ``make`` to find the correct tools.
  2778. - It is also worth noting that ``devshell`` still works over X11
  2779. forwarding and similar situations.
  2780. Using a Development Python Shell
  2781. ================================
  2782. Similar to working within a development shell as described in the
  2783. previous section, you can also spawn and work within an interactive
  2784. Python development shell. When debugging certain commands or even when
  2785. just editing packages, ``devpyshell`` can be a useful tool. When you
  2786. invoke ``devpyshell``, all tasks up to and including
  2787. :ref:`ref-tasks-patch` are run for the
  2788. specified target. Then a new terminal is opened. Additionally, key
  2789. Python objects and code are available in the same way they are to
  2790. BitBake tasks, in particular, the data store 'd'. So, commands such as
  2791. the following are useful when exploring the data store and running
  2792. functions:
  2793. ::
  2794. pydevshell> d.getVar("STAGING_DIR")
  2795. '/media/build1/poky/build/tmp/sysroots'
  2796. pydevshell> d.getVar("STAGING_DIR")
  2797. '${TMPDIR}/sysroots'
  2798. pydevshell> d.setVar("FOO", "bar")
  2799. pydevshell> d.getVar("FOO")
  2800. 'bar'
  2801. pydevshell> d.delVar("FOO")
  2802. pydevshell> d.getVar("FOO")
  2803. pydevshell> bb.build.exec_func("do_unpack", d)
  2804. pydevshell>
  2805. The commands execute just as if the OpenEmbedded build
  2806. system were executing them. Consequently, working this way can be
  2807. helpful when debugging a build or preparing software to be used with the
  2808. OpenEmbedded build system.
  2809. Following is an example that uses ``devpyshell`` on a target named
  2810. ``matchbox-desktop``:
  2811. ::
  2812. $ bitbake matchbox-desktop -c devpyshell
  2813. This command spawns a terminal and places you in an interactive Python
  2814. interpreter within the OpenEmbedded build environment. The
  2815. :term:`OE_TERMINAL` variable
  2816. controls what type of shell is opened.
  2817. When you are finished using ``devpyshell``, you can exit the shell
  2818. either by using Ctrl+d or closing the terminal window.
  2819. Building
  2820. ========
  2821. This section describes various build procedures. For example, the steps
  2822. needed for a simple build, a target that uses multiple configurations,
  2823. building an image for more than one machine, and so forth.
  2824. Building a Simple Image
  2825. -----------------------
  2826. In the development environment, you need to build an image whenever you
  2827. change hardware support, add or change system libraries, or add or
  2828. change services that have dependencies. Several methods exist that allow
  2829. you to build an image within the Yocto Project. This section presents
  2830. the basic steps you need to build a simple image using BitBake from a
  2831. build host running Linux.
  2832. .. note::
  2833. - For information on how to build an image using
  2834. :term:`Toaster`, see the
  2835. :doc:`/toaster-manual/index`.
  2836. - For information on how to use ``devtool`` to build images, see the
  2837. ":ref:`sdk-manual/extensible:using \`\`devtool\`\` in your sdk workflow`"
  2838. section in the Yocto Project Application Development and the
  2839. Extensible Software Development Kit (eSDK) manual.
  2840. - For a quick example on how to build an image using the
  2841. OpenEmbedded build system, see the
  2842. :doc:`/brief-yoctoprojectqs/index` document.
  2843. The build process creates an entire Linux distribution from source and
  2844. places it in your :term:`Build Directory` under
  2845. ``tmp/deploy/images``. For detailed information on the build process
  2846. using BitBake, see the ":ref:`overview-manual/concepts:images`" section in the
  2847. Yocto Project Overview and Concepts Manual.
  2848. The following figure and list overviews the build process:
  2849. .. image:: figures/bitbake-build-flow.png
  2850. :align: center
  2851. 1. *Set up Your Host Development System to Support Development Using the
  2852. Yocto Project*: See the ":doc:`start`" section for options on how to get a
  2853. build host ready to use the Yocto Project.
  2854. 2. *Initialize the Build Environment:* Initialize the build environment
  2855. by sourcing the build environment script (i.e.
  2856. :ref:`structure-core-script`):
  2857. ::
  2858. $ source oe-init-build-env [build_dir]
  2859. When you use the initialization script, the OpenEmbedded build system
  2860. uses ``build`` as the default :term:`Build Directory` in your current work
  2861. directory. You can use a `build_dir` argument with the script to
  2862. specify a different build directory.
  2863. .. note::
  2864. A common practice is to use a different Build Directory for
  2865. different targets. For example, ``~/build/x86`` for a ``qemux86``
  2866. target, and ``~/build/arm`` for a ``qemuarm`` target.
  2867. 3. *Make Sure Your* ``local.conf`` *File is Correct*: Ensure the
  2868. ``conf/local.conf`` configuration file, which is found in the Build
  2869. Directory, is set up how you want it. This file defines many aspects
  2870. of the build environment including the target machine architecture
  2871. through the ``MACHINE`` variable, the packaging format used during
  2872. the build
  2873. (:term:`PACKAGE_CLASSES`),
  2874. and a centralized tarball download directory through the
  2875. :term:`DL_DIR` variable.
  2876. 4. *Build the Image:* Build the image using the ``bitbake`` command:
  2877. ::
  2878. $ bitbake target
  2879. .. note::
  2880. For information on BitBake, see the :doc:`bitbake:index`.
  2881. The target is the name of the recipe you want to build. Common
  2882. targets are the images in ``meta/recipes-core/images``,
  2883. ``meta/recipes-sato/images``, and so forth all found in the
  2884. :term:`Source Directory`. Or, the target
  2885. can be the name of a recipe for a specific piece of software such as
  2886. BusyBox. For more details about the images the OpenEmbedded build
  2887. system supports, see the
  2888. ":ref:`ref-manual/images:Images`" chapter in the Yocto
  2889. Project Reference Manual.
  2890. As an example, the following command builds the
  2891. ``core-image-minimal`` image:
  2892. ::
  2893. $ bitbake core-image-minimal
  2894. Once an
  2895. image has been built, it often needs to be installed. The images and
  2896. kernels built by the OpenEmbedded build system are placed in the
  2897. Build Directory in ``tmp/deploy/images``. For information on how to
  2898. run pre-built images such as ``qemux86`` and ``qemuarm``, see the
  2899. :doc:`/sdk-manual/index` manual. For
  2900. information about how to install these images, see the documentation
  2901. for your particular board or machine.
  2902. Building Images for Multiple Targets Using Multiple Configurations
  2903. ------------------------------------------------------------------
  2904. You can use a single ``bitbake`` command to build multiple images or
  2905. packages for different targets where each image or package requires a
  2906. different configuration (multiple configuration builds). The builds, in
  2907. this scenario, are sometimes referred to as "multiconfigs", and this
  2908. section uses that term throughout.
  2909. This section describes how to set up for multiple configuration builds
  2910. and how to account for cross-build dependencies between the
  2911. multiconfigs.
  2912. Setting Up and Running a Multiple Configuration Build
  2913. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2914. To accomplish a multiple configuration build, you must define each
  2915. target's configuration separately using a parallel configuration file in
  2916. the :term:`Build Directory`, and you
  2917. must follow a required file hierarchy. Additionally, you must enable the
  2918. multiple configuration builds in your ``local.conf`` file.
  2919. Follow these steps to set up and execute multiple configuration builds:
  2920. - *Create Separate Configuration Files*: You need to create a single
  2921. configuration file for each build target (each multiconfig).
  2922. Minimally, each configuration file must define the machine and the
  2923. temporary directory BitBake uses for the build. Suggested practice
  2924. dictates that you do not overlap the temporary directories used
  2925. during the builds. However, it is possible that you can share the
  2926. temporary directory
  2927. (:term:`TMPDIR`). For example,
  2928. consider a scenario with two different multiconfigs for the same
  2929. :term:`MACHINE`: "qemux86" built
  2930. for two distributions such as "poky" and "poky-lsb". In this case,
  2931. you might want to use the same ``TMPDIR``.
  2932. Here is an example showing the minimal statements needed in a
  2933. configuration file for a "qemux86" target whose temporary build
  2934. directory is ``tmpmultix86``:
  2935. ::
  2936. MACHINE = "qemux86"
  2937. TMPDIR = "${TOPDIR}/tmpmultix86"
  2938. The location for these multiconfig configuration files is specific.
  2939. They must reside in the current build directory in a sub-directory of
  2940. ``conf`` named ``multiconfig``. Following is an example that defines
  2941. two configuration files for the "x86" and "arm" multiconfigs:
  2942. .. image:: figures/multiconfig_files.png
  2943. :align: center
  2944. The reason for this required file hierarchy is because the ``BBPATH``
  2945. variable is not constructed until the layers are parsed.
  2946. Consequently, using the configuration file as a pre-configuration
  2947. file is not possible unless it is located in the current working
  2948. directory.
  2949. - *Add the BitBake Multi-configuration Variable to the Local
  2950. Configuration File*: Use the
  2951. :term:`BBMULTICONFIG`
  2952. variable in your ``conf/local.conf`` configuration file to specify
  2953. each multiconfig. Continuing with the example from the previous
  2954. figure, the ``BBMULTICONFIG`` variable needs to enable two
  2955. multiconfigs: "x86" and "arm" by specifying each configuration file:
  2956. ::
  2957. BBMULTICONFIG = "x86 arm"
  2958. .. note::
  2959. A "default" configuration already exists by definition. This
  2960. configuration is named: "" (i.e. empty string) and is defined by
  2961. the variables coming from your ``local.conf``
  2962. file. Consequently, the previous example actually adds two
  2963. additional configurations to your build: "arm" and "x86" along
  2964. with "".
  2965. - *Launch BitBake*: Use the following BitBake command form to launch
  2966. the multiple configuration build:
  2967. ::
  2968. $ bitbake [mc:multiconfigname:]target [[[mc:multiconfigname:]target] ... ]
  2969. For the example in this section, the following command applies:
  2970. ::
  2971. $ bitbake mc:x86:core-image-minimal mc:arm:core-image-sato mc::core-image-base
  2972. The previous BitBake command builds a ``core-image-minimal`` image
  2973. that is configured through the ``x86.conf`` configuration file, a
  2974. ``core-image-sato`` image that is configured through the ``arm.conf``
  2975. configuration file and a ``core-image-base`` that is configured
  2976. through your ``local.conf`` configuration file.
  2977. .. note::
  2978. Support for multiple configuration builds in the Yocto Project &DISTRO;
  2979. (&DISTRO_NAME;) Release does not include Shared State (sstate)
  2980. optimizations. Consequently, if a build uses the same object twice
  2981. in, for example, two different ``TMPDIR``
  2982. directories, the build either loads from an existing sstate cache for
  2983. that build at the start or builds the object fresh.
  2984. Enabling Multiple Configuration Build Dependencies
  2985. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2986. Sometimes dependencies can exist between targets (multiconfigs) in a
  2987. multiple configuration build. For example, suppose that in order to
  2988. build a ``core-image-sato`` image for an "x86" multiconfig, the root
  2989. filesystem of an "arm" multiconfig must exist. This dependency is
  2990. essentially that the
  2991. :ref:`ref-tasks-image` task in the
  2992. ``core-image-sato`` recipe depends on the completion of the
  2993. :ref:`ref-tasks-rootfs` task of the
  2994. ``core-image-minimal`` recipe.
  2995. To enable dependencies in a multiple configuration build, you must
  2996. declare the dependencies in the recipe using the following statement
  2997. form:
  2998. ::
  2999. task_or_package[mcdepends] = "mc:from_multiconfig:to_multiconfig:recipe_name:task_on_which_to_depend"
  3000. To better show how to use this statement, consider the example scenario
  3001. from the first paragraph of this section. The following statement needs
  3002. to be added to the recipe that builds the ``core-image-sato`` image:
  3003. ::
  3004. do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_rootfs"
  3005. In this example, the `from_multiconfig` is "x86". The `to_multiconfig` is "arm". The
  3006. task on which the ``do_image`` task in the recipe depends is the
  3007. ``do_rootfs`` task from the ``core-image-minimal`` recipe associated
  3008. with the "arm" multiconfig.
  3009. Once you set up this dependency, you can build the "x86" multiconfig
  3010. using a BitBake command as follows:
  3011. ::
  3012. $ bitbake mc:x86:core-image-sato
  3013. This command executes all the tasks needed to create the
  3014. ``core-image-sato`` image for the "x86" multiconfig. Because of the
  3015. dependency, BitBake also executes through the ``do_rootfs`` task for the
  3016. "arm" multiconfig build.
  3017. Having a recipe depend on the root filesystem of another build might not
  3018. seem that useful. Consider this change to the statement in the
  3019. ``core-image-sato`` recipe:
  3020. ::
  3021. do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_image"
  3022. In this case, BitBake must
  3023. create the ``core-image-minimal`` image for the "arm" build since the
  3024. "x86" build depends on it.
  3025. Because "x86" and "arm" are enabled for multiple configuration builds
  3026. and have separate configuration files, BitBake places the artifacts for
  3027. each build in the respective temporary build directories (i.e.
  3028. :term:`TMPDIR`).
  3029. Building an Initial RAM Filesystem (initramfs) Image
  3030. ----------------------------------------------------
  3031. An initial RAM filesystem (initramfs) image provides a temporary root
  3032. filesystem used for early system initialization (e.g. loading of modules
  3033. needed to locate and mount the "real" root filesystem).
  3034. .. note::
  3035. The initramfs image is the successor of initial RAM disk (initrd). It
  3036. is a "copy in and out" (cpio) archive of the initial filesystem that
  3037. gets loaded into memory during the Linux startup process. Because
  3038. Linux uses the contents of the archive during initialization, the
  3039. initramfs image needs to contain all of the device drivers and tools
  3040. needed to mount the final root filesystem.
  3041. Follow these steps to create an initramfs image:
  3042. 1. *Create the initramfs Image Recipe:* You can reference the
  3043. ``core-image-minimal-initramfs.bb`` recipe found in the
  3044. ``meta/recipes-core`` directory of the :term:`Source Directory`
  3045. as an example
  3046. from which to work.
  3047. 2. *Decide if You Need to Bundle the initramfs Image Into the Kernel
  3048. Image:* If you want the initramfs image that is built to be bundled
  3049. in with the kernel image, set the
  3050. :term:`INITRAMFS_IMAGE_BUNDLE`
  3051. variable to "1" in your ``local.conf`` configuration file and set the
  3052. :term:`INITRAMFS_IMAGE`
  3053. variable in the recipe that builds the kernel image.
  3054. .. note::
  3055. It is recommended that you do bundle the initramfs image with the
  3056. kernel image to avoid circular dependencies between the kernel
  3057. recipe and the initramfs recipe should the initramfs image include
  3058. kernel modules.
  3059. Setting the ``INITRAMFS_IMAGE_BUNDLE`` flag causes the initramfs
  3060. image to be unpacked into the ``${B}/usr/`` directory. The unpacked
  3061. initramfs image is then passed to the kernel's ``Makefile`` using the
  3062. :term:`CONFIG_INITRAMFS_SOURCE`
  3063. variable, allowing the initramfs image to be built into the kernel
  3064. normally.
  3065. .. note::
  3066. If you choose to not bundle the initramfs image with the kernel
  3067. image, you are essentially using an
  3068. `Initial RAM Disk (initrd) <https://en.wikipedia.org/wiki/Initrd>`__.
  3069. Creating an initrd is handled primarily through the :term:`INITRD_IMAGE`,
  3070. ``INITRD_LIVE``, and ``INITRD_IMAGE_LIVE`` variables. For more
  3071. information, see the :ref:`ref-classes-image-live` file.
  3072. 3. *Optionally Add Items to the initramfs Image Through the initramfs
  3073. Image Recipe:* If you add items to the initramfs image by way of its
  3074. recipe, you should use
  3075. :term:`PACKAGE_INSTALL`
  3076. rather than
  3077. :term:`IMAGE_INSTALL`.
  3078. ``PACKAGE_INSTALL`` gives more direct control of what is added to the
  3079. image as compared to the defaults you might not necessarily want that
  3080. are set by the :ref:`image <ref-classes-image>`
  3081. or :ref:`core-image <ref-classes-core-image>`
  3082. classes.
  3083. 4. *Build the Kernel Image and the initramfs Image:* Build your kernel
  3084. image using BitBake. Because the initramfs image recipe is a
  3085. dependency of the kernel image, the initramfs image is built as well
  3086. and bundled with the kernel image if you used the
  3087. :term:`INITRAMFS_IMAGE_BUNDLE`
  3088. variable described earlier.
  3089. Building a Tiny System
  3090. ----------------------
  3091. Very small distributions have some significant advantages such as
  3092. requiring less on-die or in-package memory (cheaper), better performance
  3093. through efficient cache usage, lower power requirements due to less
  3094. memory, faster boot times, and reduced development overhead. Some
  3095. real-world examples where a very small distribution gives you distinct
  3096. advantages are digital cameras, medical devices, and small headless
  3097. systems.
  3098. This section presents information that shows you how you can trim your
  3099. distribution to even smaller sizes than the ``poky-tiny`` distribution,
  3100. which is around 5 Mbytes, that can be built out-of-the-box using the
  3101. Yocto Project.
  3102. Tiny System Overview
  3103. ~~~~~~~~~~~~~~~~~~~~
  3104. The following list presents the overall steps you need to consider and
  3105. perform to create distributions with smaller root filesystems, achieve
  3106. faster boot times, maintain your critical functionality, and avoid
  3107. initial RAM disks:
  3108. - :ref:`Determine your goals and guiding principles
  3109. <dev-manual/common-tasks:goals and guiding principles>`
  3110. - :ref:`dev-manual/common-tasks:understand what contributes to your image size`
  3111. - :ref:`Reduce the size of the root filesystem
  3112. <dev-manual/common-tasks:trim the root filesystem>`
  3113. - :ref:`Reduce the size of the kernel <dev-manual/common-tasks:trim the kernel>`
  3114. - :ref:`dev-manual/common-tasks:remove package management requirements`
  3115. - :ref:`dev-manual/common-tasks:look for other ways to minimize size`
  3116. - :ref:`dev-manual/common-tasks:iterate on the process`
  3117. Goals and Guiding Principles
  3118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3119. Before you can reach your destination, you need to know where you are
  3120. going. Here is an example list that you can use as a guide when creating
  3121. very small distributions:
  3122. - Determine how much space you need (e.g. a kernel that is 1 Mbyte or
  3123. less and a root filesystem that is 3 Mbytes or less).
  3124. - Find the areas that are currently taking 90% of the space and
  3125. concentrate on reducing those areas.
  3126. - Do not create any difficult "hacks" to achieve your goals.
  3127. - Leverage the device-specific options.
  3128. - Work in a separate layer so that you keep changes isolated. For
  3129. information on how to create layers, see the
  3130. ":ref:`dev-manual/common-tasks:understanding and creating layers`" section.
  3131. Understand What Contributes to Your Image Size
  3132. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3133. It is easiest to have something to start with when creating your own
  3134. distribution. You can use the Yocto Project out-of-the-box to create the
  3135. ``poky-tiny`` distribution. Ultimately, you will want to make changes in
  3136. your own distribution that are likely modeled after ``poky-tiny``.
  3137. .. note::
  3138. To use ``poky-tiny`` in your build, set the ``DISTRO`` variable in your
  3139. ``local.conf`` file to "poky-tiny" as described in the
  3140. ":ref:`dev-manual/common-tasks:creating your own distribution`"
  3141. section.
  3142. Understanding some memory concepts will help you reduce the system size.
  3143. Memory consists of static, dynamic, and temporary memory. Static memory
  3144. is the TEXT (code), DATA (initialized data in the code), and BSS
  3145. (uninitialized data) sections. Dynamic memory represents memory that is
  3146. allocated at runtime: stacks, hash tables, and so forth. Temporary
  3147. memory is recovered after the boot process. This memory consists of
  3148. memory used for decompressing the kernel and for the ``__init__``
  3149. functions.
  3150. To help you see where you currently are with kernel and root filesystem
  3151. sizes, you can use two tools found in the :term:`Source Directory`
  3152. in the
  3153. ``scripts/tiny/`` directory:
  3154. - ``ksize.py``: Reports component sizes for the kernel build objects.
  3155. - ``dirsize.py``: Reports component sizes for the root filesystem.
  3156. This next tool and command help you organize configuration fragments and
  3157. view file dependencies in a human-readable form:
  3158. - ``merge_config.sh``: Helps you manage configuration files and
  3159. fragments within the kernel. With this tool, you can merge individual
  3160. configuration fragments together. The tool allows you to make
  3161. overrides and warns you of any missing configuration options. The
  3162. tool is ideal for allowing you to iterate on configurations, create
  3163. minimal configurations, and create configuration files for different
  3164. machines without having to duplicate your process.
  3165. The ``merge_config.sh`` script is part of the Linux Yocto kernel Git
  3166. repositories (i.e. ``linux-yocto-3.14``, ``linux-yocto-3.10``,
  3167. ``linux-yocto-3.8``, and so forth) in the ``scripts/kconfig``
  3168. directory.
  3169. For more information on configuration fragments, see the
  3170. ":ref:`kernel-dev/common:creating configuration fragments`"
  3171. section in the Yocto Project Linux Kernel Development Manual.
  3172. - ``bitbake -u taskexp -g bitbake_target``: Using the BitBake command
  3173. with these options brings up a Dependency Explorer from which you can
  3174. view file dependencies. Understanding these dependencies allows you
  3175. to make informed decisions when cutting out various pieces of the
  3176. kernel and root filesystem.
  3177. Trim the Root Filesystem
  3178. ~~~~~~~~~~~~~~~~~~~~~~~~
  3179. The root filesystem is made up of packages for booting, libraries, and
  3180. applications. To change things, you can configure how the packaging
  3181. happens, which changes the way you build them. You can also modify the
  3182. filesystem itself or select a different filesystem.
  3183. First, find out what is hogging your root filesystem by running the
  3184. ``dirsize.py`` script from your root directory:
  3185. ::
  3186. $ cd root-directory-of-image
  3187. $ dirsize.py 100000 > dirsize-100k.log
  3188. $ cat dirsize-100k.log
  3189. You can apply a filter to the script to ignore files
  3190. under a certain size. The previous example filters out any files below
  3191. 100 Kbytes. The sizes reported by the tool are uncompressed, and thus
  3192. will be smaller by a relatively constant factor in a compressed root
  3193. filesystem. When you examine your log file, you can focus on areas of
  3194. the root filesystem that take up large amounts of memory.
  3195. You need to be sure that what you eliminate does not cripple the
  3196. functionality you need. One way to see how packages relate to each other
  3197. is by using the Dependency Explorer UI with the BitBake command:
  3198. ::
  3199. $ cd image-directory
  3200. $ bitbake -u taskexp -g image
  3201. Use the interface to
  3202. select potential packages you wish to eliminate and see their dependency
  3203. relationships.
  3204. When deciding how to reduce the size, get rid of packages that result in
  3205. minimal impact on the feature set. For example, you might not need a VGA
  3206. display. Or, you might be able to get by with ``devtmpfs`` and ``mdev``
  3207. instead of ``udev``.
  3208. Use your ``local.conf`` file to make changes. For example, to eliminate
  3209. ``udev`` and ``glib``, set the following in the local configuration
  3210. file:
  3211. ::
  3212. VIRTUAL-RUNTIME_dev_manager = ""
  3213. Finally, you should consider exactly the type of root filesystem you
  3214. need to meet your needs while also reducing its size. For example,
  3215. consider ``cramfs``, ``squashfs``, ``ubifs``, ``ext2``, or an
  3216. ``initramfs`` using ``initramfs``. Be aware that ``ext3`` requires a 1
  3217. Mbyte journal. If you are okay with running read-only, you do not need
  3218. this journal.
  3219. .. note::
  3220. After each round of elimination, you need to rebuild your system and
  3221. then use the tools to see the effects of your reductions.
  3222. Trim the Kernel
  3223. ~~~~~~~~~~~~~~~
  3224. The kernel is built by including policies for hardware-independent
  3225. aspects. What subsystems do you enable? For what architecture are you
  3226. building? Which drivers do you build by default?
  3227. .. note::
  3228. You can modify the kernel source if you want to help with boot time.
  3229. Run the ``ksize.py`` script from the top-level Linux build directory to
  3230. get an idea of what is making up the kernel:
  3231. ::
  3232. $ cd top-level-linux-build-directory
  3233. $ ksize.py > ksize.log
  3234. $ cat ksize.log
  3235. When you examine the log, you will see how much space is taken up with
  3236. the built-in ``.o`` files for drivers, networking, core kernel files,
  3237. filesystem, sound, and so forth. The sizes reported by the tool are
  3238. uncompressed, and thus will be smaller by a relatively constant factor
  3239. in a compressed kernel image. Look to reduce the areas that are large
  3240. and taking up around the "90% rule."
  3241. To examine, or drill down, into any particular area, use the ``-d``
  3242. option with the script:
  3243. ::
  3244. $ ksize.py -d > ksize.log
  3245. Using this option
  3246. breaks out the individual file information for each area of the kernel
  3247. (e.g. drivers, networking, and so forth).
  3248. Use your log file to see what you can eliminate from the kernel based on
  3249. features you can let go. For example, if you are not going to need
  3250. sound, you do not need any drivers that support sound.
  3251. After figuring out what to eliminate, you need to reconfigure the kernel
  3252. to reflect those changes during the next build. You could run
  3253. ``menuconfig`` and make all your changes at once. However, that makes it
  3254. difficult to see the effects of your individual eliminations and also
  3255. makes it difficult to replicate the changes for perhaps another target
  3256. device. A better method is to start with no configurations using
  3257. ``allnoconfig``, create configuration fragments for individual changes,
  3258. and then manage the fragments into a single configuration file using
  3259. ``merge_config.sh``. The tool makes it easy for you to iterate using the
  3260. configuration change and build cycle.
  3261. Each time you make configuration changes, you need to rebuild the kernel
  3262. and check to see what impact your changes had on the overall size.
  3263. Remove Package Management Requirements
  3264. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3265. Packaging requirements add size to the image. One way to reduce the size
  3266. of the image is to remove all the packaging requirements from the image.
  3267. This reduction includes both removing the package manager and its unique
  3268. dependencies as well as removing the package management data itself.
  3269. To eliminate all the packaging requirements for an image, be sure that
  3270. "package-management" is not part of your
  3271. :term:`IMAGE_FEATURES`
  3272. statement for the image. When you remove this feature, you are removing
  3273. the package manager as well as its dependencies from the root
  3274. filesystem.
  3275. Look for Other Ways to Minimize Size
  3276. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3277. Depending on your particular circumstances, other areas that you can
  3278. trim likely exist. The key to finding these areas is through tools and
  3279. methods described here combined with experimentation and iteration. Here
  3280. are a couple of areas to experiment with:
  3281. - ``glibc``: In general, follow this process:
  3282. 1. Remove ``glibc`` features from
  3283. :term:`DISTRO_FEATURES`
  3284. that you think you do not need.
  3285. 2. Build your distribution.
  3286. 3. If the build fails due to missing symbols in a package, determine
  3287. if you can reconfigure the package to not need those features. For
  3288. example, change the configuration to not support wide character
  3289. support as is done for ``ncurses``. Or, if support for those
  3290. characters is needed, determine what ``glibc`` features provide
  3291. the support and restore the configuration.
  3292. 4. Rebuild and repeat the process.
  3293. - ``busybox``: For BusyBox, use a process similar as described for
  3294. ``glibc``. A difference is you will need to boot the resulting system
  3295. to see if you are able to do everything you expect from the running
  3296. system. You need to be sure to integrate configuration fragments into
  3297. Busybox because BusyBox handles its own core features and then allows
  3298. you to add configuration fragments on top.
  3299. Iterate on the Process
  3300. ~~~~~~~~~~~~~~~~~~~~~~
  3301. If you have not reached your goals on system size, you need to iterate
  3302. on the process. The process is the same. Use the tools and see just what
  3303. is taking up 90% of the root filesystem and the kernel. Decide what you
  3304. can eliminate without limiting your device beyond what you need.
  3305. Depending on your system, a good place to look might be Busybox, which
  3306. provides a stripped down version of Unix tools in a single, executable
  3307. file. You might be able to drop virtual terminal services or perhaps
  3308. ipv6.
  3309. Building Images for More than One Machine
  3310. -----------------------------------------
  3311. A common scenario developers face is creating images for several
  3312. different machines that use the same software environment. In this
  3313. situation, it is tempting to set the tunings and optimization flags for
  3314. each build specifically for the targeted hardware (i.e. "maxing out" the
  3315. tunings). Doing so can considerably add to build times and package feed
  3316. maintenance collectively for the machines. For example, selecting tunes
  3317. that are extremely specific to a CPU core used in a system might enable
  3318. some micro optimizations in GCC for that particular system but would
  3319. otherwise not gain you much of a performance difference across the other
  3320. systems as compared to using a more general tuning across all the builds
  3321. (e.g. setting :term:`DEFAULTTUNE`
  3322. specifically for each machine's build). Rather than "max out" each
  3323. build's tunings, you can take steps that cause the OpenEmbedded build
  3324. system to reuse software across the various machines where it makes
  3325. sense.
  3326. If build speed and package feed maintenance are considerations, you
  3327. should consider the points in this section that can help you optimize
  3328. your tunings to best consider build times and package feed maintenance.
  3329. - *Share the Build Directory:* If at all possible, share the
  3330. :term:`TMPDIR` across builds. The
  3331. Yocto Project supports switching between different
  3332. :term:`MACHINE` values in the same
  3333. ``TMPDIR``. This practice is well supported and regularly used by
  3334. developers when building for multiple machines. When you use the same
  3335. ``TMPDIR`` for multiple machine builds, the OpenEmbedded build system
  3336. can reuse the existing native and often cross-recipes for multiple
  3337. machines. Thus, build time decreases.
  3338. .. note::
  3339. If :term:`DISTRO` settings change or fundamental configuration settings
  3340. such as the filesystem layout, you need to work with a clean ``TMPDIR``.
  3341. Sharing ``TMPDIR`` under these circumstances might work but since it is
  3342. not guaranteed, you should use a clean ``TMPDIR``.
  3343. - *Enable the Appropriate Package Architecture:* By default, the
  3344. OpenEmbedded build system enables three levels of package
  3345. architectures: "all", "tune" or "package", and "machine". Any given
  3346. recipe usually selects one of these package architectures (types) for
  3347. its output. Depending for what a given recipe creates packages,
  3348. making sure you enable the appropriate package architecture can
  3349. directly impact the build time.
  3350. A recipe that just generates scripts can enable "all" architecture
  3351. because there are no binaries to build. To specifically enable "all"
  3352. architecture, be sure your recipe inherits the
  3353. :ref:`allarch <ref-classes-allarch>` class.
  3354. This class is useful for "all" architectures because it configures
  3355. many variables so packages can be used across multiple architectures.
  3356. If your recipe needs to generate packages that are machine-specific
  3357. or when one of the build or runtime dependencies is already
  3358. machine-architecture dependent, which makes your recipe also
  3359. machine-architecture dependent, make sure your recipe enables the
  3360. "machine" package architecture through the
  3361. :term:`MACHINE_ARCH`
  3362. variable:
  3363. ::
  3364. PACKAGE_ARCH = "${MACHINE_ARCH}"
  3365. When you do not
  3366. specifically enable a package architecture through the
  3367. :term:`PACKAGE_ARCH`, The
  3368. OpenEmbedded build system defaults to the
  3369. :term:`TUNE_PKGARCH` setting:
  3370. ::
  3371. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  3372. - *Choose a Generic Tuning File if Possible:* Some tunes are more
  3373. generic and can run on multiple targets (e.g. an ``armv5`` set of
  3374. packages could run on ``armv6`` and ``armv7`` processors in most
  3375. cases). Similarly, ``i486`` binaries could work on ``i586`` and
  3376. higher processors. You should realize, however, that advances on
  3377. newer processor versions would not be used.
  3378. If you select the same tune for several different machines, the
  3379. OpenEmbedded build system reuses software previously built, thus
  3380. speeding up the overall build time. Realize that even though a new
  3381. sysroot for each machine is generated, the software is not recompiled
  3382. and only one package feed exists.
  3383. - *Manage Granular Level Packaging:* Sometimes cases exist where
  3384. injecting another level of package architecture beyond the three
  3385. higher levels noted earlier can be useful. For example, consider how
  3386. NXP (formerly Freescale) allows for the easy reuse of binary packages
  3387. in their layer
  3388. :yocto_git:`meta-freescale </meta-freescale/>`.
  3389. In this example, the
  3390. :yocto_git:`fsl-dynamic-packagearch </meta-freescale/tree/classes/fsl-dynamic-packagearch.bbclass>`
  3391. class shares GPU packages for i.MX53 boards because all boards share
  3392. the AMD GPU. The i.MX6-based boards can do the same because all
  3393. boards share the Vivante GPU. This class inspects the BitBake
  3394. datastore to identify if the package provides or depends on one of
  3395. the sub-architecture values. If so, the class sets the
  3396. :term:`PACKAGE_ARCH` value
  3397. based on the ``MACHINE_SUBARCH`` value. If the package does not
  3398. provide or depend on one of the sub-architecture values but it
  3399. matches a value in the machine-specific filter, it sets
  3400. :term:`MACHINE_ARCH`. This
  3401. behavior reduces the number of packages built and saves build time by
  3402. reusing binaries.
  3403. - *Use Tools to Debug Issues:* Sometimes you can run into situations
  3404. where software is being rebuilt when you think it should not be. For
  3405. example, the OpenEmbedded build system might not be using shared
  3406. state between machines when you think it should be. These types of
  3407. situations are usually due to references to machine-specific
  3408. variables such as :term:`MACHINE`,
  3409. :term:`SERIAL_CONSOLES`,
  3410. :term:`XSERVER`,
  3411. :term:`MACHINE_FEATURES`,
  3412. and so forth in code that is supposed to only be tune-specific or
  3413. when the recipe depends
  3414. (:term:`DEPENDS`,
  3415. :term:`RDEPENDS`,
  3416. :term:`RRECOMMENDS`,
  3417. :term:`RSUGGESTS`, and so forth)
  3418. on some other recipe that already has
  3419. :term:`PACKAGE_ARCH` defined
  3420. as "${MACHINE_ARCH}".
  3421. .. note::
  3422. Patches to fix any issues identified are most welcome as these
  3423. issues occasionally do occur.
  3424. For such cases, you can use some tools to help you sort out the
  3425. situation:
  3426. - ``state-diff-machines.sh``*:* You can find this tool in the
  3427. ``scripts`` directory of the Source Repositories. See the comments
  3428. in the script for information on how to use the tool.
  3429. - *BitBake's "-S printdiff" Option:* Using this option causes
  3430. BitBake to try to establish the closest signature match it can
  3431. (e.g. in the shared state cache) and then run ``bitbake-diffsigs``
  3432. over the matches to determine the stamps and delta where these two
  3433. stamp trees diverge.
  3434. Building Software from an External Source
  3435. -----------------------------------------
  3436. By default, the OpenEmbedded build system uses the
  3437. :term:`Build Directory` when building source
  3438. code. The build process involves fetching the source files, unpacking
  3439. them, and then patching them if necessary before the build takes place.
  3440. Situations exist where you might want to build software from source
  3441. files that are external to and thus outside of the OpenEmbedded build
  3442. system. For example, suppose you have a project that includes a new BSP
  3443. with a heavily customized kernel. And, you want to minimize exposing the
  3444. build system to the development team so that they can focus on their
  3445. project and maintain everyone's workflow as much as possible. In this
  3446. case, you want a kernel source directory on the development machine
  3447. where the development occurs. You want the recipe's
  3448. :term:`SRC_URI` variable to point to
  3449. the external directory and use it as is, not copy it.
  3450. To build from software that comes from an external source, all you need
  3451. to do is inherit the
  3452. :ref:`externalsrc <ref-classes-externalsrc>` class
  3453. and then set the
  3454. :term:`EXTERNALSRC` variable to
  3455. point to your external source code. Here are the statements to put in
  3456. your ``local.conf`` file:
  3457. ::
  3458. INHERIT += "externalsrc"
  3459. EXTERNALSRC_pn-myrecipe = "path-to-your-source-tree"
  3460. This next example shows how to accomplish the same thing by setting
  3461. ``EXTERNALSRC`` in the recipe itself or in the recipe's append file:
  3462. ::
  3463. EXTERNALSRC = "path"
  3464. EXTERNALSRC_BUILD = "path"
  3465. .. note::
  3466. In order for these settings to take effect, you must globally or
  3467. locally inherit the :ref:`externalsrc <ref-classes-externalsrc>`
  3468. class.
  3469. By default, ``externalsrc.bbclass`` builds the source code in a
  3470. directory separate from the external source directory as specified by
  3471. :term:`EXTERNALSRC`. If you need
  3472. to have the source built in the same directory in which it resides, or
  3473. some other nominated directory, you can set
  3474. :term:`EXTERNALSRC_BUILD`
  3475. to point to that directory:
  3476. ::
  3477. EXTERNALSRC_BUILD_pn-myrecipe = "path-to-your-source-tree"
  3478. Replicating a Build Offline
  3479. ---------------------------
  3480. It can be useful to take a "snapshot" of upstream sources used in a
  3481. build and then use that "snapshot" later to replicate the build offline.
  3482. To do so, you need to first prepare and populate your downloads
  3483. directory your "snapshot" of files. Once your downloads directory is
  3484. ready, you can use it at any time and from any machine to replicate your
  3485. build.
  3486. Follow these steps to populate your Downloads directory:
  3487. 1. *Create a Clean Downloads Directory:* Start with an empty downloads
  3488. directory (:term:`DL_DIR`). You
  3489. start with an empty downloads directory by either removing the files
  3490. in the existing directory or by setting ``DL_DIR`` to point to either
  3491. an empty location or one that does not yet exist.
  3492. 2. *Generate Tarballs of the Source Git Repositories:* Edit your
  3493. ``local.conf`` configuration file as follows:
  3494. ::
  3495. DL_DIR = "/home/your-download-dir/"
  3496. BB_GENERATE_MIRROR_TARBALLS = "1"
  3497. During
  3498. the fetch process in the next step, BitBake gathers the source files
  3499. and creates tarballs in the directory pointed to by ``DL_DIR``. See
  3500. the
  3501. :term:`BB_GENERATE_MIRROR_TARBALLS`
  3502. variable for more information.
  3503. 3. *Populate Your Downloads Directory Without Building:* Use BitBake to
  3504. fetch your sources but inhibit the build:
  3505. ::
  3506. $ bitbake target --runonly=fetch
  3507. The downloads directory (i.e. ``${DL_DIR}``) now has
  3508. a "snapshot" of the source files in the form of tarballs, which can
  3509. be used for the build.
  3510. 4. *Optionally Remove Any Git or other SCM Subdirectories From the
  3511. Downloads Directory:* If you want, you can clean up your downloads
  3512. directory by removing any Git or other Source Control Management
  3513. (SCM) subdirectories such as ``${DL_DIR}/git2/*``. The tarballs
  3514. already contain these subdirectories.
  3515. Once your downloads directory has everything it needs regarding source
  3516. files, you can create your "own-mirror" and build your target.
  3517. Understand that you can use the files to build the target offline from
  3518. any machine and at any time.
  3519. Follow these steps to build your target using the files in the downloads
  3520. directory:
  3521. 1. *Using Local Files Only:* Inside your ``local.conf`` file, add the
  3522. :term:`SOURCE_MIRROR_URL`
  3523. variable, inherit the
  3524. :ref:`own-mirrors <ref-classes-own-mirrors>`
  3525. class, and use the
  3526. :term:`bitbake:BB_NO_NETWORK`
  3527. variable to your ``local.conf``.
  3528. ::
  3529. SOURCE_MIRROR_URL ?= "file:///home/your-download-dir/"
  3530. INHERIT += "own-mirrors"
  3531. BB_NO_NETWORK = "1"
  3532. The ``SOURCE_MIRROR_URL`` and ``own-mirror``
  3533. class set up the system to use the downloads directory as your "own
  3534. mirror". Using the ``BB_NO_NETWORK`` variable makes sure that
  3535. BitBake's fetching process in step 3 stays local, which means files
  3536. from your "own-mirror" are used.
  3537. 2. *Start With a Clean Build:* You can start with a clean build by
  3538. removing the
  3539. ``${``\ :term:`TMPDIR`\ ``}``
  3540. directory or using a new :term:`Build Directory`.
  3541. 3. *Build Your Target:* Use BitBake to build your target:
  3542. ::
  3543. $ bitbake target
  3544. The build completes using the known local "snapshot" of source
  3545. files from your mirror. The resulting tarballs for your "snapshot" of
  3546. source files are in the downloads directory.
  3547. .. note::
  3548. The offline build does not work if recipes attempt to find the
  3549. latest version of software by setting
  3550. :term:`SRCREV` to
  3551. ``${``\ :term:`AUTOREV`\ ``}``:
  3552. ::
  3553. SRCREV = "${AUTOREV}"
  3554. When a recipe sets ``SRCREV`` to
  3555. ``${AUTOREV}``, the build system accesses the network in an
  3556. attempt to determine the latest version of software from the SCM.
  3557. Typically, recipes that use ``AUTOREV`` are custom or modified
  3558. recipes. Recipes that reside in public repositories usually do not
  3559. use ``AUTOREV``.
  3560. If you do have recipes that use ``AUTOREV``, you can take steps to
  3561. still use the recipes in an offline build. Do the following:
  3562. 1. Use a configuration generated by enabling :ref:`build
  3563. history <dev-manual/common-tasks:maintaining build output quality>`.
  3564. 2. Use the ``buildhistory-collect-srcrevs`` command to collect the
  3565. stored ``SRCREV`` values from the build's history. For more
  3566. information on collecting these values, see the
  3567. ":ref:`dev-manual/common-tasks:build history package information`"
  3568. section.
  3569. 3. Once you have the correct source revisions, you can modify
  3570. those recipes to set ``SRCREV`` to specific versions of the
  3571. software.
  3572. Speeding Up a Build
  3573. ===================
  3574. Build time can be an issue. By default, the build system uses simple
  3575. controls to try and maximize build efficiency. In general, the default
  3576. settings for all the following variables result in the most efficient
  3577. build times when dealing with single socket systems (i.e. a single CPU).
  3578. If you have multiple CPUs, you might try increasing the default values
  3579. to gain more speed. See the descriptions in the glossary for each
  3580. variable for more information:
  3581. - :term:`BB_NUMBER_THREADS`:
  3582. The maximum number of threads BitBake simultaneously executes.
  3583. - :term:`bitbake:BB_NUMBER_PARSE_THREADS`:
  3584. The number of threads BitBake uses during parsing.
  3585. - :term:`PARALLEL_MAKE`: Extra
  3586. options passed to the ``make`` command during the
  3587. :ref:`ref-tasks-compile` task in
  3588. order to specify parallel compilation on the local build host.
  3589. - :term:`PARALLEL_MAKEINST`:
  3590. Extra options passed to the ``make`` command during the
  3591. :ref:`ref-tasks-install` task in
  3592. order to specify parallel installation on the local build host.
  3593. As mentioned, these variables all scale to the number of processor cores
  3594. available on the build system. For single socket systems, this
  3595. auto-scaling ensures that the build system fundamentally takes advantage
  3596. of potential parallel operations during the build based on the build
  3597. machine's capabilities.
  3598. Following are additional factors that can affect build speed:
  3599. - File system type: The file system type that the build is being
  3600. performed on can also influence performance. Using ``ext4`` is
  3601. recommended as compared to ``ext2`` and ``ext3`` due to ``ext4``
  3602. improved features such as extents.
  3603. - Disabling the updating of access time using ``noatime``: The
  3604. ``noatime`` mount option prevents the build system from updating file
  3605. and directory access times.
  3606. - Setting a longer commit: Using the "commit=" mount option increases
  3607. the interval in seconds between disk cache writes. Changing this
  3608. interval from the five second default to something longer increases
  3609. the risk of data loss but decreases the need to write to the disk,
  3610. thus increasing the build performance.
  3611. - Choosing the packaging backend: Of the available packaging backends,
  3612. IPK is the fastest. Additionally, selecting a singular packaging
  3613. backend also helps.
  3614. - Using ``tmpfs`` for :term:`TMPDIR`
  3615. as a temporary file system: While this can help speed up the build,
  3616. the benefits are limited due to the compiler using ``-pipe``. The
  3617. build system goes to some lengths to avoid ``sync()`` calls into the
  3618. file system on the principle that if there was a significant failure,
  3619. the :term:`Build Directory`
  3620. contents could easily be rebuilt.
  3621. - Inheriting the
  3622. :ref:`rm_work <ref-classes-rm-work>` class:
  3623. Inheriting this class has shown to speed up builds due to
  3624. significantly lower amounts of data stored in the data cache as well
  3625. as on disk. Inheriting this class also makes cleanup of
  3626. :term:`TMPDIR` faster, at the
  3627. expense of being easily able to dive into the source code. File
  3628. system maintainers have recommended that the fastest way to clean up
  3629. large numbers of files is to reformat partitions rather than delete
  3630. files due to the linear nature of partitions. This, of course,
  3631. assumes you structure the disk partitions and file systems in a way
  3632. that this is practical.
  3633. Aside from the previous list, you should keep some trade offs in mind
  3634. that can help you speed up the build:
  3635. - Remove items from
  3636. :term:`DISTRO_FEATURES`
  3637. that you might not need.
  3638. - Exclude debug symbols and other debug information: If you do not need
  3639. these symbols and other debug information, disabling the ``*-dbg``
  3640. package generation can speed up the build. You can disable this
  3641. generation by setting the
  3642. :term:`INHIBIT_PACKAGE_DEBUG_SPLIT`
  3643. variable to "1".
  3644. - Disable static library generation for recipes derived from
  3645. ``autoconf`` or ``libtool``: Following is an example showing how to
  3646. disable static libraries and still provide an override to handle
  3647. exceptions:
  3648. ::
  3649. STATICLIBCONF = "--disable-static"
  3650. STATICLIBCONF_sqlite3-native = ""
  3651. EXTRA_OECONF += "${STATICLIBCONF}"
  3652. .. note::
  3653. - Some recipes need static libraries in order to work correctly
  3654. (e.g. ``pseudo-native`` needs ``sqlite3-native``). Overrides,
  3655. as in the previous example, account for these kinds of
  3656. exceptions.
  3657. - Some packages have packaging code that assumes the presence of
  3658. the static libraries. If so, you might need to exclude them as
  3659. well.
  3660. Working With Libraries
  3661. ======================
  3662. Libraries are an integral part of your system. This section describes
  3663. some common practices you might find helpful when working with libraries
  3664. to build your system:
  3665. - :ref:`How to include static library files
  3666. <dev-manual/common-tasks:including static library files>`
  3667. - :ref:`How to use the Multilib feature to combine multiple versions of
  3668. library files into a single image
  3669. <dev-manual/common-tasks:combining multiple versions of library files into one image>`
  3670. - :ref:`How to install multiple versions of the same library in parallel on
  3671. the same system
  3672. <dev-manual/common-tasks:installing multiple versions of the same library>`
  3673. Including Static Library Files
  3674. ------------------------------
  3675. If you are building a library and the library offers static linking, you
  3676. can control which static library files (``*.a`` files) get included in
  3677. the built library.
  3678. The :term:`PACKAGES` and
  3679. :term:`FILES_* <FILES>` variables in the
  3680. ``meta/conf/bitbake.conf`` configuration file define how files installed
  3681. by the ``do_install`` task are packaged. By default, the ``PACKAGES``
  3682. variable includes ``${PN}-staticdev``, which represents all static
  3683. library files.
  3684. .. note::
  3685. Some previously released versions of the Yocto Project defined the
  3686. static library files through ``${PN}-dev``.
  3687. Following is part of the BitBake configuration file, where you can see
  3688. how the static library files are defined:
  3689. ::
  3690. PACKAGE_BEFORE_PN ?= ""
  3691. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  3692. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  3693. FILES = ""
  3694. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  3695. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  3696. ${base_bindir}/* ${base_sbindir}/* \
  3697. ${base_libdir}/*${SOLIBS} \
  3698. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  3699. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  3700. ${datadir}/pixmaps ${datadir}/applications \
  3701. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  3702. ${libdir}/bonobo/servers"
  3703. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  3704. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  3705. ${datadir}/gnome/help"
  3706. SECTION_${PN}-doc = "doc"
  3707. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  3708. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  3709. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  3710. ${datadir}/aclocal ${base_libdir}/*.o \
  3711. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  3712. SECTION_${PN}-dev = "devel"
  3713. ALLOW_EMPTY_${PN}-dev = "1"
  3714. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  3715. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  3716. SECTION_${PN}-staticdev = "devel"
  3717. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  3718. Combining Multiple Versions of Library Files into One Image
  3719. -----------------------------------------------------------
  3720. The build system offers the ability to build libraries with different
  3721. target optimizations or architecture formats and combine these together
  3722. into one system image. You can link different binaries in the image
  3723. against the different libraries as needed for specific use cases. This
  3724. feature is called "Multilib".
  3725. An example would be where you have most of a system compiled in 32-bit
  3726. mode using 32-bit libraries, but you have something large, like a
  3727. database engine, that needs to be a 64-bit application and uses 64-bit
  3728. libraries. Multilib allows you to get the best of both 32-bit and 64-bit
  3729. libraries.
  3730. While the Multilib feature is most commonly used for 32 and 64-bit
  3731. differences, the approach the build system uses facilitates different
  3732. target optimizations. You could compile some binaries to use one set of
  3733. libraries and other binaries to use a different set of libraries. The
  3734. libraries could differ in architecture, compiler options, or other
  3735. optimizations.
  3736. Several examples exist in the ``meta-skeleton`` layer found in the
  3737. :term:`Source Directory`:
  3738. - ``conf/multilib-example.conf`` configuration file
  3739. - ``conf/multilib-example2.conf`` configuration file
  3740. - ``recipes-multilib/images/core-image-multilib-example.bb`` recipe
  3741. Preparing to Use Multilib
  3742. ~~~~~~~~~~~~~~~~~~~~~~~~~
  3743. User-specific requirements drive the Multilib feature. Consequently,
  3744. there is no one "out-of-the-box" configuration that likely exists to
  3745. meet your needs.
  3746. In order to enable Multilib, you first need to ensure your recipe is
  3747. extended to support multiple libraries. Many standard recipes are
  3748. already extended and support multiple libraries. You can check in the
  3749. ``meta/conf/multilib.conf`` configuration file in the
  3750. :term:`Source Directory` to see how this is
  3751. done using the
  3752. :term:`BBCLASSEXTEND` variable.
  3753. Eventually, all recipes will be covered and this list will not be
  3754. needed.
  3755. For the most part, the Multilib class extension works automatically to
  3756. extend the package name from ``${PN}`` to ``${MLPREFIX}${PN}``, where
  3757. ``MLPREFIX`` is the particular multilib (e.g. "lib32-" or "lib64-").
  3758. Standard variables such as
  3759. :term:`DEPENDS`,
  3760. :term:`RDEPENDS`,
  3761. :term:`RPROVIDES`,
  3762. :term:`RRECOMMENDS`,
  3763. :term:`PACKAGES`, and
  3764. :term:`PACKAGES_DYNAMIC` are
  3765. automatically extended by the system. If you are extending any manual
  3766. code in the recipe, you can use the ``${MLPREFIX}`` variable to ensure
  3767. those names are extended correctly. This automatic extension code
  3768. resides in ``multilib.bbclass``.
  3769. Using Multilib
  3770. ~~~~~~~~~~~~~~
  3771. After you have set up the recipes, you need to define the actual
  3772. combination of multiple libraries you want to build. You accomplish this
  3773. through your ``local.conf`` configuration file in the
  3774. :term:`Build Directory`. An example
  3775. configuration would be as follows:
  3776. ::
  3777. MACHINE = "qemux86-64"
  3778. require conf/multilib.conf
  3779. MULTILIBS = "multilib:lib32"
  3780. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  3781. IMAGE_INSTALL_append = "lib32-glib-2.0"
  3782. This example enables an additional library named
  3783. ``lib32`` alongside the normal target packages. When combining these
  3784. "lib32" alternatives, the example uses "x86" for tuning. For information
  3785. on this particular tuning, see
  3786. ``meta/conf/machine/include/ia32/arch-ia32.inc``.
  3787. The example then includes ``lib32-glib-2.0`` in all the images, which
  3788. illustrates one method of including a multiple library dependency. You
  3789. can use a normal image build to include this dependency, for example:
  3790. ::
  3791. $ bitbake core-image-sato
  3792. You can also build Multilib packages
  3793. specifically with a command like this:
  3794. ::
  3795. $ bitbake lib32-glib-2.0
  3796. Additional Implementation Details
  3797. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3798. Generic implementation details as well as details that are specific to
  3799. package management systems exist. Following are implementation details
  3800. that exist regardless of the package management system:
  3801. - The typical convention used for the class extension code as used by
  3802. Multilib assumes that all package names specified in
  3803. :term:`PACKAGES` that contain
  3804. ``${PN}`` have ``${PN}`` at the start of the name. When that
  3805. convention is not followed and ``${PN}`` appears at the middle or the
  3806. end of a name, problems occur.
  3807. - The :term:`TARGET_VENDOR`
  3808. value under Multilib will be extended to "-vendormlmultilib" (e.g.
  3809. "-pokymllib32" for a "lib32" Multilib with Poky). The reason for this
  3810. slightly unwieldy contraction is that any "-" characters in the
  3811. vendor string presently break Autoconf's ``config.sub``, and other
  3812. separators are problematic for different reasons.
  3813. For the RPM Package Management System, the following implementation
  3814. details exist:
  3815. - A unique architecture is defined for the Multilib packages, along
  3816. with creating a unique deploy folder under ``tmp/deploy/rpm`` in the
  3817. :term:`Build Directory`. For
  3818. example, consider ``lib32`` in a ``qemux86-64`` image. The possible
  3819. architectures in the system are "all", "qemux86_64",
  3820. "lib32_qemux86_64", and "lib32_x86".
  3821. - The ``${MLPREFIX}`` variable is stripped from ``${PN}`` during RPM
  3822. packaging. The naming for a normal RPM package and a Multilib RPM
  3823. package in a ``qemux86-64`` system resolves to something similar to
  3824. ``bash-4.1-r2.x86_64.rpm`` and ``bash-4.1.r2.lib32_x86.rpm``,
  3825. respectively.
  3826. - When installing a Multilib image, the RPM backend first installs the
  3827. base image and then installs the Multilib libraries.
  3828. - The build system relies on RPM to resolve the identical files in the
  3829. two (or more) Multilib packages.
  3830. For the IPK Package Management System, the following implementation
  3831. details exist:
  3832. - The ``${MLPREFIX}`` is not stripped from ``${PN}`` during IPK
  3833. packaging. The naming for a normal RPM package and a Multilib IPK
  3834. package in a ``qemux86-64`` system resolves to something like
  3835. ``bash_4.1-r2.x86_64.ipk`` and ``lib32-bash_4.1-rw_x86.ipk``,
  3836. respectively.
  3837. - The IPK deploy folder is not modified with ``${MLPREFIX}`` because
  3838. packages with and without the Multilib feature can exist in the same
  3839. folder due to the ``${PN}`` differences.
  3840. - IPK defines a sanity check for Multilib installation using certain
  3841. rules for file comparison, overridden, etc.
  3842. Installing Multiple Versions of the Same Library
  3843. ------------------------------------------------
  3844. Situations can exist where you need to install and use multiple versions
  3845. of the same library on the same system at the same time. These
  3846. situations almost always exist when a library API changes and you have
  3847. multiple pieces of software that depend on the separate versions of the
  3848. library. To accommodate these situations, you can install multiple
  3849. versions of the same library in parallel on the same system.
  3850. The process is straightforward as long as the libraries use proper
  3851. versioning. With properly versioned libraries, all you need to do to
  3852. individually specify the libraries is create separate, appropriately
  3853. named recipes where the :term:`PN` part of
  3854. the name includes a portion that differentiates each library version
  3855. (e.g. the major part of the version number). Thus, instead of having a
  3856. single recipe that loads one version of a library (e.g. ``clutter``),
  3857. you provide multiple recipes that result in different versions of the
  3858. libraries you want. As an example, the following two recipes would allow
  3859. the two separate versions of the ``clutter`` library to co-exist on the
  3860. same system:
  3861. .. code-block:: none
  3862. clutter-1.6_1.6.20.bb
  3863. clutter-1.8_1.8.4.bb
  3864. Additionally, if
  3865. you have other recipes that depend on a given library, you need to use
  3866. the :term:`DEPENDS` variable to
  3867. create the dependency. Continuing with the same example, if you want to
  3868. have a recipe depend on the 1.8 version of the ``clutter`` library, use
  3869. the following in your recipe:
  3870. ::
  3871. DEPENDS = "clutter-1.8"
  3872. Using x32 psABI
  3873. ===============
  3874. x32 processor-specific Application Binary Interface (`x32
  3875. psABI <https://software.intel.com/en-us/node/628948>`__) is a native
  3876. 32-bit processor-specific ABI for Intel 64 (x86-64) architectures. An
  3877. ABI defines the calling conventions between functions in a processing
  3878. environment. The interface determines what registers are used and what
  3879. the sizes are for various C data types.
  3880. Some processing environments prefer using 32-bit applications even when
  3881. running on Intel 64-bit platforms. Consider the i386 psABI, which is a
  3882. very old 32-bit ABI for Intel 64-bit platforms. The i386 psABI does not
  3883. provide efficient use and access of the Intel 64-bit processor
  3884. resources, leaving the system underutilized. Now consider the x86_64
  3885. psABI. This ABI is newer and uses 64-bits for data sizes and program
  3886. pointers. The extra bits increase the footprint size of the programs,
  3887. libraries, and also increases the memory and file system size
  3888. requirements. Executing under the x32 psABI enables user programs to
  3889. utilize CPU and system resources more efficiently while keeping the
  3890. memory footprint of the applications low. Extra bits are used for
  3891. registers but not for addressing mechanisms.
  3892. The Yocto Project supports the final specifications of x32 psABI as
  3893. follows:
  3894. - You can create packages and images in x32 psABI format on x86_64
  3895. architecture targets.
  3896. - You can successfully build recipes with the x32 toolchain.
  3897. - You can create and boot ``core-image-minimal`` and
  3898. ``core-image-sato`` images.
  3899. - RPM Package Manager (RPM) support exists for x32 binaries.
  3900. - Support for large images exists.
  3901. To use the x32 psABI, you need to edit your ``conf/local.conf``
  3902. configuration file as follows:
  3903. ::
  3904. MACHINE = "qemux86-64"
  3905. DEFAULTTUNE = "x86-64-x32"
  3906. baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE') \
  3907. or 'INVALID')) or 'lib'}"
  3908. Once you have set
  3909. up your configuration file, use BitBake to build an image that supports
  3910. the x32 psABI. Here is an example:
  3911. ::
  3912. $ bitbake core-image-sato
  3913. Enabling GObject Introspection Support
  3914. ======================================
  3915. `GObject
  3916. introspection <https://wiki.gnome.org/Projects/GObjectIntrospection>`__
  3917. is the standard mechanism for accessing GObject-based software from
  3918. runtime environments. GObject is a feature of the GLib library that
  3919. provides an object framework for the GNOME desktop and related software.
  3920. GObject Introspection adds information to GObject that allows objects
  3921. created within it to be represented across different programming
  3922. languages. If you want to construct GStreamer pipelines using Python, or
  3923. control UPnP infrastructure using Javascript and GUPnP, GObject
  3924. introspection is the only way to do it.
  3925. This section describes the Yocto Project support for generating and
  3926. packaging GObject introspection data. GObject introspection data is a
  3927. description of the API provided by libraries built on top of GLib
  3928. framework, and, in particular, that framework's GObject mechanism.
  3929. GObject Introspection Repository (GIR) files go to ``-dev`` packages,
  3930. ``typelib`` files go to main packages as they are packaged together with
  3931. libraries that are introspected.
  3932. The data is generated when building such a library, by linking the
  3933. library with a small executable binary that asks the library to describe
  3934. itself, and then executing the binary and processing its output.
  3935. Generating this data in a cross-compilation environment is difficult
  3936. because the library is produced for the target architecture, but its
  3937. code needs to be executed on the build host. This problem is solved with
  3938. the OpenEmbedded build system by running the code through QEMU, which
  3939. allows precisely that. Unfortunately, QEMU does not always work
  3940. perfectly as mentioned in the ":ref:`dev-manual/common-tasks:known issues`"
  3941. section.
  3942. Enabling the Generation of Introspection Data
  3943. ---------------------------------------------
  3944. Enabling the generation of introspection data (GIR files) in your
  3945. library package involves the following:
  3946. 1. Inherit the
  3947. :ref:`gobject-introspection <ref-classes-gobject-introspection>`
  3948. class.
  3949. 2. Make sure introspection is not disabled anywhere in the recipe or
  3950. from anything the recipe includes. Also, make sure that
  3951. "gobject-introspection-data" is not in
  3952. :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`
  3953. and that "qemu-usermode" is not in
  3954. :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`.
  3955. If either of these conditions exist, nothing will happen.
  3956. 3. Try to build the recipe. If you encounter build errors that look like
  3957. something is unable to find ``.so`` libraries, check where these
  3958. libraries are located in the source tree and add the following to the
  3959. recipe:
  3960. ::
  3961. GIR_EXTRA_LIBS_PATH = "${B}/something/.libs"
  3962. .. note::
  3963. See recipes in the ``oe-core`` repository that use that
  3964. ``GIR_EXTRA_LIBS_PATH`` variable as an example.
  3965. 4. Look for any other errors, which probably mean that introspection
  3966. support in a package is not entirely standard, and thus breaks down
  3967. in a cross-compilation environment. For such cases, custom-made fixes
  3968. are needed. A good place to ask and receive help in these cases is
  3969. the :ref:`Yocto Project mailing
  3970. lists <resources-mailinglist>`.
  3971. .. note::
  3972. Using a library that no longer builds against the latest Yocto
  3973. Project release and prints introspection related errors is a good
  3974. candidate for the previous procedure.
  3975. Disabling the Generation of Introspection Data
  3976. ----------------------------------------------
  3977. You might find that you do not want to generate introspection data. Or,
  3978. perhaps QEMU does not work on your build host and target architecture
  3979. combination. If so, you can use either of the following methods to
  3980. disable GIR file generations:
  3981. - Add the following to your distro configuration:
  3982. ::
  3983. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  3984. Adding this statement disables generating introspection data using
  3985. QEMU but will still enable building introspection tools and libraries
  3986. (i.e. building them does not require the use of QEMU).
  3987. - Add the following to your machine configuration:
  3988. ::
  3989. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  3990. Adding this statement disables the use of QEMU when building packages for your
  3991. machine. Currently, this feature is used only by introspection
  3992. recipes and has the same effect as the previously described option.
  3993. .. note::
  3994. Future releases of the Yocto Project might have other features
  3995. affected by this option.
  3996. If you disable introspection data, you can still obtain it through other
  3997. means such as copying the data from a suitable sysroot, or by generating
  3998. it on the target hardware. The OpenEmbedded build system does not
  3999. currently provide specific support for these techniques.
  4000. Testing that Introspection Works in an Image
  4001. --------------------------------------------
  4002. Use the following procedure to test if generating introspection data is
  4003. working in an image:
  4004. 1. Make sure that "gobject-introspection-data" is not in
  4005. :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`
  4006. and that "qemu-usermode" is not in
  4007. :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`.
  4008. 2. Build ``core-image-sato``.
  4009. 3. Launch a Terminal and then start Python in the terminal.
  4010. 4. Enter the following in the terminal:
  4011. ::
  4012. >>> from gi.repository import GLib
  4013. >>> GLib.get_host_name()
  4014. 5. For something a little more advanced, enter the following see:
  4015. https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
  4016. Known Issues
  4017. ------------
  4018. The following know issues exist for GObject Introspection Support:
  4019. - ``qemu-ppc64`` immediately crashes. Consequently, you cannot build
  4020. introspection data on that architecture.
  4021. - x32 is not supported by QEMU. Consequently, introspection data is
  4022. disabled.
  4023. - musl causes transient GLib binaries to crash on assertion failures.
  4024. Consequently, generating introspection data is disabled.
  4025. - Because QEMU is not able to run the binaries correctly, introspection
  4026. is disabled for some specific packages under specific architectures
  4027. (e.g. ``gcr``, ``libsecret``, and ``webkit``).
  4028. - QEMU usermode might not work properly when running 64-bit binaries
  4029. under 32-bit host machines. In particular, "qemumips64" is known to
  4030. not work under i686.
  4031. Optionally Using an External Toolchain
  4032. ======================================
  4033. You might want to use an external toolchain as part of your development.
  4034. If this is the case, the fundamental steps you need to accomplish are as
  4035. follows:
  4036. - Understand where the installed toolchain resides. For cases where you
  4037. need to build the external toolchain, you would need to take separate
  4038. steps to build and install the toolchain.
  4039. - Make sure you add the layer that contains the toolchain to your
  4040. ``bblayers.conf`` file through the
  4041. :term:`BBLAYERS` variable.
  4042. - Set the ``EXTERNAL_TOOLCHAIN`` variable in your ``local.conf`` file
  4043. to the location in which you installed the toolchain.
  4044. A good example of an external toolchain used with the Yocto Project is
  4045. Mentor Graphics Sourcery G++ Toolchain. You can see information on how
  4046. to use that particular layer in the ``README`` file at
  4047. https://github.com/MentorEmbedded/meta-sourcery/. You can find
  4048. further information by reading about the
  4049. :term:`TCMODE` variable in the Yocto
  4050. Project Reference Manual's variable glossary.
  4051. Creating Partitioned Images Using Wic
  4052. =====================================
  4053. Creating an image for a particular hardware target using the
  4054. OpenEmbedded build system does not necessarily mean you can boot that
  4055. image as is on your device. Physical devices accept and boot images in
  4056. various ways depending on the specifics of the device. Usually,
  4057. information about the hardware can tell you what image format the device
  4058. requires. Should your device require multiple partitions on an SD card,
  4059. flash, or an HDD, you can use the OpenEmbedded Image Creator, Wic, to
  4060. create the properly partitioned image.
  4061. The ``wic`` command generates partitioned images from existing
  4062. OpenEmbedded build artifacts. Image generation is driven by partitioning
  4063. commands contained in an Openembedded kickstart file (``.wks``)
  4064. specified either directly on the command line or as one of a selection
  4065. of canned kickstart files as shown with the ``wic list images`` command
  4066. in the
  4067. ":ref:`dev-manual/common-tasks:generate an image using an existing kickstart file`"
  4068. section. When you apply the command to a given set of build artifacts, the
  4069. result is an image or set of images that can be directly written onto media and
  4070. used on a particular system.
  4071. .. note::
  4072. For a kickstart file reference, see the
  4073. ":ref:`ref-manual/kickstart:openembedded kickstart (\`\`.wks\`\`) reference`"
  4074. Chapter in the Yocto Project Reference Manual.
  4075. The ``wic`` command and the infrastructure it is based on is by
  4076. definition incomplete. The purpose of the command is to allow the
  4077. generation of customized images, and as such, was designed to be
  4078. completely extensible through a plugin interface. See the
  4079. ":ref:`dev-manual/common-tasks:using the wic plugin interface`" section
  4080. for information on these plugins.
  4081. This section provides some background information on Wic, describes what
  4082. you need to have in place to run the tool, provides instruction on how
  4083. to use the Wic utility, provides information on using the Wic plugins
  4084. interface, and provides several examples that show how to use Wic.
  4085. Background
  4086. ----------
  4087. This section provides some background on the Wic utility. While none of
  4088. this information is required to use Wic, you might find it interesting.
  4089. - The name "Wic" is derived from OpenEmbedded Image Creator (oeic). The
  4090. "oe" diphthong in "oeic" was promoted to the letter "w", because
  4091. "oeic" is both difficult to remember and to pronounce.
  4092. - Wic is loosely based on the Meego Image Creator (``mic``) framework.
  4093. The Wic implementation has been heavily modified to make direct use
  4094. of OpenEmbedded build artifacts instead of package installation and
  4095. configuration, which are already incorporated within the OpenEmbedded
  4096. artifacts.
  4097. - Wic is a completely independent standalone utility that initially
  4098. provides easier-to-use and more flexible replacements for an existing
  4099. functionality in OE-Core's
  4100. :ref:`image-live <ref-classes-image-live>`
  4101. class. The difference between Wic and those examples is that with Wic
  4102. the functionality of those scripts is implemented by a
  4103. general-purpose partitioning language, which is based on Redhat
  4104. kickstart syntax.
  4105. Requirements
  4106. ------------
  4107. In order to use the Wic utility with the OpenEmbedded Build system, your
  4108. system needs to meet the following requirements:
  4109. - The Linux distribution on your development host must support the
  4110. Yocto Project. See the ":ref:`detailed-supported-distros`"
  4111. section in the Yocto Project Reference Manual for the list of
  4112. distributions that support the Yocto Project.
  4113. - The standard system utilities, such as ``cp``, must be installed on
  4114. your development host system.
  4115. - You must have sourced the build environment setup script (i.e.
  4116. :ref:`structure-core-script`) found in the
  4117. :term:`Build Directory`.
  4118. - You need to have the build artifacts already available, which
  4119. typically means that you must have already created an image using the
  4120. Openembedded build system (e.g. ``core-image-minimal``). While it
  4121. might seem redundant to generate an image in order to create an image
  4122. using Wic, the current version of Wic requires the artifacts in the
  4123. form generated by the OpenEmbedded build system.
  4124. - You must build several native tools, which are built to run on the
  4125. build system:
  4126. ::
  4127. $ bitbake parted-native dosfstools-native mtools-native
  4128. - Include "wic" as part of the
  4129. :term:`IMAGE_FSTYPES`
  4130. variable.
  4131. - Include the name of the :ref:`wic kickstart file <openembedded-kickstart-wks-reference>`
  4132. as part of the :term:`WKS_FILE` variable
  4133. Getting Help
  4134. ------------
  4135. You can get general help for the ``wic`` command by entering the ``wic``
  4136. command by itself or by entering the command with a help argument as
  4137. follows:
  4138. ::
  4139. $ wic -h
  4140. $ wic --help
  4141. $ wic help
  4142. Currently, Wic supports seven commands: ``cp``, ``create``, ``help``,
  4143. ``list``, ``ls``, ``rm``, and ``write``. You can get help for all these
  4144. commands except "help" by using the following form:
  4145. ::
  4146. $ wic help command
  4147. For example, the following command returns help for the ``write``
  4148. command:
  4149. ::
  4150. $ wic help write
  4151. Wic supports help for three topics: ``overview``, ``plugins``, and
  4152. ``kickstart``. You can get help for any topic using the following form:
  4153. ::
  4154. $ wic help topic
  4155. For example, the following returns overview help for Wic:
  4156. ::
  4157. $ wic help overview
  4158. One additional level of help exists for Wic. You can get help on
  4159. individual images through the ``list`` command. You can use the ``list``
  4160. command to return the available Wic images as follows:
  4161. ::
  4162. $ wic list images
  4163. genericx86 Create an EFI disk image for genericx86*
  4164. beaglebone-yocto Create SD card image for Beaglebone
  4165. edgerouter Create SD card image for Edgerouter
  4166. qemux86-directdisk Create a QEMU machine 'pcbios' direct disk image
  4167. directdisk-gpt Create a 'pcbios' direct disk image
  4168. mkefidisk Create an EFI disk image
  4169. directdisk Create a 'pcbios' direct disk image
  4170. systemd-bootdisk Create an EFI disk image with systemd-boot
  4171. mkhybridiso Create a hybrid ISO image
  4172. sdimage-bootpart Create SD card image with a boot partition
  4173. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  4174. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  4175. Once you know the list of available
  4176. Wic images, you can use ``help`` with the command to get help on a
  4177. particular image. For example, the following command returns help on the
  4178. "beaglebone-yocto" image:
  4179. ::
  4180. $ wic list beaglebone-yocto help
  4181. Creates a partitioned SD card image for Beaglebone.
  4182. Boot files are located in the first vfat partition.
  4183. Operational Modes
  4184. -----------------
  4185. You can use Wic in two different modes, depending on how much control
  4186. you need for specifying the Openembedded build artifacts that are used
  4187. for creating the image: Raw and Cooked:
  4188. - *Raw Mode:* You explicitly specify build artifacts through Wic
  4189. command-line arguments.
  4190. - *Cooked Mode:* The current
  4191. :term:`MACHINE` setting and image
  4192. name are used to automatically locate and provide the build
  4193. artifacts. You just supply a kickstart file and the name of the image
  4194. from which to use artifacts.
  4195. Regardless of the mode you use, you need to have the build artifacts
  4196. ready and available.
  4197. Raw Mode
  4198. ~~~~~~~~
  4199. Running Wic in raw mode allows you to specify all the partitions through
  4200. the ``wic`` command line. The primary use for raw mode is if you have
  4201. built your kernel outside of the Yocto Project
  4202. :term:`Build Directory`. In other words, you
  4203. can point to arbitrary kernel, root filesystem locations, and so forth.
  4204. Contrast this behavior with cooked mode where Wic looks in the Build
  4205. Directory (e.g. ``tmp/deploy/images/``\ machine).
  4206. The general form of the ``wic`` command in raw mode is:
  4207. ::
  4208. $ wic create wks_file options ...
  4209. Where:
  4210. wks_file:
  4211. An OpenEmbedded kickstart file. You can provide
  4212. your own custom file or use a file from a set of
  4213. existing files as described by further options.
  4214. optional arguments:
  4215. -h, --help show this help message and exit
  4216. -o OUTDIR, --outdir OUTDIR
  4217. name of directory to create image in
  4218. -e IMAGE_NAME, --image-name IMAGE_NAME
  4219. name of the image to use the artifacts from e.g. core-
  4220. image-sato
  4221. -r ROOTFS_DIR, --rootfs-dir ROOTFS_DIR
  4222. path to the /rootfs dir to use as the .wks rootfs
  4223. source
  4224. -b BOOTIMG_DIR, --bootimg-dir BOOTIMG_DIR
  4225. path to the dir containing the boot artifacts (e.g.
  4226. /EFI or /syslinux dirs) to use as the .wks bootimg
  4227. source
  4228. -k KERNEL_DIR, --kernel-dir KERNEL_DIR
  4229. path to the dir containing the kernel to use in the
  4230. .wks bootimg
  4231. -n NATIVE_SYSROOT, --native-sysroot NATIVE_SYSROOT
  4232. path to the native sysroot containing the tools to use
  4233. to build the image
  4234. -s, --skip-build-check
  4235. skip the build check
  4236. -f, --build-rootfs build rootfs
  4237. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  4238. compress image with specified compressor
  4239. -m, --bmap generate .bmap
  4240. --no-fstab-update Do not change fstab file.
  4241. -v VARS_DIR, --vars VARS_DIR
  4242. directory with <image>.env files that store bitbake
  4243. variables
  4244. -D, --debug output debug information
  4245. .. note::
  4246. You do not need root privileges to run Wic. In fact, you should not
  4247. run as root when using the utility.
  4248. Cooked Mode
  4249. ~~~~~~~~~~~
  4250. Running Wic in cooked mode leverages off artifacts in the Build
  4251. Directory. In other words, you do not have to specify kernel or root
  4252. filesystem locations as part of the command. All you need to provide is
  4253. a kickstart file and the name of the image from which to use artifacts
  4254. by using the "-e" option. Wic looks in the Build Directory (e.g.
  4255. ``tmp/deploy/images/``\ machine) for artifacts.
  4256. The general form of the ``wic`` command using Cooked Mode is as follows:
  4257. ::
  4258. $ wic create wks_file -e IMAGE_NAME
  4259. Where:
  4260. wks_file:
  4261. An OpenEmbedded kickstart file. You can provide
  4262. your own custom file or use a file from a set of
  4263. existing files provided with the Yocto Project
  4264. release.
  4265. required argument:
  4266. -e IMAGE_NAME, --image-name IMAGE_NAME
  4267. name of the image to use the artifacts from e.g. core-
  4268. image-sato
  4269. Using an Existing Kickstart File
  4270. --------------------------------
  4271. If you do not want to create your own kickstart file, you can use an
  4272. existing file provided by the Wic installation. As shipped, kickstart
  4273. files can be found in the :ref:`overview-manual/development-environment:yocto project source repositories` in the
  4274. following two locations:
  4275. ::
  4276. poky/meta-yocto-bsp/wic
  4277. poky/scripts/lib/wic/canned-wks
  4278. Use the following command to list the available kickstart files:
  4279. ::
  4280. $ wic list images
  4281. genericx86 Create an EFI disk image for genericx86*
  4282. beaglebone-yocto Create SD card image for Beaglebone
  4283. edgerouter Create SD card image for Edgerouter
  4284. qemux86-directdisk Create a QEMU machine 'pcbios' direct disk image
  4285. directdisk-gpt Create a 'pcbios' direct disk image
  4286. mkefidisk Create an EFI disk image
  4287. directdisk Create a 'pcbios' direct disk image
  4288. systemd-bootdisk Create an EFI disk image with systemd-boot
  4289. mkhybridiso Create a hybrid ISO image
  4290. sdimage-bootpart Create SD card image with a boot partition
  4291. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  4292. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  4293. When you use an existing file, you
  4294. do not have to use the ``.wks`` extension. Here is an example in Raw
  4295. Mode that uses the ``directdisk`` file:
  4296. ::
  4297. $ wic create directdisk -r rootfs_dir -b bootimg_dir \
  4298. -k kernel_dir -n native_sysroot
  4299. Here are the actual partition language commands used in the
  4300. ``genericx86.wks`` file to generate an image:
  4301. ::
  4302. # short-description: Create an EFI disk image for genericx86*
  4303. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  4304. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  4305. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  4306. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  4307. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  4308. Using the Wic Plugin Interface
  4309. ------------------------------
  4310. You can extend and specialize Wic functionality by using Wic plugins.
  4311. This section explains the Wic plugin interface.
  4312. .. note::
  4313. Wic plugins consist of "source" and "imager" plugins. Imager plugins
  4314. are beyond the scope of this section.
  4315. Source plugins provide a mechanism to customize partition content during
  4316. the Wic image generation process. You can use source plugins to map
  4317. values that you specify using ``--source`` commands in kickstart files
  4318. (i.e. ``*.wks``) to a plugin implementation used to populate a given
  4319. partition.
  4320. .. note::
  4321. If you use plugins that have build-time dependencies (e.g. native
  4322. tools, bootloaders, and so forth) when building a Wic image, you need
  4323. to specify those dependencies using the :term:`WKS_FILE_DEPENDS`
  4324. variable.
  4325. Source plugins are subclasses defined in plugin files. As shipped, the
  4326. Yocto Project provides several plugin files. You can see the source
  4327. plugin files that ship with the Yocto Project
  4328. :yocto_git:`here </poky/tree/scripts/lib/wic/plugins/source>`.
  4329. Each of these plugin files contains source plugins that are designed to
  4330. populate a specific Wic image partition.
  4331. Source plugins are subclasses of the ``SourcePlugin`` class, which is
  4332. defined in the ``poky/scripts/lib/wic/pluginbase.py`` file. For example,
  4333. the ``BootimgEFIPlugin`` source plugin found in the ``bootimg-efi.py``
  4334. file is a subclass of the ``SourcePlugin`` class, which is found in the
  4335. ``pluginbase.py`` file.
  4336. You can also implement source plugins in a layer outside of the Source
  4337. Repositories (external layer). To do so, be sure that your plugin files
  4338. are located in a directory whose path is
  4339. ``scripts/lib/wic/plugins/source/`` within your external layer. When the
  4340. plugin files are located there, the source plugins they contain are made
  4341. available to Wic.
  4342. When the Wic implementation needs to invoke a partition-specific
  4343. implementation, it looks for the plugin with the same name as the
  4344. ``--source`` parameter used in the kickstart file given to that
  4345. partition. For example, if the partition is set up using the following
  4346. command in a kickstart file:
  4347. ::
  4348. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  4349. The methods defined as class
  4350. members of the matching source plugin (i.e. ``bootimg-pcbios``) in the
  4351. ``bootimg-pcbios.py`` plugin file are used.
  4352. To be more concrete, here is the corresponding plugin definition from
  4353. the ``bootimg-pcbios.py`` file for the previous command along with an
  4354. example method called by the Wic implementation when it needs to prepare
  4355. a partition using an implementation-specific function:
  4356. ::
  4357. .
  4358. .
  4359. .
  4360. class BootimgPcbiosPlugin(SourcePlugin):
  4361. """
  4362. Create MBR boot partition and install syslinux on it.
  4363. """
  4364. name = 'bootimg-pcbios'
  4365. .
  4366. .
  4367. .
  4368. @classmethod
  4369. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  4370. oe_builddir, bootimg_dir, kernel_dir,
  4371. rootfs_dir, native_sysroot):
  4372. """
  4373. Called to do the actual content population for a partition i.e. it
  4374. 'prepares' the partition to be incorporated into the image.
  4375. In this case, prepare content for legacy bios boot partition.
  4376. """
  4377. .
  4378. .
  4379. .
  4380. If a
  4381. subclass (plugin) itself does not implement a particular function, Wic
  4382. locates and uses the default version in the superclass. It is for this
  4383. reason that all source plugins are derived from the ``SourcePlugin``
  4384. class.
  4385. The ``SourcePlugin`` class defined in the ``pluginbase.py`` file defines
  4386. a set of methods that source plugins can implement or override. Any
  4387. plugins (subclass of ``SourcePlugin``) that do not implement a
  4388. particular method inherit the implementation of the method from the
  4389. ``SourcePlugin`` class. For more information, see the ``SourcePlugin``
  4390. class in the ``pluginbase.py`` file for details:
  4391. The following list describes the methods implemented in the
  4392. ``SourcePlugin`` class:
  4393. - ``do_prepare_partition()``: Called to populate a partition with
  4394. actual content. In other words, the method prepares the final
  4395. partition image that is incorporated into the disk image.
  4396. - ``do_configure_partition()``: Called before
  4397. ``do_prepare_partition()`` to create custom configuration files for a
  4398. partition (e.g. syslinux or grub configuration files).
  4399. - ``do_install_disk()``: Called after all partitions have been
  4400. prepared and assembled into a disk image. This method provides a hook
  4401. to allow finalization of a disk image (e.g. writing an MBR).
  4402. - ``do_stage_partition()``: Special content-staging hook called
  4403. before ``do_prepare_partition()``. This method is normally empty.
  4404. Typically, a partition just uses the passed-in parameters (e.g. the
  4405. unmodified value of ``bootimg_dir``). However, in some cases, things
  4406. might need to be more tailored. As an example, certain files might
  4407. additionally need to be taken from ``bootimg_dir + /boot``. This hook
  4408. allows those files to be staged in a customized fashion.
  4409. .. note::
  4410. ``get_bitbake_var()`` allows you to access non-standard variables that
  4411. you might want to use for this behavior.
  4412. You can extend the source plugin mechanism. To add more hooks, create
  4413. more source plugin methods within ``SourcePlugin`` and the corresponding
  4414. derived subclasses. The code that calls the plugin methods uses the
  4415. ``plugin.get_source_plugin_methods()`` function to find the method or
  4416. methods needed by the call. Retrieval of those methods is accomplished
  4417. by filling up a dict with keys that contain the method names of
  4418. interest. On success, these will be filled in with the actual methods.
  4419. See the Wic implementation for examples and details.
  4420. Wic Examples
  4421. ------------
  4422. This section provides several examples that show how to use the Wic
  4423. utility. All the examples assume the list of requirements in the
  4424. ":ref:`dev-manual/common-tasks:requirements`" section have been met. The
  4425. examples assume the previously generated image is
  4426. ``core-image-minimal``.
  4427. Generate an Image using an Existing Kickstart File
  4428. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4429. This example runs in Cooked Mode and uses the ``mkefidisk`` kickstart
  4430. file:
  4431. ::
  4432. $ wic create mkefidisk -e core-image-minimal
  4433. INFO: Building wic-tools...
  4434. .
  4435. .
  4436. .
  4437. INFO: The new image(s) can be found here:
  4438. ./mkefidisk-201804191017-sda.direct
  4439. The following build artifacts were used to create the image(s):
  4440. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  4441. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  4442. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  4443. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4444. INFO: The image(s) were created using OE kickstart file:
  4445. /home/stephano/build/master/openembedded-core/scripts/lib/wic/canned-wks/mkefidisk.wks
  4446. The previous example shows the easiest way to create an image by running
  4447. in cooked mode and supplying a kickstart file and the "-e" option to
  4448. point to the existing build artifacts. Your ``local.conf`` file needs to
  4449. have the :term:`MACHINE` variable set
  4450. to the machine you are using, which is "qemux86" in this example.
  4451. Once the image builds, the output provides image location, artifact use,
  4452. and kickstart file information.
  4453. .. note::
  4454. You should always verify the details provided in the output to make
  4455. sure that the image was indeed created exactly as expected.
  4456. Continuing with the example, you can now write the image from the Build
  4457. Directory onto a USB stick, or whatever media for which you built your
  4458. image, and boot from the media. You can write the image by using
  4459. ``bmaptool`` or ``dd``:
  4460. ::
  4461. $ oe-run-native bmaptool copy mkefidisk-201804191017-sda.direct /dev/sdX
  4462. or ::
  4463. $ sudo dd if=mkefidisk-201804191017-sda.direct of=/dev/sdX
  4464. .. note::
  4465. For more information on how to use the ``bmaptool``
  4466. to flash a device with an image, see the
  4467. ":ref:`dev-manual/common-tasks:flashing images using \`\`bmaptool\`\``"
  4468. section.
  4469. Using a Modified Kickstart File
  4470. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4471. Because partitioned image creation is driven by the kickstart file, it
  4472. is easy to affect image creation by changing the parameters in the file.
  4473. This next example demonstrates that through modification of the
  4474. ``directdisk-gpt`` kickstart file.
  4475. As mentioned earlier, you can use the command ``wic list images`` to
  4476. show the list of existing kickstart files. The directory in which the
  4477. ``directdisk-gpt.wks`` file resides is
  4478. ``scripts/lib/image/canned-wks/``, which is located in the
  4479. :term:`Source Directory` (e.g. ``poky``).
  4480. Because available files reside in this directory, you can create and add
  4481. your own custom files to the directory. Subsequent use of the
  4482. ``wic list images`` command would then include your kickstart files.
  4483. In this example, the existing ``directdisk-gpt`` file already does most
  4484. of what is needed. However, for the hardware in this example, the image
  4485. will need to boot from ``sdb`` instead of ``sda``, which is what the
  4486. ``directdisk-gpt`` kickstart file uses.
  4487. The example begins by making a copy of the ``directdisk-gpt.wks`` file
  4488. in the ``scripts/lib/image/canned-wks`` directory and then by changing
  4489. the lines that specify the target disk from which to boot.
  4490. ::
  4491. $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  4492. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  4493. Next, the example modifies the ``directdisksdb-gpt.wks`` file and
  4494. changes all instances of "``--ondisk sda``" to "``--ondisk sdb``". The
  4495. example changes the following two lines and leaves the remaining lines
  4496. untouched:
  4497. ::
  4498. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  4499. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  4500. Once the lines are changed, the
  4501. example generates the ``directdisksdb-gpt`` image. The command points
  4502. the process at the ``core-image-minimal`` artifacts for the Next Unit of
  4503. Computing (nuc) :term:`MACHINE` the
  4504. ``local.conf``.
  4505. ::
  4506. $ wic create directdisksdb-gpt -e core-image-minimal
  4507. INFO: Building wic-tools...
  4508. .
  4509. .
  4510. .
  4511. Initialising tasks: 100% |#######################################| Time: 0:00:01
  4512. NOTE: Executing SetScene Tasks
  4513. NOTE: Executing RunQueue Tasks
  4514. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  4515. INFO: Creating image(s)...
  4516. INFO: The new image(s) can be found here:
  4517. ./directdisksdb-gpt-201710090938-sdb.direct
  4518. The following build artifacts were used to create the image(s):
  4519. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  4520. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  4521. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  4522. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4523. INFO: The image(s) were created using OE kickstart file:
  4524. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  4525. Continuing with the example, you can now directly ``dd`` the image to a
  4526. USB stick, or whatever media for which you built your image, and boot
  4527. the resulting media:
  4528. ::
  4529. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  4530. 140966+0 records in
  4531. 140966+0 records out
  4532. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  4533. $ sudo eject /dev/sdb
  4534. Using a Modified Kickstart File and Running in Raw Mode
  4535. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4536. This next example manually specifies each build artifact (runs in Raw
  4537. Mode) and uses a modified kickstart file. The example also uses the
  4538. ``-o`` option to cause Wic to create the output somewhere other than the
  4539. default output directory, which is the current directory:
  4540. ::
  4541. $ wic create /home/stephano/my_yocto/test.wks -o /home/stephano/testwic \
  4542. --rootfs-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  4543. --bootimg-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  4544. --kernel-dir /home/stephano/build/master/build/tmp/deploy/images/qemux86 \
  4545. --native-sysroot /home/stephano/build/master/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4546. INFO: Creating image(s)...
  4547. INFO: The new image(s) can be found here:
  4548. /home/stephano/testwic/test-201710091445-sdb.direct
  4549. The following build artifacts were used to create the image(s):
  4550. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  4551. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  4552. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  4553. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4554. INFO: The image(s) were created using OE kickstart file:
  4555. /home/stephano/my_yocto/test.wks
  4556. For this example,
  4557. :term:`MACHINE` did not have to be
  4558. specified in the ``local.conf`` file since the artifact is manually
  4559. specified.
  4560. Using Wic to Manipulate an Image
  4561. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4562. Wic image manipulation allows you to shorten turnaround time during
  4563. image development. For example, you can use Wic to delete the kernel
  4564. partition of a Wic image and then insert a newly built kernel. This
  4565. saves you time from having to rebuild the entire image each time you
  4566. modify the kernel.
  4567. .. note::
  4568. In order to use Wic to manipulate a Wic image as in this example,
  4569. your development machine must have the ``mtools`` package installed.
  4570. The following example examines the contents of the Wic image, deletes
  4571. the existing kernel, and then inserts a new kernel:
  4572. 1. *List the Partitions:* Use the ``wic ls`` command to list all the
  4573. partitions in the Wic image:
  4574. ::
  4575. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  4576. Num Start End Size Fstype
  4577. 1 1048576 25041919 23993344 fat16
  4578. 2 25165824 72157183 46991360 ext4
  4579. The previous output shows two partitions in the
  4580. ``core-image-minimal-qemux86.wic`` image.
  4581. 2. *Examine a Particular Partition:* Use the ``wic ls`` command again
  4582. but in a different form to examine a particular partition.
  4583. .. note::
  4584. You can get command usage on any Wic command using the following
  4585. form:
  4586. ::
  4587. $ wic help command
  4588. For example, the following command shows you the various ways to
  4589. use the
  4590. wic ls
  4591. command:
  4592. ::
  4593. $ wic help ls
  4594. The following command shows what is in partition one:
  4595. ::
  4596. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  4597. Volume in drive : is boot
  4598. Volume Serial Number is E894-1809
  4599. Directory for ::/
  4600. libcom32 c32 186500 2017-10-09 16:06
  4601. libutil c32 24148 2017-10-09 16:06
  4602. syslinux cfg 220 2017-10-09 16:06
  4603. vesamenu c32 27104 2017-10-09 16:06
  4604. vmlinuz 6904608 2017-10-09 16:06
  4605. 5 files 7 142 580 bytes
  4606. 16 582 656 bytes free
  4607. The previous output shows five files, with the
  4608. ``vmlinuz`` being the kernel.
  4609. .. note::
  4610. If you see the following error, you need to update or create a
  4611. ``~/.mtoolsrc`` file and be sure to have the line "mtools_skip_check=1"
  4612. in the file. Then, run the Wic command again:
  4613. ::
  4614. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  4615. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  4616. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  4617. 3. *Remove the Old Kernel:* Use the ``wic rm`` command to remove the
  4618. ``vmlinuz`` file (kernel):
  4619. ::
  4620. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  4621. 4. *Add In the New Kernel:* Use the ``wic cp`` command to add the
  4622. updated kernel to the Wic image. Depending on how you built your
  4623. kernel, it could be in different places. If you used ``devtool`` and
  4624. an SDK to build your kernel, it resides in the ``tmp/work`` directory
  4625. of the extensible SDK. If you used ``make`` to build the kernel, the
  4626. kernel will be in the ``workspace/sources`` area.
  4627. The following example assumes ``devtool`` was used to build the
  4628. kernel:
  4629. ::
  4630. $ wic 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 \
  4631. poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  4632. Once the new kernel is added back into the image, you can use the
  4633. ``dd`` command or :ref:`bmaptool
  4634. <dev-manual/common-tasks:flashing images using \`\`bmaptool\`\`>`
  4635. to flash your wic image onto an SD card or USB stick and test your
  4636. target.
  4637. .. note::
  4638. Using ``bmaptool`` is generally 10 to 20 times faster than using ``dd``.
  4639. Flashing Images Using ``bmaptool``
  4640. ==================================
  4641. A fast and easy way to flash an image to a bootable device is to use
  4642. Bmaptool, which is integrated into the OpenEmbedded build system.
  4643. Bmaptool is a generic tool that creates a file's block map (bmap) and
  4644. then uses that map to copy the file. As compared to traditional tools
  4645. such as dd or cp, Bmaptool can copy (or flash) large files like raw
  4646. system image files much faster.
  4647. .. note::
  4648. - If you are using Ubuntu or Debian distributions, you can install
  4649. the ``bmap-tools`` package using the following command and then
  4650. use the tool without specifying ``PATH`` even from the root
  4651. account:
  4652. ::
  4653. $ sudo apt-get install bmap-tools
  4654. - If you are unable to install the ``bmap-tools`` package, you will
  4655. need to build Bmaptool before using it. Use the following command:
  4656. ::
  4657. $ bitbake bmap-tools-native
  4658. Following, is an example that shows how to flash a Wic image. Realize
  4659. that while this example uses a Wic image, you can use Bmaptool to flash
  4660. any type of image. Use these steps to flash an image using Bmaptool:
  4661. 1. *Update your local.conf File:* You need to have the following set
  4662. in your ``local.conf`` file before building your image:
  4663. ::
  4664. IMAGE_FSTYPES += "wic wic.bmap"
  4665. 2. *Get Your Image:* Either have your image ready (pre-built with the
  4666. :term:`IMAGE_FSTYPES`
  4667. setting previously mentioned) or take the step to build the image:
  4668. ::
  4669. $ bitbake image
  4670. 3. *Flash the Device:* Flash the device with the image by using Bmaptool
  4671. depending on your particular setup. The following commands assume the
  4672. image resides in the Build Directory's ``deploy/images/`` area:
  4673. - If you have write access to the media, use this command form:
  4674. ::
  4675. $ oe-run-native bmap-tools-native bmaptool copy build-directory/tmp/deploy/images/machine/image.wic /dev/sdX
  4676. - If you do not have write access to the media, set your permissions
  4677. first and then use the same command form:
  4678. ::
  4679. $ sudo chmod 666 /dev/sdX
  4680. $ oe-run-native bmap-tools-native bmaptool copy build-directory/tmp/deploy/images/machine/image.wic /dev/sdX
  4681. For help on the ``bmaptool`` command, use the following command:
  4682. ::
  4683. $ bmaptool --help
  4684. Making Images More Secure
  4685. =========================
  4686. Security is of increasing concern for embedded devices. Consider the
  4687. issues and problems discussed in just this sampling of work found across
  4688. the Internet:
  4689. - *"*\ `Security Risks of Embedded
  4690. Systems <https://www.schneier.com/blog/archives/2014/01/security_risks_9.html>`__\ *"*
  4691. by Bruce Schneier
  4692. - *"*\ `Internet Census
  4693. 2012 <http://census2012.sourceforge.net/paper.html>`__\ *"* by Carna
  4694. Botnet
  4695. - *"*\ `Security Issues for Embedded
  4696. Devices <https://elinux.org/images/6/6f/Security-issues.pdf>`__\ *"*
  4697. by Jake Edge
  4698. When securing your image is of concern, there are steps, tools, and
  4699. variables that you can consider to help you reach the security goals you
  4700. need for your particular device. Not all situations are identical when
  4701. it comes to making an image secure. Consequently, this section provides
  4702. some guidance and suggestions for consideration when you want to make
  4703. your image more secure.
  4704. .. note::
  4705. Because the security requirements and risks are different for every
  4706. type of device, this section cannot provide a complete reference on
  4707. securing your custom OS. It is strongly recommended that you also
  4708. consult other sources of information on embedded Linux system
  4709. hardening and on security.
  4710. General Considerations
  4711. ----------------------
  4712. General considerations exist that help you create more secure images.
  4713. You should consider the following suggestions to help make your device
  4714. more secure:
  4715. - Scan additional code you are adding to the system (e.g. application
  4716. code) by using static analysis tools. Look for buffer overflows and
  4717. other potential security problems.
  4718. - Pay particular attention to the security for any web-based
  4719. administration interface.
  4720. Web interfaces typically need to perform administrative functions and
  4721. tend to need to run with elevated privileges. Thus, the consequences
  4722. resulting from the interface's security becoming compromised can be
  4723. serious. Look for common web vulnerabilities such as
  4724. cross-site-scripting (XSS), unvalidated inputs, and so forth.
  4725. As with system passwords, the default credentials for accessing a
  4726. web-based interface should not be the same across all devices. This
  4727. is particularly true if the interface is enabled by default as it can
  4728. be assumed that many end-users will not change the credentials.
  4729. - Ensure you can update the software on the device to mitigate
  4730. vulnerabilities discovered in the future. This consideration
  4731. especially applies when your device is network-enabled.
  4732. - Ensure you remove or disable debugging functionality before producing
  4733. the final image. For information on how to do this, see the
  4734. ":ref:`dev-manual/common-tasks:considerations specific to the openembedded build system`"
  4735. section.
  4736. - Ensure you have no network services listening that are not needed.
  4737. - Remove any software from the image that is not needed.
  4738. - Enable hardware support for secure boot functionality when your
  4739. device supports this functionality.
  4740. Security Flags
  4741. --------------
  4742. The Yocto Project has security flags that you can enable that help make
  4743. your build output more secure. The security flags are in the
  4744. ``meta/conf/distro/include/security_flags.inc`` file in your
  4745. :term:`Source Directory` (e.g. ``poky``).
  4746. .. note::
  4747. Depending on the recipe, certain security flags are enabled and
  4748. disabled by default.
  4749. Use the following line in your ``local.conf`` file or in your custom
  4750. distribution configuration file to enable the security compiler and
  4751. linker flags for your build:
  4752. ::
  4753. require conf/distro/include/security_flags.inc
  4754. Considerations Specific to the OpenEmbedded Build System
  4755. --------------------------------------------------------
  4756. You can take some steps that are specific to the OpenEmbedded build
  4757. system to make your images more secure:
  4758. - Ensure "debug-tweaks" is not one of your selected
  4759. :term:`IMAGE_FEATURES`.
  4760. When creating a new project, the default is to provide you with an
  4761. initial ``local.conf`` file that enables this feature using the
  4762. :term:`EXTRA_IMAGE_FEATURES`
  4763. variable with the line:
  4764. ::
  4765. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  4766. To disable that feature, simply comment out that line in your
  4767. ``local.conf`` file, or make sure ``IMAGE_FEATURES`` does not contain
  4768. "debug-tweaks" before producing your final image. Among other things,
  4769. leaving this in place sets the root password as blank, which makes
  4770. logging in for debugging or inspection easy during development but
  4771. also means anyone can easily log in during production.
  4772. - It is possible to set a root password for the image and also to set
  4773. passwords for any extra users you might add (e.g. administrative or
  4774. service type users). When you set up passwords for multiple images or
  4775. users, you should not duplicate passwords.
  4776. To set up passwords, use the
  4777. :ref:`extrausers <ref-classes-extrausers>`
  4778. class, which is the preferred method. For an example on how to set up
  4779. both root and user passwords, see the
  4780. ":ref:`extrausers.bbclass <ref-classes-extrausers>`"
  4781. section.
  4782. .. note::
  4783. When adding extra user accounts or setting a root password, be
  4784. cautious about setting the same password on every device. If you
  4785. do this, and the password you have set is exposed, then every
  4786. device is now potentially compromised. If you need this access but
  4787. want to ensure security, consider setting a different, random
  4788. password for each device. Typically, you do this as a separate
  4789. step after you deploy the image onto the device.
  4790. - Consider enabling a Mandatory Access Control (MAC) framework such as
  4791. SMACK or SELinux and tuning it appropriately for your device's usage.
  4792. You can find more information in the
  4793. :yocto_git:`meta-selinux </meta-selinux/>` layer.
  4794. Tools for Hardening Your Image
  4795. ------------------------------
  4796. The Yocto Project provides tools for making your image more secure. You
  4797. can find these tools in the ``meta-security`` layer of the
  4798. :yocto_git:`Yocto Project Source Repositories <>`.
  4799. Creating Your Own Distribution
  4800. ==============================
  4801. When you build an image using the Yocto Project and do not alter any
  4802. distribution :term:`Metadata`, you are
  4803. creating a Poky distribution. If you wish to gain more control over
  4804. package alternative selections, compile-time options, and other
  4805. low-level configurations, you can create your own distribution.
  4806. To create your own distribution, the basic steps consist of creating
  4807. your own distribution layer, creating your own distribution
  4808. configuration file, and then adding any needed code and Metadata to the
  4809. layer. The following steps provide some more detail:
  4810. - *Create a layer for your new distro:* Create your distribution layer
  4811. so that you can keep your Metadata and code for the distribution
  4812. separate. It is strongly recommended that you create and use your own
  4813. layer for configuration and code. Using your own layer as compared to
  4814. just placing configurations in a ``local.conf`` configuration file
  4815. makes it easier to reproduce the same build configuration when using
  4816. multiple build machines. See the
  4817. ":ref:`dev-manual/common-tasks:creating a general layer using the \`\`bitbake-layers\`\` script`"
  4818. section for information on how to quickly set up a layer.
  4819. - *Create the distribution configuration file:* The distribution
  4820. configuration file needs to be created in the ``conf/distro``
  4821. directory of your layer. You need to name it using your distribution
  4822. name (e.g. ``mydistro.conf``).
  4823. .. note::
  4824. The :term:`DISTRO` variable in your ``local.conf`` file determines the
  4825. name of your distribution.
  4826. You can split out parts of your configuration file into include files
  4827. and then "require" them from within your distribution configuration
  4828. file. Be sure to place the include files in the
  4829. ``conf/distro/include`` directory of your layer. A common example
  4830. usage of include files would be to separate out the selection of
  4831. desired version and revisions for individual recipes.
  4832. Your configuration file needs to set the following required
  4833. variables:
  4834. - :term:`DISTRO_NAME`
  4835. - :term:`DISTRO_VERSION`
  4836. These following variables are optional and you typically set them
  4837. from the distribution configuration file:
  4838. - :term:`DISTRO_FEATURES`
  4839. - :term:`DISTRO_EXTRA_RDEPENDS`
  4840. - :term:`DISTRO_EXTRA_RRECOMMENDS`
  4841. - :term:`TCLIBC`
  4842. .. tip::
  4843. If you want to base your distribution configuration file on the
  4844. very basic configuration from OE-Core, you can use
  4845. ``conf/distro/defaultsetup.conf`` as a reference and just include
  4846. variables that differ as compared to ``defaultsetup.conf``.
  4847. Alternatively, you can create a distribution configuration file
  4848. from scratch using the ``defaultsetup.conf`` file or configuration files
  4849. from other distributions such as Poky or Angstrom as references.
  4850. - *Provide miscellaneous variables:* Be sure to define any other
  4851. variables for which you want to create a default or enforce as part
  4852. of the distribution configuration. You can include nearly any
  4853. variable from the ``local.conf`` file. The variables you use are not
  4854. limited to the list in the previous bulleted item.
  4855. - *Point to Your distribution configuration file:* In your
  4856. ``local.conf`` file in the :term:`Build Directory`,
  4857. set your
  4858. :term:`DISTRO` variable to point to
  4859. your distribution's configuration file. For example, if your
  4860. distribution's configuration file is named ``mydistro.conf``, then
  4861. you point to it as follows:
  4862. ::
  4863. DISTRO = "mydistro"
  4864. - *Add more to the layer if necessary:* Use your layer to hold other
  4865. information needed for the distribution:
  4866. - Add recipes for installing distro-specific configuration files
  4867. that are not already installed by another recipe. If you have
  4868. distro-specific configuration files that are included by an
  4869. existing recipe, you should add an append file (``.bbappend``) for
  4870. those. For general information and recommendations on how to add
  4871. recipes to your layer, see the
  4872. ":ref:`dev-manual/common-tasks:creating your own layer`" and
  4873. ":ref:`dev-manual/common-tasks:following best practices when creating layers`"
  4874. sections.
  4875. - Add any image recipes that are specific to your distribution.
  4876. - Add a ``psplash`` append file for a branded splash screen. For
  4877. information on append files, see the
  4878. ":ref:`dev-manual/common-tasks:using .bbappend files in your layer`"
  4879. section.
  4880. - Add any other append files to make custom changes that are
  4881. specific to individual recipes.
  4882. Creating a Custom Template Configuration Directory
  4883. ==================================================
  4884. If you are producing your own customized version of the build system for
  4885. use by other users, you might want to customize the message shown by the
  4886. setup script or you might want to change the template configuration
  4887. files (i.e. ``local.conf`` and ``bblayers.conf``) that are created in a
  4888. new build directory.
  4889. The OpenEmbedded build system uses the environment variable
  4890. ``TEMPLATECONF`` to locate the directory from which it gathers
  4891. configuration information that ultimately ends up in the
  4892. :term:`Build Directory` ``conf`` directory.
  4893. By default, ``TEMPLATECONF`` is set as follows in the ``poky``
  4894. repository:
  4895. ::
  4896. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  4897. This is the
  4898. directory used by the build system to find templates from which to build
  4899. some key configuration files. If you look at this directory, you will
  4900. see the ``bblayers.conf.sample``, ``local.conf.sample``, and
  4901. ``conf-notes.txt`` files. The build system uses these files to form the
  4902. respective ``bblayers.conf`` file, ``local.conf`` file, and display the
  4903. list of BitBake targets when running the setup script.
  4904. To override these default configuration files with configurations you
  4905. want used within every new Build Directory, simply set the
  4906. ``TEMPLATECONF`` variable to your directory. The ``TEMPLATECONF``
  4907. variable is set in the ``.templateconf`` file, which is in the top-level
  4908. :term:`Source Directory` folder
  4909. (e.g. ``poky``). Edit the ``.templateconf`` so that it can locate your
  4910. directory.
  4911. Best practices dictate that you should keep your template configuration
  4912. directory in your custom distribution layer. For example, suppose you
  4913. have a layer named ``meta-mylayer`` located in your home directory and
  4914. you want your template configuration directory named ``myconf``.
  4915. Changing the ``.templateconf`` as follows causes the OpenEmbedded build
  4916. system to look in your directory and base its configuration files on the
  4917. ``*.sample`` configuration files it finds. The final configuration files
  4918. (i.e. ``local.conf`` and ``bblayers.conf`` ultimately still end up in
  4919. your Build Directory, but they are based on your ``*.sample`` files.
  4920. ::
  4921. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  4922. Aside from the ``*.sample`` configuration files, the ``conf-notes.txt``
  4923. also resides in the default ``meta-poky/conf`` directory. The script
  4924. that sets up the build environment (i.e.
  4925. :ref:`structure-core-script`) uses this file to
  4926. display BitBake targets as part of the script output. Customizing this
  4927. ``conf-notes.txt`` file is a good way to make sure your list of custom
  4928. targets appears as part of the script's output.
  4929. Here is the default list of targets displayed as a result of running
  4930. either of the setup scripts:
  4931. ::
  4932. You can now run 'bitbake <target>'
  4933. Common targets are:
  4934. core-image-minimal
  4935. core-image-sato
  4936. meta-toolchain
  4937. meta-ide-support
  4938. Changing the listed common targets is as easy as editing your version of
  4939. ``conf-notes.txt`` in your custom template configuration directory and
  4940. making sure you have ``TEMPLATECONF`` set to your directory.
  4941. Conserving Disk Space During Builds
  4942. ===================================
  4943. To help conserve disk space during builds, you can add the following
  4944. statement to your project's ``local.conf`` configuration file found in
  4945. the :term:`Build Directory`:
  4946. ::
  4947. INHERIT += "rm_work"
  4948. Adding this statement deletes the work directory used for
  4949. building a recipe once the recipe is built. For more information on
  4950. "rm_work", see the
  4951. :ref:`rm_work <ref-classes-rm-work>` class in the
  4952. Yocto Project Reference Manual.
  4953. Working with Packages
  4954. =====================
  4955. This section describes a few tasks that involve packages:
  4956. - :ref:`dev-manual/common-tasks:excluding packages from an image`
  4957. - :ref:`dev-manual/common-tasks:incrementing a package version`
  4958. - :ref:`dev-manual/common-tasks:handling optional module packaging`
  4959. - :ref:`dev-manual/common-tasks:using runtime package management`
  4960. - :ref:`dev-manual/common-tasks:generating and using signed packages`
  4961. - :ref:`Setting up and running package test
  4962. (ptest) <dev-manual/common-tasks:testing packages with ptest>`
  4963. - :ref:`dev-manual/common-tasks:creating node package manager (npm) packages`
  4964. - :ref:`dev-manual/common-tasks:adding custom metadata to packages`
  4965. Excluding Packages from an Image
  4966. --------------------------------
  4967. You might find it necessary to prevent specific packages from being
  4968. installed into an image. If so, you can use several variables to direct
  4969. the build system to essentially ignore installing recommended packages
  4970. or to not install a package at all.
  4971. The following list introduces variables you can use to prevent packages
  4972. from being installed into your image. Each of these variables only works
  4973. with IPK and RPM package types. Support for Debian packages does not
  4974. exist. Also, you can use these variables from your ``local.conf`` file
  4975. or attach them to a specific image recipe by using a recipe name
  4976. override. For more detail on the variables, see the descriptions in the
  4977. Yocto Project Reference Manual's glossary chapter.
  4978. - :term:`BAD_RECOMMENDATIONS`:
  4979. Use this variable to specify "recommended-only" packages that you do
  4980. not want installed.
  4981. - :term:`NO_RECOMMENDATIONS`:
  4982. Use this variable to prevent all "recommended-only" packages from
  4983. being installed.
  4984. - :term:`PACKAGE_EXCLUDE`:
  4985. Use this variable to prevent specific packages from being installed
  4986. regardless of whether they are "recommended-only" or not. You need to
  4987. realize that the build process could fail with an error when you
  4988. prevent the installation of a package whose presence is required by
  4989. an installed package.
  4990. Incrementing a Package Version
  4991. ------------------------------
  4992. This section provides some background on how binary package versioning
  4993. is accomplished and presents some of the services, variables, and
  4994. terminology involved.
  4995. In order to understand binary package versioning, you need to consider
  4996. the following:
  4997. - Binary Package: The binary package that is eventually built and
  4998. installed into an image.
  4999. - Binary Package Version: The binary package version is composed of two
  5000. components - a version and a revision.
  5001. .. note::
  5002. Technically, a third component, the "epoch" (i.e. :term:`PE`) is involved
  5003. but this discussion for the most part ignores ``PE``.
  5004. The version and revision are taken from the
  5005. :term:`PV` and
  5006. :term:`PR` variables, respectively.
  5007. - ``PV``: The recipe version. ``PV`` represents the version of the
  5008. software being packaged. Do not confuse ``PV`` with the binary
  5009. package version.
  5010. - ``PR``: The recipe revision.
  5011. - :term:`SRCPV`: The OpenEmbedded
  5012. build system uses this string to help define the value of ``PV`` when
  5013. the source code revision needs to be included in it.
  5014. - :yocto_wiki:`PR Service </PR_Service>`: A
  5015. network-based service that helps automate keeping package feeds
  5016. compatible with existing package manager applications such as RPM,
  5017. APT, and OPKG.
  5018. Whenever the binary package content changes, the binary package version
  5019. must change. Changing the binary package version is accomplished by
  5020. changing or "bumping" the ``PR`` and/or ``PV`` values. Increasing these
  5021. values occurs one of two ways:
  5022. - Automatically using a Package Revision Service (PR Service).
  5023. - Manually incrementing the ``PR`` and/or ``PV`` variables.
  5024. Given a primary challenge of any build system and its users is how to
  5025. maintain a package feed that is compatible with existing package manager
  5026. applications such as RPM, APT, and OPKG, using an automated system is
  5027. much preferred over a manual system. In either system, the main
  5028. requirement is that binary package version numbering increases in a
  5029. linear fashion and that a number of version components exist that
  5030. support that linear progression. For information on how to ensure
  5031. package revisioning remains linear, see the
  5032. ":ref:`dev-manual/common-tasks:automatically incrementing a package version number`"
  5033. section.
  5034. The following three sections provide related information on the PR
  5035. Service, the manual method for "bumping" ``PR`` and/or ``PV``, and on
  5036. how to ensure binary package revisioning remains linear.
  5037. Working With a PR Service
  5038. ~~~~~~~~~~~~~~~~~~~~~~~~~
  5039. As mentioned, attempting to maintain revision numbers in the
  5040. :term:`Metadata` is error prone, inaccurate,
  5041. and causes problems for people submitting recipes. Conversely, the PR
  5042. Service automatically generates increasing numbers, particularly the
  5043. revision field, which removes the human element.
  5044. .. note::
  5045. For additional information on using a PR Service, you can see the
  5046. :yocto_wiki:`PR Service </PR_Service>` wiki page.
  5047. The Yocto Project uses variables in order of decreasing priority to
  5048. facilitate revision numbering (i.e.
  5049. :term:`PE`,
  5050. :term:`PV`, and
  5051. :term:`PR` for epoch, version, and
  5052. revision, respectively). The values are highly dependent on the policies
  5053. and procedures of a given distribution and package feed.
  5054. Because the OpenEmbedded build system uses
  5055. ":ref:`signatures <overview-manual/concepts:checksums (signatures)>`", which are
  5056. unique to a given build, the build system knows when to rebuild
  5057. packages. All the inputs into a given task are represented by a
  5058. signature, which can trigger a rebuild when different. Thus, the build
  5059. system itself does not rely on the ``PR``, ``PV``, and ``PE`` numbers to
  5060. trigger a rebuild. The signatures, however, can be used to generate
  5061. these values.
  5062. The PR Service works with both ``OEBasic`` and ``OEBasicHash``
  5063. generators. The value of ``PR`` bumps when the checksum changes and the
  5064. different generator mechanisms change signatures under different
  5065. circumstances.
  5066. As implemented, the build system includes values from the PR Service
  5067. into the ``PR`` field as an addition using the form "``.x``" so ``r0``
  5068. becomes ``r0.1``, ``r0.2`` and so forth. This scheme allows existing
  5069. ``PR`` values to be used for whatever reasons, which include manual
  5070. ``PR`` bumps, should it be necessary.
  5071. By default, the PR Service is not enabled or running. Thus, the packages
  5072. generated are just "self consistent". The build system adds and removes
  5073. packages and there are no guarantees about upgrade paths but images will
  5074. be consistent and correct with the latest changes.
  5075. The simplest form for a PR Service is for it to exist for a single host
  5076. development system that builds the package feed (building system). For
  5077. this scenario, you can enable a local PR Service by setting
  5078. :term:`PRSERV_HOST` in your
  5079. ``local.conf`` file in the :term:`Build Directory`:
  5080. ::
  5081. PRSERV_HOST = "localhost:0"
  5082. Once the service is started, packages will automatically
  5083. get increasing ``PR`` values and BitBake takes care of starting and
  5084. stopping the server.
  5085. If you have a more complex setup where multiple host development systems
  5086. work against a common, shared package feed, you have a single PR Service
  5087. running and it is connected to each building system. For this scenario,
  5088. you need to start the PR Service using the ``bitbake-prserv`` command:
  5089. ::
  5090. bitbake-prserv --host ip --port port --start
  5091. In addition to
  5092. hand-starting the service, you need to update the ``local.conf`` file of
  5093. each building system as described earlier so each system points to the
  5094. server and port.
  5095. It is also recommended you use build history, which adds some sanity
  5096. checks to binary package versions, in conjunction with the server that
  5097. is running the PR Service. To enable build history, add the following to
  5098. each building system's ``local.conf`` file:
  5099. ::
  5100. # It is recommended to activate "buildhistory" for testing the PR service
  5101. INHERIT += "buildhistory"
  5102. BUILDHISTORY_COMMIT = "1"
  5103. For information on build
  5104. history, see the
  5105. ":ref:`dev-manual/common-tasks:maintaining build output quality`" section.
  5106. .. note::
  5107. The OpenEmbedded build system does not maintain ``PR`` information as
  5108. part of the shared state (sstate) packages. If you maintain an sstate
  5109. feed, it's expected that either all your building systems that
  5110. contribute to the sstate feed use a shared PR Service, or you do not
  5111. run a PR Service on any of your building systems. Having some systems
  5112. use a PR Service while others do not leads to obvious problems.
  5113. For more information on shared state, see the
  5114. ":ref:`overview-manual/concepts:shared state cache`"
  5115. section in the Yocto Project Overview and Concepts Manual.
  5116. Manually Bumping PR
  5117. ~~~~~~~~~~~~~~~~~~~
  5118. The alternative to setting up a PR Service is to manually "bump" the
  5119. :term:`PR` variable.
  5120. If a committed change results in changing the package output, then the
  5121. value of the PR variable needs to be increased (or "bumped") as part of
  5122. that commit. For new recipes you should add the ``PR`` variable and set
  5123. its initial value equal to "r0", which is the default. Even though the
  5124. default value is "r0", the practice of adding it to a new recipe makes
  5125. it harder to forget to bump the variable when you make changes to the
  5126. recipe in future.
  5127. If you are sharing a common ``.inc`` file with multiple recipes, you can
  5128. also use the ``INC_PR`` variable to ensure that the recipes sharing the
  5129. ``.inc`` file are rebuilt when the ``.inc`` file itself is changed. The
  5130. ``.inc`` file must set ``INC_PR`` (initially to "r0"), and all recipes
  5131. referring to it should set ``PR`` to "${INC_PR}.0" initially,
  5132. incrementing the last number when the recipe is changed. If the ``.inc``
  5133. file is changed then its ``INC_PR`` should be incremented.
  5134. When upgrading the version of a binary package, assuming the ``PV``
  5135. changes, the ``PR`` variable should be reset to "r0" (or "${INC_PR}.0"
  5136. if you are using ``INC_PR``).
  5137. Usually, version increases occur only to binary packages. However, if
  5138. for some reason ``PV`` changes but does not increase, you can increase
  5139. the ``PE`` variable (Package Epoch). The ``PE`` variable defaults to
  5140. "0".
  5141. Binary package version numbering strives to follow the `Debian Version
  5142. Field Policy
  5143. Guidelines <https://www.debian.org/doc/debian-policy/ch-controlfields.html>`__.
  5144. These guidelines define how versions are compared and what "increasing"
  5145. a version means.
  5146. Automatically Incrementing a Package Version Number
  5147. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5148. When fetching a repository, BitBake uses the
  5149. :term:`SRCREV` variable to determine
  5150. the specific source code revision from which to build. You set the
  5151. ``SRCREV`` variable to
  5152. :term:`AUTOREV` to cause the
  5153. OpenEmbedded build system to automatically use the latest revision of
  5154. the software:
  5155. ::
  5156. SRCREV = "${AUTOREV}"
  5157. Furthermore, you need to reference ``SRCPV`` in ``PV`` in order to
  5158. automatically update the version whenever the revision of the source
  5159. code changes. Here is an example:
  5160. ::
  5161. PV = "1.0+git${SRCPV}"
  5162. The OpenEmbedded build system substitutes ``SRCPV`` with the following:
  5163. .. code-block:: none
  5164. AUTOINC+source_code_revision
  5165. The build system replaces the ``AUTOINC``
  5166. with a number. The number used depends on the state of the PR Service:
  5167. - If PR Service is enabled, the build system increments the number,
  5168. which is similar to the behavior of
  5169. :term:`PR`. This behavior results in
  5170. linearly increasing package versions, which is desirable. Here is an
  5171. example:
  5172. .. code-block:: none
  5173. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  5174. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  5175. - If PR Service is not enabled, the build system replaces the
  5176. ``AUTOINC`` placeholder with zero (i.e. "0"). This results in
  5177. changing the package version since the source revision is included.
  5178. However, package versions are not increased linearly. Here is an
  5179. example:
  5180. .. code-block:: none
  5181. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  5182. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  5183. In summary, the OpenEmbedded build system does not track the history of
  5184. binary package versions for this purpose. ``AUTOINC``, in this case, is
  5185. comparable to ``PR``. If PR server is not enabled, ``AUTOINC`` in the
  5186. package version is simply replaced by "0". If PR server is enabled, the
  5187. build system keeps track of the package versions and bumps the number
  5188. when the package revision changes.
  5189. Handling Optional Module Packaging
  5190. ----------------------------------
  5191. Many pieces of software split functionality into optional modules (or
  5192. plugins) and the plugins that are built might depend on configuration
  5193. options. To avoid having to duplicate the logic that determines what
  5194. modules are available in your recipe or to avoid having to package each
  5195. module by hand, the OpenEmbedded build system provides functionality to
  5196. handle module packaging dynamically.
  5197. To handle optional module packaging, you need to do two things:
  5198. - Ensure the module packaging is actually done.
  5199. - Ensure that any dependencies on optional modules from other recipes
  5200. are satisfied by your recipe.
  5201. Making Sure the Packaging is Done
  5202. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5203. To ensure the module packaging actually gets done, you use the
  5204. ``do_split_packages`` function within the ``populate_packages`` Python
  5205. function in your recipe. The ``do_split_packages`` function searches for
  5206. a pattern of files or directories under a specified path and creates a
  5207. package for each one it finds by appending to the
  5208. :term:`PACKAGES` variable and
  5209. setting the appropriate values for ``FILES_packagename``,
  5210. ``RDEPENDS_packagename``, ``DESCRIPTION_packagename``, and so forth.
  5211. Here is an example from the ``lighttpd`` recipe:
  5212. ::
  5213. python populate_packages_prepend () {
  5214. lighttpd_libdir = d.expand('${libdir}')
  5215. do_split_packages(d, lighttpd_libdir, '^mod_(.*).so$',
  5216. 'lighttpd-module-%s', 'Lighttpd module for %s',
  5217. extra_depends='')
  5218. }
  5219. The previous example specifies a number of things in the call to
  5220. ``do_split_packages``.
  5221. - A directory within the files installed by your recipe through
  5222. ``do_install`` in which to search.
  5223. - A regular expression used to match module files in that directory. In
  5224. the example, note the parentheses () that mark the part of the
  5225. expression from which the module name should be derived.
  5226. - A pattern to use for the package names.
  5227. - A description for each package.
  5228. - An empty string for ``extra_depends``, which disables the default
  5229. dependency on the main ``lighttpd`` package. Thus, if a file in
  5230. ``${libdir}`` called ``mod_alias.so`` is found, a package called
  5231. ``lighttpd-module-alias`` is created for it and the
  5232. :term:`DESCRIPTION` is set to
  5233. "Lighttpd module for alias".
  5234. Often, packaging modules is as simple as the previous example. However,
  5235. more advanced options exist that you can use within
  5236. ``do_split_packages`` to modify its behavior. And, if you need to, you
  5237. can add more logic by specifying a hook function that is called for each
  5238. package. It is also perfectly acceptable to call ``do_split_packages``
  5239. multiple times if you have more than one set of modules to package.
  5240. For more examples that show how to use ``do_split_packages``, see the
  5241. ``connman.inc`` file in the ``meta/recipes-connectivity/connman/``
  5242. directory of the ``poky`` :ref:`source repository <overview-manual/development-environment:yocto project source repositories>`. You can
  5243. also find examples in ``meta/classes/kernel.bbclass``.
  5244. Following is a reference that shows ``do_split_packages`` mandatory and
  5245. optional arguments:
  5246. ::
  5247. Mandatory arguments
  5248. root
  5249. The path in which to search
  5250. file_regex
  5251. Regular expression to match searched files.
  5252. Use parentheses () to mark the part of this
  5253. expression that should be used to derive the
  5254. module name (to be substituted where %s is
  5255. used in other function arguments as noted below)
  5256. output_pattern
  5257. Pattern to use for the package names. Must
  5258. include %s.
  5259. description
  5260. Description to set for each package. Must
  5261. include %s.
  5262. Optional arguments
  5263. postinst
  5264. Postinstall script to use for all packages
  5265. (as a string)
  5266. recursive
  5267. True to perform a recursive search - default
  5268. False
  5269. hook
  5270. A hook function to be called for every match.
  5271. The function will be called with the following
  5272. arguments (in the order listed):
  5273. f
  5274. Full path to the file/directory match
  5275. pkg
  5276. The package name
  5277. file_regex
  5278. As above
  5279. output_pattern
  5280. As above
  5281. modulename
  5282. The module name derived using file_regex
  5283. extra_depends
  5284. Extra runtime dependencies (RDEPENDS) to be
  5285. set for all packages. The default value of None
  5286. causes a dependency on the main package
  5287. (${PN}) - if you do not want this, pass empty
  5288. string '' for this parameter.
  5289. aux_files_pattern
  5290. Extra item(s) to be added to FILES for each
  5291. package. Can be a single string item or a list
  5292. of strings for multiple items. Must include %s.
  5293. postrm
  5294. postrm script to use for all packages (as a
  5295. string)
  5296. allow_dirs
  5297. True to allow directories to be matched -
  5298. default False
  5299. prepend
  5300. If True, prepend created packages to PACKAGES
  5301. instead of the default False which appends them
  5302. match_path
  5303. match file_regex on the whole relative path to
  5304. the root rather than just the file name
  5305. aux_files_pattern_verbatim
  5306. Extra item(s) to be added to FILES for each
  5307. package, using the actual derived module name
  5308. rather than converting it to something legal
  5309. for a package name. Can be a single string item
  5310. or a list of strings for multiple items. Must
  5311. include %s.
  5312. allow_links
  5313. True to allow symlinks to be matched - default
  5314. False
  5315. summary
  5316. Summary to set for each package. Must include %s;
  5317. defaults to description if not set.
  5318. Satisfying Dependencies
  5319. ~~~~~~~~~~~~~~~~~~~~~~~
  5320. The second part for handling optional module packaging is to ensure that
  5321. any dependencies on optional modules from other recipes are satisfied by
  5322. your recipe. You can be sure these dependencies are satisfied by using
  5323. the :term:`PACKAGES_DYNAMIC`
  5324. variable. Here is an example that continues with the ``lighttpd`` recipe
  5325. shown earlier:
  5326. ::
  5327. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  5328. The name
  5329. specified in the regular expression can of course be anything. In this
  5330. example, it is ``lighttpd-module-`` and is specified as the prefix to
  5331. ensure that any :term:`RDEPENDS` and
  5332. :term:`RRECOMMENDS` on a package
  5333. name starting with the prefix are satisfied during build time. If you
  5334. are using ``do_split_packages`` as described in the previous section,
  5335. the value you put in ``PACKAGES_DYNAMIC`` should correspond to the name
  5336. pattern specified in the call to ``do_split_packages``.
  5337. Using Runtime Package Management
  5338. --------------------------------
  5339. During a build, BitBake always transforms a recipe into one or more
  5340. packages. For example, BitBake takes the ``bash`` recipe and produces a
  5341. number of packages (e.g. ``bash``, ``bash-bashbug``,
  5342. ``bash-completion``, ``bash-completion-dbg``, ``bash-completion-dev``,
  5343. ``bash-completion-extra``, ``bash-dbg``, and so forth). Not all
  5344. generated packages are included in an image.
  5345. In several situations, you might need to update, add, remove, or query
  5346. the packages on a target device at runtime (i.e. without having to
  5347. generate a new image). Examples of such situations include:
  5348. - You want to provide in-the-field updates to deployed devices (e.g.
  5349. security updates).
  5350. - You want to have a fast turn-around development cycle for one or more
  5351. applications that run on your device.
  5352. - You want to temporarily install the "debug" packages of various
  5353. applications on your device so that debugging can be greatly improved
  5354. by allowing access to symbols and source debugging.
  5355. - You want to deploy a more minimal package selection of your device
  5356. but allow in-the-field updates to add a larger selection for
  5357. customization.
  5358. In all these situations, you have something similar to a more
  5359. traditional Linux distribution in that in-field devices are able to
  5360. receive pre-compiled packages from a server for installation or update.
  5361. Being able to install these packages on a running, in-field device is
  5362. what is termed "runtime package management".
  5363. In order to use runtime package management, you need a host or server
  5364. machine that serves up the pre-compiled packages plus the required
  5365. metadata. You also need package manipulation tools on the target. The
  5366. build machine is a likely candidate to act as the server. However, that
  5367. machine does not necessarily have to be the package server. The build
  5368. machine could push its artifacts to another machine that acts as the
  5369. server (e.g. Internet-facing). In fact, doing so is advantageous for a
  5370. production environment as getting the packages away from the development
  5371. system's build directory prevents accidental overwrites.
  5372. A simple build that targets just one device produces more than one
  5373. package database. In other words, the packages produced by a build are
  5374. separated out into a couple of different package groupings based on
  5375. criteria such as the target's CPU architecture, the target board, or the
  5376. C library used on the target. For example, a build targeting the
  5377. ``qemux86`` device produces the following three package databases:
  5378. ``noarch``, ``i586``, and ``qemux86``. If you wanted your ``qemux86``
  5379. device to be aware of all the packages that were available to it, you
  5380. would need to point it to each of these databases individually. In a
  5381. similar way, a traditional Linux distribution usually is configured to
  5382. be aware of a number of software repositories from which it retrieves
  5383. packages.
  5384. Using runtime package management is completely optional and not required
  5385. for a successful build or deployment in any way. But if you want to make
  5386. use of runtime package management, you need to do a couple things above
  5387. and beyond the basics. The remainder of this section describes what you
  5388. need to do.
  5389. Build Considerations
  5390. ~~~~~~~~~~~~~~~~~~~~
  5391. This section describes build considerations of which you need to be
  5392. aware in order to provide support for runtime package management.
  5393. When BitBake generates packages, it needs to know what format or formats
  5394. to use. In your configuration, you use the
  5395. :term:`PACKAGE_CLASSES`
  5396. variable to specify the format:
  5397. 1. Open the ``local.conf`` file inside your
  5398. :term:`Build Directory` (e.g.
  5399. ``poky/build/conf/local.conf``).
  5400. 2. Select the desired package format as follows:
  5401. ::
  5402. PACKAGE_CLASSES ?= "package_packageformat"
  5403. where packageformat can be "ipk", "rpm",
  5404. "deb", or "tar" which are the supported package formats.
  5405. .. note::
  5406. Because the Yocto Project supports four different package formats,
  5407. you can set the variable with more than one argument. However, the
  5408. OpenEmbedded build system only uses the first argument when
  5409. creating an image or Software Development Kit (SDK).
  5410. If you would like your image to start off with a basic package database
  5411. containing the packages in your current build as well as to have the
  5412. relevant tools available on the target for runtime package management,
  5413. you can include "package-management" in the
  5414. :term:`IMAGE_FEATURES`
  5415. variable. Including "package-management" in this configuration variable
  5416. ensures that when the image is assembled for your target, the image
  5417. includes the currently-known package databases as well as the
  5418. target-specific tools required for runtime package management to be
  5419. performed on the target. However, this is not strictly necessary. You
  5420. could start your image off without any databases but only include the
  5421. required on-target package tool(s). As an example, you could include
  5422. "opkg" in your
  5423. :term:`IMAGE_INSTALL` variable
  5424. if you are using the IPK package format. You can then initialize your
  5425. target's package database(s) later once your image is up and running.
  5426. Whenever you perform any sort of build step that can potentially
  5427. generate a package or modify existing package, it is always a good idea
  5428. to re-generate the package index after the build by using the following
  5429. command:
  5430. ::
  5431. $ bitbake package-index
  5432. It might be tempting to build the
  5433. package and the package index at the same time with a command such as
  5434. the following:
  5435. ::
  5436. $ bitbake some-package package-index
  5437. Do not do this as
  5438. BitBake does not schedule the package index for after the completion of
  5439. the package you are building. Consequently, you cannot be sure of the
  5440. package index including information for the package you just built.
  5441. Thus, be sure to run the package update step separately after building
  5442. any packages.
  5443. You can use the
  5444. :term:`PACKAGE_FEED_ARCHS`,
  5445. :term:`PACKAGE_FEED_BASE_PATHS`,
  5446. and
  5447. :term:`PACKAGE_FEED_URIS`
  5448. variables to pre-configure target images to use a package feed. If you
  5449. do not define these variables, then manual steps as described in the
  5450. subsequent sections are necessary to configure the target. You should
  5451. set these variables before building the image in order to produce a
  5452. correctly configured image.
  5453. When your build is complete, your packages reside in the
  5454. ``${TMPDIR}/deploy/packageformat`` directory. For example, if
  5455. ``${``\ :term:`TMPDIR`\ ``}`` is
  5456. ``tmp`` and your selected package type is RPM, then your RPM packages
  5457. are available in ``tmp/deploy/rpm``.
  5458. Host or Server Machine Setup
  5459. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5460. Although other protocols are possible, a server using HTTP typically
  5461. serves packages. If you want to use HTTP, then set up and configure a
  5462. web server such as Apache 2, lighttpd, or Python web server on the
  5463. machine serving the packages.
  5464. To keep things simple, this section describes how to set up a
  5465. Python web server to share package feeds from the developer's
  5466. machine. Although this server might not be the best for a production
  5467. environment, the setup is simple and straight forward. Should you want
  5468. to use a different server more suited for production (e.g. Apache 2,
  5469. Lighttpd, or Nginx), take the appropriate steps to do so.
  5470. From within the build directory where you have built an image based on
  5471. your packaging choice (i.e. the
  5472. :term:`PACKAGE_CLASSES`
  5473. setting), simply start the server. The following example assumes a build
  5474. directory of ``poky/build/tmp/deploy/rpm`` and a ``PACKAGE_CLASSES``
  5475. setting of "package_rpm":
  5476. ::
  5477. $ cd poky/build/tmp/deploy/rpm
  5478. $ python3 -m http.server
  5479. Target Setup
  5480. ~~~~~~~~~~~~
  5481. Setting up the target differs depending on the package management
  5482. system. This section provides information for RPM, IPK, and DEB.
  5483. Using RPM
  5484. ^^^^^^^^^
  5485. The `Dandified Packaging
  5486. Tool <https://en.wikipedia.org/wiki/DNF_(software)>`__ (DNF) performs
  5487. runtime package management of RPM packages. In order to use DNF for
  5488. runtime package management, you must perform an initial setup on the
  5489. target machine for cases where the ``PACKAGE_FEED_*`` variables were not
  5490. set as part of the image that is running on the target. This means if
  5491. you built your image and did not use these variables as part of the
  5492. build and your image is now running on the target, you need to perform
  5493. the steps in this section if you want to use runtime package management.
  5494. .. note::
  5495. For information on the ``PACKAGE_FEED_*`` variables, see
  5496. :term:`PACKAGE_FEED_ARCHS`, :term:`PACKAGE_FEED_BASE_PATHS`, and
  5497. :term:`PACKAGE_FEED_URIS` in the Yocto Project Reference Manual variables
  5498. glossary.
  5499. On the target, you must inform DNF that package databases are available.
  5500. You do this by creating a file named
  5501. ``/etc/yum.repos.d/oe-packages.repo`` and defining the ``oe-packages``.
  5502. As an example, assume the target is able to use the following package
  5503. databases: ``all``, ``i586``, and ``qemux86`` from a server named
  5504. ``my.server``. The specifics for setting up the web server are up to
  5505. you. The critical requirement is that the URIs in the target repository
  5506. configuration point to the correct remote location for the feeds.
  5507. .. note::
  5508. For development purposes, you can point the web server to the build
  5509. system's ``deploy`` directory. However, for production use, it is better to
  5510. copy the package directories to a location outside of the build area and use
  5511. that location. Doing so avoids situations where the build system
  5512. overwrites or changes the ``deploy`` directory.
  5513. When telling DNF where to look for the package databases, you must
  5514. declare individual locations per architecture or a single location used
  5515. for all architectures. You cannot do both:
  5516. - *Create an Explicit List of Architectures:* Define individual base
  5517. URLs to identify where each package database is located:
  5518. .. code-block:: none
  5519. [oe-packages]
  5520. baseurl=http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all
  5521. This example
  5522. informs DNF about individual package databases for all three
  5523. architectures.
  5524. - *Create a Single (Full) Package Index:* Define a single base URL that
  5525. identifies where a full package database is located:
  5526. ::
  5527. [oe-packages]
  5528. baseurl=http://my.server/rpm
  5529. This example informs DNF about a single
  5530. package database that contains all the package index information for
  5531. all supported architectures.
  5532. Once you have informed DNF where to find the package databases, you need
  5533. to fetch them:
  5534. .. code-block:: none
  5535. # dnf makecache
  5536. DNF is now able to find, install, and
  5537. upgrade packages from the specified repository or repositories.
  5538. .. note::
  5539. See the `DNF documentation <https://dnf.readthedocs.io/en/latest/>`__ for
  5540. additional information.
  5541. Using IPK
  5542. ^^^^^^^^^
  5543. The ``opkg`` application performs runtime package management of IPK
  5544. packages. You must perform an initial setup for ``opkg`` on the target
  5545. machine if the
  5546. :term:`PACKAGE_FEED_ARCHS`,
  5547. :term:`PACKAGE_FEED_BASE_PATHS`,
  5548. and
  5549. :term:`PACKAGE_FEED_URIS`
  5550. variables have not been set or the target image was built before the
  5551. variables were set.
  5552. The ``opkg`` application uses configuration files to find available
  5553. package databases. Thus, you need to create a configuration file inside
  5554. the ``/etc/opkg/`` direction, which informs ``opkg`` of any repository
  5555. you want to use.
  5556. As an example, suppose you are serving packages from a ``ipk/``
  5557. directory containing the ``i586``, ``all``, and ``qemux86`` databases
  5558. through an HTTP server named ``my.server``. On the target, create a
  5559. configuration file (e.g. ``my_repo.conf``) inside the ``/etc/opkg/``
  5560. directory containing the following:
  5561. .. code-block:: none
  5562. src/gz all http://my.server/ipk/all
  5563. src/gz i586 http://my.server/ipk/i586
  5564. src/gz qemux86 http://my.server/ipk/qemux86
  5565. Next, instruct ``opkg`` to fetch the
  5566. repository information:
  5567. .. code-block:: none
  5568. # opkg update
  5569. The ``opkg`` application is now able to find, install, and upgrade packages
  5570. from the specified repository.
  5571. Using DEB
  5572. ^^^^^^^^^
  5573. The ``apt`` application performs runtime package management of DEB
  5574. packages. This application uses a source list file to find available
  5575. package databases. You must perform an initial setup for ``apt`` on the
  5576. target machine if the
  5577. :term:`PACKAGE_FEED_ARCHS`,
  5578. :term:`PACKAGE_FEED_BASE_PATHS`,
  5579. and
  5580. :term:`PACKAGE_FEED_URIS`
  5581. variables have not been set or the target image was built before the
  5582. variables were set.
  5583. To inform ``apt`` of the repository you want to use, you might create a
  5584. list file (e.g. ``my_repo.list``) inside the
  5585. ``/etc/apt/sources.list.d/`` directory. As an example, suppose you are
  5586. serving packages from a ``deb/`` directory containing the ``i586``,
  5587. ``all``, and ``qemux86`` databases through an HTTP server named
  5588. ``my.server``. The list file should contain:
  5589. .. code-block:: none
  5590. deb http://my.server/deb/all ./
  5591. deb http://my.server/deb/i586 ./
  5592. deb http://my.server/deb/qemux86 ./
  5593. Next, instruct the ``apt`` application
  5594. to fetch the repository information:
  5595. .. code-block:: none
  5596. # apt-get update
  5597. After this step,
  5598. ``apt`` is able to find, install, and upgrade packages from the
  5599. specified repository.
  5600. Generating and Using Signed Packages
  5601. ------------------------------------
  5602. In order to add security to RPM packages used during a build, you can
  5603. take steps to securely sign them. Once a signature is verified, the
  5604. OpenEmbedded build system can use the package in the build. If security
  5605. fails for a signed package, the build system aborts the build.
  5606. This section describes how to sign RPM packages during a build and how
  5607. to use signed package feeds (repositories) when doing a build.
  5608. Signing RPM Packages
  5609. ~~~~~~~~~~~~~~~~~~~~
  5610. To enable signing RPM packages, you must set up the following
  5611. configurations in either your ``local.config`` or ``distro.config``
  5612. file:
  5613. ::
  5614. # Inherit sign_rpm.bbclass to enable signing functionality
  5615. INHERIT += " sign_rpm"
  5616. # Define the GPG key that will be used for signing.
  5617. RPM_GPG_NAME = "key_name"
  5618. # Provide passphrase for the key
  5619. RPM_GPG_PASSPHRASE = "passphrase"
  5620. .. note::
  5621. Be sure to supply appropriate values for both `key_name` and
  5622. `passphrase`.
  5623. Aside from the ``RPM_GPG_NAME`` and ``RPM_GPG_PASSPHRASE`` variables in
  5624. the previous example, two optional variables related to signing exist:
  5625. - *GPG_BIN:* Specifies a ``gpg`` binary/wrapper that is executed
  5626. when the package is signed.
  5627. - *GPG_PATH:* Specifies the ``gpg`` home directory used when the
  5628. package is signed.
  5629. Processing Package Feeds
  5630. ~~~~~~~~~~~~~~~~~~~~~~~~
  5631. In addition to being able to sign RPM packages, you can also enable
  5632. signed package feeds for IPK and RPM packages.
  5633. The steps you need to take to enable signed package feed use are similar
  5634. to the steps used to sign RPM packages. You must define the following in
  5635. your ``local.config`` or ``distro.config`` file:
  5636. ::
  5637. INHERIT += "sign_package_feed"
  5638. PACKAGE_FEED_GPG_NAME = "key_name"
  5639. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "path_to_file_containing_passphrase"
  5640. For signed package feeds, the passphrase must exist in a separate file,
  5641. which is pointed to by the ``PACKAGE_FEED_GPG_PASSPHRASE_FILE``
  5642. variable. Regarding security, keeping a plain text passphrase out of the
  5643. configuration is more secure.
  5644. Aside from the ``PACKAGE_FEED_GPG_NAME`` and
  5645. ``PACKAGE_FEED_GPG_PASSPHRASE_FILE`` variables, three optional variables
  5646. related to signed package feeds exist:
  5647. - *GPG_BIN* Specifies a ``gpg`` binary/wrapper that is executed
  5648. when the package is signed.
  5649. - *GPG_PATH:* Specifies the ``gpg`` home directory used when the
  5650. package is signed.
  5651. - *PACKAGE_FEED_GPG_SIGNATURE_TYPE:* Specifies the type of ``gpg``
  5652. signature. This variable applies only to RPM and IPK package feeds.
  5653. Allowable values for the ``PACKAGE_FEED_GPG_SIGNATURE_TYPE`` are
  5654. "ASC", which is the default and specifies ascii armored, and "BIN",
  5655. which specifies binary.
  5656. Testing Packages With ptest
  5657. ---------------------------
  5658. A Package Test (ptest) runs tests against packages built by the
  5659. OpenEmbedded build system on the target machine. A ptest contains at
  5660. least two items: the actual test, and a shell script (``run-ptest``)
  5661. that starts the test. The shell script that starts the test must not
  5662. contain the actual test - the script only starts the test. On the other
  5663. hand, the test can be anything from a simple shell script that runs a
  5664. binary and checks the output to an elaborate system of test binaries and
  5665. data files.
  5666. The test generates output in the format used by Automake:
  5667. ::
  5668. result: testname
  5669. where the result can be ``PASS``, ``FAIL``, or ``SKIP``, and
  5670. the testname can be any identifying string.
  5671. For a list of Yocto Project recipes that are already enabled with ptest,
  5672. see the :yocto_wiki:`Ptest </Ptest>` wiki page.
  5673. .. note::
  5674. A recipe is "ptest-enabled" if it inherits the
  5675. :ref:`ptest <ref-classes-ptest>` class.
  5676. Adding ptest to Your Build
  5677. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  5678. To add package testing to your build, add the
  5679. :term:`DISTRO_FEATURES` and
  5680. :term:`EXTRA_IMAGE_FEATURES`
  5681. variables to your ``local.conf`` file, which is found in the
  5682. :term:`Build Directory`:
  5683. ::
  5684. DISTRO_FEATURES_append = " ptest"
  5685. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  5686. Once your build is complete, the ptest files are installed into the
  5687. ``/usr/lib/package/ptest`` directory within the image, where ``package``
  5688. is the name of the package.
  5689. Running ptest
  5690. ~~~~~~~~~~~~~
  5691. The ``ptest-runner`` package installs a shell script that loops through
  5692. all installed ptest test suites and runs them in sequence. Consequently,
  5693. you might want to add this package to your image.
  5694. Getting Your Package Ready
  5695. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  5696. In order to enable a recipe to run installed ptests on target hardware,
  5697. you need to prepare the recipes that build the packages you want to
  5698. test. Here is what you have to do for each recipe:
  5699. - *Be sure the recipe inherits
  5700. the* :ref:`ptest <ref-classes-ptest>` *class:*
  5701. Include the following line in each recipe:
  5702. ::
  5703. inherit ptest
  5704. - *Create run-ptest:* This script starts your test. Locate the
  5705. script where you will refer to it using
  5706. :term:`SRC_URI`. Here is an
  5707. example that starts a test for ``dbus``:
  5708. ::
  5709. #!/bin/sh
  5710. cd test
  5711. make -k runtest-TESTS
  5712. - *Ensure dependencies are met:* If the test adds build or runtime
  5713. dependencies that normally do not exist for the package (such as
  5714. requiring "make" to run the test suite), use the
  5715. :term:`DEPENDS` and
  5716. :term:`RDEPENDS` variables in
  5717. your recipe in order for the package to meet the dependencies. Here
  5718. is an example where the package has a runtime dependency on "make":
  5719. ::
  5720. RDEPENDS_${PN}-ptest += "make"
  5721. - *Add a function to build the test suite:* Not many packages support
  5722. cross-compilation of their test suites. Consequently, you usually
  5723. need to add a cross-compilation function to the package.
  5724. Many packages based on Automake compile and run the test suite by
  5725. using a single command such as ``make check``. However, the host
  5726. ``make check`` builds and runs on the same computer, while
  5727. cross-compiling requires that the package is built on the host but
  5728. executed for the target architecture (though often, as in the case
  5729. for ptest, the execution occurs on the host). The built version of
  5730. Automake that ships with the Yocto Project includes a patch that
  5731. separates building and execution. Consequently, packages that use the
  5732. unaltered, patched version of ``make check`` automatically
  5733. cross-compiles.
  5734. Regardless, you still must add a ``do_compile_ptest`` function to
  5735. build the test suite. Add a function similar to the following to your
  5736. recipe:
  5737. ::
  5738. do_compile_ptest() {
  5739. oe_runmake buildtest-TESTS
  5740. }
  5741. - *Ensure special configurations are set:* If the package requires
  5742. special configurations prior to compiling the test code, you must
  5743. insert a ``do_configure_ptest`` function into the recipe.
  5744. - *Install the test suite:* The ``ptest`` class automatically copies
  5745. the file ``run-ptest`` to the target and then runs make
  5746. ``install-ptest`` to run the tests. If this is not enough, you need
  5747. to create a ``do_install_ptest`` function and make sure it gets
  5748. called after the "make install-ptest" completes.
  5749. Creating Node Package Manager (NPM) Packages
  5750. --------------------------------------------
  5751. `NPM <https://en.wikipedia.org/wiki/Npm_(software)>`__ is a package
  5752. manager for the JavaScript programming language. The Yocto Project
  5753. supports the NPM :ref:`fetcher <bitbake:bitbake-user-manual/bitbake-user-manual-fetching:fetchers>`. You can
  5754. use this fetcher in combination with
  5755. :doc:`devtool </ref-manual/devtool-reference>` to create
  5756. recipes that produce NPM packages.
  5757. Two workflows exist that allow you to create NPM packages using
  5758. ``devtool``: the NPM registry modules method and the NPM project code
  5759. method.
  5760. .. note::
  5761. While it is possible to create NPM recipes manually, using
  5762. ``devtool`` is far simpler.
  5763. Additionally, some requirements and caveats exist.
  5764. Requirements and Caveats
  5765. ~~~~~~~~~~~~~~~~~~~~~~~~
  5766. You need to be aware of the following before using ``devtool`` to create
  5767. NPM packages:
  5768. - Of the two methods that you can use ``devtool`` to create NPM
  5769. packages, the registry approach is slightly simpler. However, you
  5770. might consider the project approach because you do not have to
  5771. publish your module in the NPM registry
  5772. (`npm-registry <https://docs.npmjs.com/misc/registry>`_), which
  5773. is NPM's public registry.
  5774. - Be familiar with
  5775. :doc:`devtool </ref-manual/devtool-reference>`.
  5776. - The NPM host tools need the native ``nodejs-npm`` package, which is
  5777. part of the OpenEmbedded environment. You need to get the package by
  5778. cloning the https://github.com/openembedded/meta-openembedded
  5779. repository out of GitHub. Be sure to add the path to your local copy
  5780. to your ``bblayers.conf`` file.
  5781. - ``devtool`` cannot detect native libraries in module dependencies.
  5782. Consequently, you must manually add packages to your recipe.
  5783. - While deploying NPM packages, ``devtool`` cannot determine which
  5784. dependent packages are missing on the target (e.g. the node runtime
  5785. ``nodejs``). Consequently, you need to find out what files are
  5786. missing and be sure they are on the target.
  5787. - Although you might not need NPM to run your node package, it is
  5788. useful to have NPM on your target. The NPM package name is
  5789. ``nodejs-npm``.
  5790. Using the Registry Modules Method
  5791. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5792. This section presents an example that uses the ``cute-files`` module,
  5793. which is a file browser web application.
  5794. .. note::
  5795. You must know the ``cute-files`` module version.
  5796. The first thing you need to do is use ``devtool`` and the NPM fetcher to
  5797. create the recipe:
  5798. ::
  5799. $ devtool add "npm://registry.npmjs.org;package=cute-files;version=1.0.2"
  5800. The
  5801. ``devtool add`` command runs ``recipetool create`` and uses the same
  5802. fetch URI to download each dependency and capture license details where
  5803. possible. The result is a generated recipe.
  5804. The recipe file is fairly simple and contains every license that
  5805. ``recipetool`` finds and includes the licenses in the recipe's
  5806. :term:`LIC_FILES_CHKSUM`
  5807. variables. You need to examine the variables and look for those with
  5808. "unknown" in the :term:`LICENSE`
  5809. field. You need to track down the license information for "unknown"
  5810. modules and manually add the information to the recipe.
  5811. ``recipetool`` creates a "shrinkwrap" file for your recipe. Shrinkwrap
  5812. files capture the version of all dependent modules. Many packages do not
  5813. provide shrinkwrap files. ``recipetool`` create a shrinkwrap file as it
  5814. runs.
  5815. .. note::
  5816. A package is created for each sub-module. This policy is the only
  5817. practical way to have the licenses for all of the dependencies
  5818. represented in the license manifest of the image.
  5819. The ``devtool edit-recipe`` command lets you take a look at the recipe:
  5820. ::
  5821. $ devtool edit-recipe cute-files
  5822. SUMMARY = "Turn any folder on your computer into a cute file browser, available on the local network."
  5823. LICENSE = "MIT & ISC & Unknown"
  5824. LIC_FILES_CHKSUM = "file://LICENSE;md5=71d98c0a1db42956787b1909c74a86ca \
  5825. file://node_modules/toidentifier/LICENSE;md5=1a261071a044d02eb6f2bb47f51a3502 \
  5826. file://node_modules/debug/LICENSE;md5=ddd815a475e7338b0be7a14d8ee35a99 \
  5827. ...
  5828. SRC_URI = " \
  5829. npm://registry.npmjs.org/;package=cute-files;version=${PV} \
  5830. npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \
  5831. "
  5832. S = "${WORKDIR}/npm"
  5833. inherit npm LICENSE_${PN} = "MIT"
  5834. LICENSE_${PN}-accepts = "MIT"
  5835. LICENSE_${PN}-array-flatten = "MIT"
  5836. ...
  5837. LICENSE_${PN}-vary = "MIT"
  5838. Three key points exist in the previous example:
  5839. - :term:`SRC_URI` uses the NPM
  5840. scheme so that the NPM fetcher is used.
  5841. - ``recipetool`` collects all the license information. If a
  5842. sub-module's license is unavailable, the sub-module's name appears in
  5843. the comments.
  5844. - The ``inherit npm`` statement causes the
  5845. :ref:`npm <ref-classes-npm>` class to package
  5846. up all the modules.
  5847. You can run the following command to build the ``cute-files`` package:
  5848. ::
  5849. $ devtool build cute-files
  5850. Remember that ``nodejs`` must be installed on
  5851. the target before your package.
  5852. Assuming 192.168.7.2 for the target's IP address, use the following
  5853. command to deploy your package:
  5854. ::
  5855. $ devtool deploy-target -s cute-files root@192.168.7.2
  5856. Once the package is installed on the target, you can
  5857. test the application:
  5858. .. note::
  5859. Because of a known issue, you cannot simply run ``cute-files`` as you would
  5860. if you had run ``npm install``.
  5861. ::
  5862. $ cd /usr/lib/node_modules/cute-files
  5863. $ node cute-files.js
  5864. On a browser,
  5865. go to ``http://192.168.7.2:3000`` and you see the following:
  5866. .. image:: figures/cute-files-npm-example.png
  5867. :align: center
  5868. You can find the recipe in ``workspace/recipes/cute-files``. You can use
  5869. the recipe in any layer you choose.
  5870. Using the NPM Projects Code Method
  5871. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5872. Although it is useful to package modules already in the NPM registry,
  5873. adding ``node.js`` projects under development is a more common developer
  5874. use case.
  5875. This section covers the NPM projects code method, which is very similar
  5876. to the "registry" approach described in the previous section. In the NPM
  5877. projects method, you provide ``devtool`` with an URL that points to the
  5878. source files.
  5879. Replicating the same example, (i.e. ``cute-files``) use the following
  5880. command:
  5881. ::
  5882. $ devtool add https://github.com/martinaglv/cute-files.git
  5883. The
  5884. recipe this command generates is very similar to the recipe created in
  5885. the previous section. However, the ``SRC_URI`` looks like the following:
  5886. ::
  5887. SRC_URI = " \
  5888. git://github.com/martinaglv/cute-files.git;protocol=https \
  5889. npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \
  5890. "
  5891. In this example,
  5892. the main module is taken from the Git repository and dependencies are
  5893. taken from the NPM registry. Other than those differences, the recipe is
  5894. basically the same between the two methods. You can build and deploy the
  5895. package exactly as described in the previous section that uses the
  5896. registry modules method.
  5897. Adding custom metadata to packages
  5898. ----------------------------------
  5899. The variable
  5900. :term:`PACKAGE_ADD_METADATA`
  5901. can be used to add additional metadata to packages. This is reflected in
  5902. the package control/spec file. To take the ipk format for example, the
  5903. CONTROL file stored inside would contain the additional metadata as
  5904. additional lines.
  5905. The variable can be used in multiple ways, including using suffixes to
  5906. set it for a specific package type and/or package. Note that the order
  5907. of precedence is the same as this list:
  5908. - ``PACKAGE_ADD_METADATA_<PKGTYPE>_<PN>``
  5909. - ``PACKAGE_ADD_METADATA_<PKGTYPE>``
  5910. - ``PACKAGE_ADD_METADATA_<PN>``
  5911. - ``PACKAGE_ADD_METADATA``
  5912. `<PKGTYPE>` is a parameter and expected to be a distinct name of specific
  5913. package type:
  5914. - IPK for .ipk packages
  5915. - DEB for .deb packages
  5916. - RPM for .rpm packages
  5917. `<PN>` is a parameter and expected to be a package name.
  5918. The variable can contain multiple [one-line] metadata fields separated
  5919. by the literal sequence '\\n'. The separator can be redefined using the
  5920. variable flag ``separator``.
  5921. The following is an example that adds two custom fields for ipk
  5922. packages:
  5923. ::
  5924. PACKAGE_ADD_METADATA_IPK = "Vendor: CustomIpk\nGroup:Applications/Spreadsheets"
  5925. Efficiently Fetching Source Files During a Build
  5926. ================================================
  5927. The OpenEmbedded build system works with source files located through
  5928. the :term:`SRC_URI` variable. When
  5929. you build something using BitBake, a big part of the operation is
  5930. locating and downloading all the source tarballs. For images,
  5931. downloading all the source for various packages can take a significant
  5932. amount of time.
  5933. This section shows you how you can use mirrors to speed up fetching
  5934. source files and how you can pre-fetch files all of which leads to more
  5935. efficient use of resources and time.
  5936. Setting up Effective Mirrors
  5937. ----------------------------
  5938. A good deal that goes into a Yocto Project build is simply downloading
  5939. all of the source tarballs. Maybe you have been working with another
  5940. build system (OpenEmbedded or Angstrom) for which you have built up a
  5941. sizable directory of source tarballs. Or, perhaps someone else has such
  5942. a directory for which you have read access. If so, you can save time by
  5943. adding statements to your configuration file so that the build process
  5944. checks local directories first for existing tarballs before checking the
  5945. Internet.
  5946. Here is an efficient way to set it up in your ``local.conf`` file:
  5947. ::
  5948. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  5949. INHERIT += "own-mirrors"
  5950. BB_GENERATE_MIRROR_TARBALLS = "1"
  5951. # BB_NO_NETWORK = "1"
  5952. In the previous example, the
  5953. :term:`BB_GENERATE_MIRROR_TARBALLS`
  5954. variable causes the OpenEmbedded build system to generate tarballs of
  5955. the Git repositories and store them in the
  5956. :term:`DL_DIR` directory. Due to
  5957. performance reasons, generating and storing these tarballs is not the
  5958. build system's default behavior.
  5959. You can also use the
  5960. :term:`PREMIRRORS` variable. For
  5961. an example, see the variable's glossary entry in the Yocto Project
  5962. Reference Manual.
  5963. Getting Source Files and Suppressing the Build
  5964. ----------------------------------------------
  5965. Another technique you can use to ready yourself for a successive string
  5966. of build operations, is to pre-fetch all the source files without
  5967. actually starting a build. This technique lets you work through any
  5968. download issues and ultimately gathers all the source files into your
  5969. download directory :ref:`structure-build-downloads`,
  5970. which is located with :term:`DL_DIR`.
  5971. Use the following BitBake command form to fetch all the necessary
  5972. sources without starting the build:
  5973. ::
  5974. $ bitbake target --runall=fetch
  5975. This
  5976. variation of the BitBake command guarantees that you have all the
  5977. sources for that BitBake target should you disconnect from the Internet
  5978. and want to do the build later offline.
  5979. Selecting an Initialization Manager
  5980. ===================================
  5981. By default, the Yocto Project uses SysVinit as the initialization
  5982. manager. However, support also exists for systemd, which is a full
  5983. replacement for init with parallel starting of services, reduced shell
  5984. overhead and other features that are used by many distributions.
  5985. Within the system, SysVinit treats system components as services. These
  5986. services are maintained as shell scripts stored in the ``/etc/init.d/``
  5987. directory. Services organize into different run levels. This
  5988. organization is maintained by putting links to the services in the
  5989. ``/etc/rcN.d/`` directories, where `N/` is one of the following options:
  5990. "S", "0", "1", "2", "3", "4", "5", or "6".
  5991. .. note::
  5992. Each runlevel has a dependency on the previous runlevel. This
  5993. dependency allows the services to work properly.
  5994. In comparison, systemd treats components as units. Using units is a
  5995. broader concept as compared to using a service. A unit includes several
  5996. different types of entities. Service is one of the types of entities.
  5997. The runlevel concept in SysVinit corresponds to the concept of a target
  5998. in systemd, where target is also a type of supported unit.
  5999. In a SysVinit-based system, services load sequentially (i.e. one by one)
  6000. during init and parallelization is not supported. With systemd, services
  6001. start in parallel. Needless to say, the method can have an impact on
  6002. system startup performance.
  6003. If you want to use SysVinit, you do not have to do anything. But, if you
  6004. want to use systemd, you must take some steps as described in the
  6005. following sections.
  6006. Using systemd Exclusively
  6007. -------------------------
  6008. Set these variables in your distribution configuration file as follows:
  6009. ::
  6010. DISTRO_FEATURES_append = " systemd"
  6011. VIRTUAL-RUNTIME_init_manager = "systemd"
  6012. You can also prevent the SysVinit distribution feature from
  6013. being automatically enabled as follows:
  6014. ::
  6015. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  6016. Doing so removes any
  6017. redundant SysVinit scripts.
  6018. To remove initscripts from your image altogether, set this variable
  6019. also:
  6020. ::
  6021. VIRTUAL-RUNTIME_initscripts = ""
  6022. For information on the backfill variable, see
  6023. :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`.
  6024. Using systemd for the Main Image and Using SysVinit for the Rescue Image
  6025. ------------------------------------------------------------------------
  6026. Set these variables in your distribution configuration file as follows:
  6027. ::
  6028. DISTRO_FEATURES_append = " systemd"
  6029. VIRTUAL-RUNTIME_init_manager = "systemd"
  6030. Doing so causes your main image to use the
  6031. ``packagegroup-core-boot.bb`` recipe and systemd. The rescue/minimal
  6032. image cannot use this package group. However, it can install SysVinit
  6033. and the appropriate packages will have support for both systemd and
  6034. SysVinit.
  6035. Selecting a Device Manager
  6036. ==========================
  6037. The Yocto Project provides multiple ways to manage the device manager
  6038. (``/dev``):
  6039. - Persistent and Pre-Populated\ ``/dev``: For this case, the ``/dev``
  6040. directory is persistent and the required device nodes are created
  6041. during the build.
  6042. - Use ``devtmpfs`` with a Device Manager: For this case, the ``/dev``
  6043. directory is provided by the kernel as an in-memory file system and
  6044. is automatically populated by the kernel at runtime. Additional
  6045. configuration of device nodes is done in user space by a device
  6046. manager like ``udev`` or ``busybox-mdev``.
  6047. Using Persistent and Pre-Populated\ ``/dev``
  6048. --------------------------------------------
  6049. To use the static method for device population, you need to set the
  6050. :term:`USE_DEVFS` variable to "0"
  6051. as follows:
  6052. ::
  6053. USE_DEVFS = "0"
  6054. The content of the resulting ``/dev`` directory is defined in a Device
  6055. Table file. The
  6056. :term:`IMAGE_DEVICE_TABLES`
  6057. variable defines the Device Table to use and should be set in the
  6058. machine or distro configuration file. Alternatively, you can set this
  6059. variable in your ``local.conf`` configuration file.
  6060. If you do not define the ``IMAGE_DEVICE_TABLES`` variable, the default
  6061. ``device_table-minimal.txt`` is used:
  6062. ::
  6063. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  6064. The population is handled by the ``makedevs`` utility during image
  6065. creation:
  6066. Using ``devtmpfs`` and a Device Manager
  6067. ---------------------------------------
  6068. To use the dynamic method for device population, you need to use (or be
  6069. sure to set) the :term:`USE_DEVFS`
  6070. variable to "1", which is the default:
  6071. ::
  6072. USE_DEVFS = "1"
  6073. With this
  6074. setting, the resulting ``/dev`` directory is populated by the kernel
  6075. using ``devtmpfs``. Make sure the corresponding kernel configuration
  6076. variable ``CONFIG_DEVTMPFS`` is set when building you build a Linux
  6077. kernel.
  6078. All devices created by ``devtmpfs`` will be owned by ``root`` and have
  6079. permissions ``0600``.
  6080. To have more control over the device nodes, you can use a device manager
  6081. like ``udev`` or ``busybox-mdev``. You choose the device manager by
  6082. defining the ``VIRTUAL-RUNTIME_dev_manager`` variable in your machine or
  6083. distro configuration file. Alternatively, you can set this variable in
  6084. your ``local.conf`` configuration file:
  6085. ::
  6086. VIRTUAL-RUNTIME_dev_manager = "udev"
  6087. # Some alternative values
  6088. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  6089. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  6090. Using an External SCM
  6091. =====================
  6092. If you're working on a recipe that pulls from an external Source Code
  6093. Manager (SCM), it is possible to have the OpenEmbedded build system
  6094. notice new recipe changes added to the SCM and then build the resulting
  6095. packages that depend on the new recipes by using the latest versions.
  6096. This only works for SCMs from which it is possible to get a sensible
  6097. revision number for changes. Currently, you can do this with Apache
  6098. Subversion (SVN), Git, and Bazaar (BZR) repositories.
  6099. To enable this behavior, the :term:`PV` of
  6100. the recipe needs to reference
  6101. :term:`SRCPV`. Here is an example:
  6102. ::
  6103. PV = "1.2.3+git${SRCPV}"
  6104. Then, you can add the following to your
  6105. ``local.conf``:
  6106. ::
  6107. SRCREV_pn-PN = "${AUTOREV}"
  6108. :term:`PN` is the name of the recipe for
  6109. which you want to enable automatic source revision updating.
  6110. If you do not want to update your local configuration file, you can add
  6111. the following directly to the recipe to finish enabling the feature:
  6112. ::
  6113. SRCREV = "${AUTOREV}"
  6114. The Yocto Project provides a distribution named ``poky-bleeding``, whose
  6115. configuration file contains the line:
  6116. ::
  6117. require conf/distro/include/poky-floating-revisions.inc
  6118. This line pulls in the
  6119. listed include file that contains numerous lines of exactly that form:
  6120. ::
  6121. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  6122. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  6123. #SRCREV_pn-opkg ?= "${AUTOREV}"
  6124. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  6125. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  6126. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  6127. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  6128. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  6129. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  6130. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  6131. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  6132. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  6133. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  6134. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  6135. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  6136. SRCREV_pn-screenshot ?= "${AUTOREV}"
  6137. . . .
  6138. These lines allow you to
  6139. experiment with building a distribution that tracks the latest
  6140. development source for numerous packages.
  6141. .. note::
  6142. The ``poky-bleeding`` distribution is not tested on a regular basis. Keep
  6143. this in mind if you use it.
  6144. Creating a Read-Only Root Filesystem
  6145. ====================================
  6146. Suppose, for security reasons, you need to disable your target device's
  6147. root filesystem's write permissions (i.e. you need a read-only root
  6148. filesystem). Or, perhaps you are running the device's operating system
  6149. from a read-only storage device. For either case, you can customize your
  6150. image for that behavior.
  6151. .. note::
  6152. Supporting a read-only root filesystem requires that the system and
  6153. applications do not try to write to the root filesystem. You must
  6154. configure all parts of the target system to write elsewhere, or to
  6155. gracefully fail in the event of attempting to write to the root
  6156. filesystem.
  6157. Creating the Root Filesystem
  6158. ----------------------------
  6159. To create the read-only root filesystem, simply add the
  6160. "read-only-rootfs" feature to your image, normally in one of two ways.
  6161. The first way is to add the "read-only-rootfs" image feature in the
  6162. image's recipe file via the ``IMAGE_FEATURES`` variable:
  6163. ::
  6164. IMAGE_FEATURES += "read-only-rootfs"
  6165. As an alternative, you can add the same feature
  6166. from within your build directory's ``local.conf`` file with the
  6167. associated ``EXTRA_IMAGE_FEATURES`` variable, as in:
  6168. ::
  6169. EXTRA_IMAGE_FEATURES = "read-only-rootfs"
  6170. For more information on how to use these variables, see the
  6171. ":ref:`dev-manual/common-tasks:Customizing Images Using Custom \`\`IMAGE_FEATURES\`\` and \`\`EXTRA_IMAGE_FEATURES\`\``"
  6172. section. For information on the variables, see
  6173. :term:`IMAGE_FEATURES` and
  6174. :term:`EXTRA_IMAGE_FEATURES`.
  6175. Post-Installation Scripts and Read-Only Root Filesystem
  6176. -------------------------------------------------------
  6177. It is very important that you make sure all post-Installation
  6178. (``pkg_postinst``) scripts for packages that are installed into the
  6179. image can be run at the time when the root filesystem is created during
  6180. the build on the host system. These scripts cannot attempt to run during
  6181. first-boot on the target device. With the "read-only-rootfs" feature
  6182. enabled, the build system checks during root filesystem creation to make
  6183. sure all post-installation scripts succeed. If any of these scripts
  6184. still need to be run after the root filesystem is created, the build
  6185. immediately fails. These build-time checks ensure that the build fails
  6186. rather than the target device fails later during its initial boot
  6187. operation.
  6188. Most of the common post-installation scripts generated by the build
  6189. system for the out-of-the-box Yocto Project are engineered so that they
  6190. can run during root filesystem creation (e.g. post-installation scripts
  6191. for caching fonts). However, if you create and add custom scripts, you
  6192. need to be sure they can be run during this file system creation.
  6193. Here are some common problems that prevent post-installation scripts
  6194. from running during root filesystem creation:
  6195. - *Not using $D in front of absolute paths:* The build system defines
  6196. ``$``\ :term:`D` when the root
  6197. filesystem is created. Furthermore, ``$D`` is blank when the script
  6198. is run on the target device. This implies two purposes for ``$D``:
  6199. ensuring paths are valid in both the host and target environments,
  6200. and checking to determine which environment is being used as a method
  6201. for taking appropriate actions.
  6202. - *Attempting to run processes that are specific to or dependent on the
  6203. target architecture:* You can work around these attempts by using
  6204. native tools, which run on the host system, to accomplish the same
  6205. tasks, or by alternatively running the processes under QEMU, which
  6206. has the ``qemu_run_binary`` function. For more information, see the
  6207. :ref:`qemu <ref-classes-qemu>` class.
  6208. Areas With Write Access
  6209. -----------------------
  6210. With the "read-only-rootfs" feature enabled, any attempt by the target
  6211. to write to the root filesystem at runtime fails. Consequently, you must
  6212. make sure that you configure processes and applications that attempt
  6213. these types of writes do so to directories with write access (e.g.
  6214. ``/tmp`` or ``/var/run``).
  6215. Maintaining Build Output Quality
  6216. ================================
  6217. Many factors can influence the quality of a build. For example, if you
  6218. upgrade a recipe to use a new version of an upstream software package or
  6219. you experiment with some new configuration options, subtle changes can
  6220. occur that you might not detect until later. Consider the case where
  6221. your recipe is using a newer version of an upstream package. In this
  6222. case, a new version of a piece of software might introduce an optional
  6223. dependency on another library, which is auto-detected. If that library
  6224. has already been built when the software is building, the software will
  6225. link to the built library and that library will be pulled into your
  6226. image along with the new software even if you did not want the library.
  6227. The :ref:`buildhistory <ref-classes-buildhistory>`
  6228. class exists to help you maintain the quality of your build output. You
  6229. can use the class to highlight unexpected and possibly unwanted changes
  6230. in the build output. When you enable build history, it records
  6231. information about the contents of each package and image and then
  6232. commits that information to a local Git repository where you can examine
  6233. the information.
  6234. The remainder of this section describes the following:
  6235. - :ref:`How you can enable and disable build history <dev-manual/common-tasks:enabling and disabling build history>`
  6236. - :ref:`How to understand what the build history contains <dev-manual/common-tasks:understanding what the build history contains>`
  6237. - :ref:`How to limit the information used for build history <dev-manual/common-tasks:using build history to gather image information only>`
  6238. - :ref:`How to examine the build history from both a command-line and web interface <dev-manual/common-tasks:examining build history information>`
  6239. Enabling and Disabling Build History
  6240. ------------------------------------
  6241. Build history is disabled by default. To enable it, add the following
  6242. ``INHERIT`` statement and set the
  6243. :term:`BUILDHISTORY_COMMIT`
  6244. variable to "1" at the end of your ``conf/local.conf`` file found in the
  6245. :term:`Build Directory`:
  6246. ::
  6247. INHERIT += "buildhistory"
  6248. BUILDHISTORY_COMMIT = "1"
  6249. Enabling build history as
  6250. previously described causes the OpenEmbedded build system to collect
  6251. build output information and commit it as a single commit to a local
  6252. :ref:`overview-manual/development-environment:git` repository.
  6253. .. note::
  6254. Enabling build history increases your build times slightly,
  6255. particularly for images, and increases the amount of disk space used
  6256. during the build.
  6257. You can disable build history by removing the previous statements from
  6258. your ``conf/local.conf`` file.
  6259. Understanding What the Build History Contains
  6260. ---------------------------------------------
  6261. Build history information is kept in
  6262. ``${``\ :term:`TOPDIR`\ ``}/buildhistory``
  6263. in the Build Directory as defined by the
  6264. :term:`BUILDHISTORY_DIR`
  6265. variable. The following is an example abbreviated listing:
  6266. .. image:: figures/buildhistory.png
  6267. :align: center
  6268. At the top level, a ``metadata-revs`` file exists that lists the
  6269. revisions of the repositories for the enabled layers when the build was
  6270. produced. The rest of the data splits into separate ``packages``,
  6271. ``images`` and ``sdk`` directories, the contents of which are described
  6272. as follows.
  6273. Build History Package Information
  6274. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6275. The history for each package contains a text file that has name-value
  6276. pairs with information about the package. For example,
  6277. ``buildhistory/packages/i586-poky-linux/busybox/busybox/latest``
  6278. contains the following:
  6279. .. code-block:: none
  6280. PV = 1.22.1
  6281. PR = r32
  6282. RPROVIDES =
  6283. RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
  6284. RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
  6285. PKGSIZE = 540168
  6286. FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
  6287. /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
  6288. /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
  6289. /usr/share/pixmaps /usr/share/applications /usr/share/idl \
  6290. /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
  6291. FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
  6292. /etc/busybox.links.nosuid /etc/busybox.links.suid
  6293. Most of these
  6294. name-value pairs correspond to variables used to produce the package.
  6295. The exceptions are ``FILELIST``, which is the actual list of files in
  6296. the package, and ``PKGSIZE``, which is the total size of files in the
  6297. package in bytes.
  6298. A file also exists that corresponds to the recipe from which the package
  6299. came (e.g. ``buildhistory/packages/i586-poky-linux/busybox/latest``):
  6300. .. code-block:: none
  6301. PV = 1.22.1
  6302. PR = r32
  6303. DEPENDS = initscripts kern-tools-native update-rc.d-native \
  6304. virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
  6305. virtual/libc virtual/update-alternatives
  6306. PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
  6307. busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
  6308. busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
  6309. Finally, for those recipes fetched from a version control system (e.g.,
  6310. Git), a file exists that lists source revisions that are specified in
  6311. the recipe and lists the actual revisions used during the build. Listed
  6312. and actual revisions might differ when
  6313. :term:`SRCREV` is set to
  6314. ${:term:`AUTOREV`}. Here is an
  6315. example assuming
  6316. ``buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev``):
  6317. ::
  6318. # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  6319. SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  6320. # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  6321. SRCREV_meta ="a227f20eff056e511d504b2e490f3774ab260d6f"
  6322. You can use the
  6323. ``buildhistory-collect-srcrevs`` command with the ``-a`` option to
  6324. collect the stored ``SRCREV`` values from build history and report them
  6325. in a format suitable for use in global configuration (e.g.,
  6326. ``local.conf`` or a distro include file) to override floating
  6327. ``AUTOREV`` values to a fixed set of revisions. Here is some example
  6328. output from this command:
  6329. ::
  6330. $ buildhistory-collect-srcrevs -a
  6331. # i586-poky-linux
  6332. SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
  6333. SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
  6334. SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
  6335. SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  6336. # x86_64-linux
  6337. SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
  6338. SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
  6339. SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
  6340. SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
  6341. SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
  6342. SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
  6343. SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
  6344. SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
  6345. SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  6346. # qemux86-poky-linux
  6347. SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  6348. SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
  6349. # all-poky-linux
  6350. SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
  6351. .. note::
  6352. Here are some notes on using the ``buildhistory-collect-srcrevs`` command:
  6353. - By default, only values where the ``SRCREV`` was not hardcoded
  6354. (usually when ``AUTOREV`` is used) are reported. Use the ``-a``
  6355. option to see all ``SRCREV`` values.
  6356. - The output statements might not have any effect if overrides are
  6357. applied elsewhere in the build system configuration. Use the
  6358. ``-f`` option to add the ``forcevariable`` override to each output
  6359. line if you need to work around this restriction.
  6360. - The script does apply special handling when building for multiple
  6361. machines. However, the script does place a comment before each set
  6362. of values that specifies which triplet to which they belong as
  6363. previously shown (e.g., ``i586-poky-linux``).
  6364. Build History Image Information
  6365. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6366. The files produced for each image are as follows:
  6367. - ``image-files:`` A directory containing selected files from the root
  6368. filesystem. The files are defined by
  6369. :term:`BUILDHISTORY_IMAGE_FILES`.
  6370. - ``build-id.txt:`` Human-readable information about the build
  6371. configuration and metadata source revisions. This file contains the
  6372. full build header as printed by BitBake.
  6373. - ``*.dot:`` Dependency graphs for the image that are compatible with
  6374. ``graphviz``.
  6375. - ``files-in-image.txt:`` A list of files in the image with
  6376. permissions, owner, group, size, and symlink information.
  6377. - ``image-info.txt:`` A text file containing name-value pairs with
  6378. information about the image. See the following listing example for
  6379. more information.
  6380. - ``installed-package-names.txt:`` A list of installed packages by name
  6381. only.
  6382. - ``installed-package-sizes.txt:`` A list of installed packages ordered
  6383. by size.
  6384. - ``installed-packages.txt:`` A list of installed packages with full
  6385. package filenames.
  6386. .. note::
  6387. Installed package information is able to be gathered and produced
  6388. even if package management is disabled for the final image.
  6389. Here is an example of ``image-info.txt``:
  6390. .. code-block:: none
  6391. DISTRO = poky
  6392. DISTRO_VERSION = 1.7
  6393. USER_CLASSES = buildstats image-mklibs image-prelink
  6394. IMAGE_CLASSES = image_types
  6395. IMAGE_FEATURES = debug-tweaks
  6396. IMAGE_LINGUAS =
  6397. IMAGE_INSTALL = packagegroup-core-boot run-postinsts
  6398. BAD_RECOMMENDATIONS =
  6399. NO_RECOMMENDATIONS =
  6400. PACKAGE_EXCLUDE =
  6401. ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
  6402. write_image_manifest ; buildhistory_list_installed_image ; \
  6403. buildhistory_get_image_installed ; ssh_allow_empty_password; \
  6404. postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
  6405. IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
  6406. IMAGESIZE = 6900
  6407. Other than ``IMAGESIZE``,
  6408. which is the total size of the files in the image in Kbytes, the
  6409. name-value pairs are variables that may have influenced the content of
  6410. the image. This information is often useful when you are trying to
  6411. determine why a change in the package or file listings has occurred.
  6412. Using Build History to Gather Image Information Only
  6413. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6414. As you can see, build history produces image information, including
  6415. dependency graphs, so you can see why something was pulled into the
  6416. image. If you are just interested in this information and not interested
  6417. in collecting specific package or SDK information, you can enable
  6418. writing only image information without any history by adding the
  6419. following to your ``conf/local.conf`` file found in the
  6420. :term:`Build Directory`:
  6421. ::
  6422. INHERIT += "buildhistory"
  6423. BUILDHISTORY_COMMIT = "0"
  6424. BUILDHISTORY_FEATURES = "image"
  6425. Here, you set the
  6426. :term:`BUILDHISTORY_FEATURES`
  6427. variable to use the image feature only.
  6428. Build History SDK Information
  6429. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6430. Build history collects similar information on the contents of SDKs (e.g.
  6431. ``bitbake -c populate_sdk imagename``) as compared to information it
  6432. collects for images. Furthermore, this information differs depending on
  6433. whether an extensible or standard SDK is being produced.
  6434. The following list shows the files produced for SDKs:
  6435. - ``files-in-sdk.txt:`` A list of files in the SDK with permissions,
  6436. owner, group, size, and symlink information. This list includes both
  6437. the host and target parts of the SDK.
  6438. - ``sdk-info.txt:`` A text file containing name-value pairs with
  6439. information about the SDK. See the following listing example for more
  6440. information.
  6441. - ``sstate-task-sizes.txt:`` A text file containing name-value pairs
  6442. with information about task group sizes (e.g. ``do_populate_sysroot``
  6443. tasks have a total size). The ``sstate-task-sizes.txt`` file exists
  6444. only when an extensible SDK is created.
  6445. - ``sstate-package-sizes.txt:`` A text file containing name-value pairs
  6446. with information for the shared-state packages and sizes in the SDK.
  6447. The ``sstate-package-sizes.txt`` file exists only when an extensible
  6448. SDK is created.
  6449. - ``sdk-files:`` A folder that contains copies of the files mentioned
  6450. in ``BUILDHISTORY_SDK_FILES`` if the files are present in the output.
  6451. Additionally, the default value of ``BUILDHISTORY_SDK_FILES`` is
  6452. specific to the extensible SDK although you can set it differently if
  6453. you would like to pull in specific files from the standard SDK.
  6454. The default files are ``conf/local.conf``, ``conf/bblayers.conf``,
  6455. ``conf/auto.conf``, ``conf/locked-sigs.inc``, and
  6456. ``conf/devtool.conf``. Thus, for an extensible SDK, these files get
  6457. copied into the ``sdk-files`` directory.
  6458. - The following information appears under each of the ``host`` and
  6459. ``target`` directories for the portions of the SDK that run on the
  6460. host and on the target, respectively:
  6461. .. note::
  6462. The following files for the most part are empty when producing an
  6463. extensible SDK because this type of SDK is not constructed from
  6464. packages as is the standard SDK.
  6465. - ``depends.dot:`` Dependency graph for the SDK that is compatible
  6466. with ``graphviz``.
  6467. - ``installed-package-names.txt:`` A list of installed packages by
  6468. name only.
  6469. - ``installed-package-sizes.txt:`` A list of installed packages
  6470. ordered by size.
  6471. - ``installed-packages.txt:`` A list of installed packages with full
  6472. package filenames.
  6473. Here is an example of ``sdk-info.txt``:
  6474. .. code-block:: none
  6475. DISTRO = poky
  6476. DISTRO_VERSION = 1.3+snapshot-20130327
  6477. SDK_NAME = poky-glibc-i686-arm
  6478. SDK_VERSION = 1.3+snapshot
  6479. SDKMACHINE =
  6480. SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
  6481. BAD_RECOMMENDATIONS =
  6482. SDKSIZE = 352712
  6483. Other than ``SDKSIZE``, which is
  6484. the total size of the files in the SDK in Kbytes, the name-value pairs
  6485. are variables that might have influenced the content of the SDK. This
  6486. information is often useful when you are trying to determine why a
  6487. change in the package or file listings has occurred.
  6488. Examining Build History Information
  6489. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6490. You can examine build history output from the command line or from a web
  6491. interface.
  6492. To see any changes that have occurred (assuming you have
  6493. :term:`BUILDHISTORY_COMMIT` = "1"),
  6494. you can simply use any Git command that allows you to view the history
  6495. of a repository. Here is one method:
  6496. ::
  6497. $ git log -p
  6498. You need to realize,
  6499. however, that this method does show changes that are not significant
  6500. (e.g. a package's size changing by a few bytes).
  6501. A command-line tool called ``buildhistory-diff`` does exist, though,
  6502. that queries the Git repository and prints just the differences that
  6503. might be significant in human-readable form. Here is an example:
  6504. ::
  6505. $ poky/poky/scripts/buildhistory-diff . HEAD^
  6506. Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
  6507. /etc/anotherpkg.conf was added
  6508. /sbin/anotherpkg was added
  6509. * (installed-package-names.txt):
  6510. * anotherpkg was added
  6511. Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
  6512. anotherpkg was added
  6513. packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
  6514. * PR changed from "r0" to "r1"
  6515. * PV changed from "0.1.10" to "0.1.12"
  6516. packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
  6517. * PR changed from "r0" to "r1"
  6518. * PV changed from "0.1.10" to "0.1.12"
  6519. .. note::
  6520. The ``buildhistory-diff`` tool requires the ``GitPython``
  6521. package. Be sure to install it using Pip3 as follows:
  6522. ::
  6523. $ pip3 install GitPython --user
  6524. Alternatively, you can install ``python3-git`` using the appropriate
  6525. distribution package manager (e.g. ``apt-get``, ``dnf``, or ``zipper``).
  6526. To see changes to the build history using a web interface, follow the
  6527. instruction in the ``README`` file
  6528. :yocto_git:`here </buildhistory-web/>`.
  6529. Here is a sample screenshot of the interface:
  6530. .. image:: figures/buildhistory-web.png
  6531. :align: center
  6532. Performing Automated Runtime Testing
  6533. ====================================
  6534. The OpenEmbedded build system makes available a series of automated
  6535. tests for images to verify runtime functionality. You can run these
  6536. tests on either QEMU or actual target hardware. Tests are written in
  6537. Python making use of the ``unittest`` module, and the majority of them
  6538. run commands on the target system over SSH. This section describes how
  6539. you set up the environment to use these tests, run available tests, and
  6540. write and add your own tests.
  6541. For information on the test and QA infrastructure available within the
  6542. Yocto Project, see the ":ref:`ref-manual/release-process:testing and quality assurance`"
  6543. section in the Yocto Project Reference Manual.
  6544. Enabling Tests
  6545. --------------
  6546. Depending on whether you are planning to run tests using QEMU or on the
  6547. hardware, you have to take different steps to enable the tests. See the
  6548. following subsections for information on how to enable both types of
  6549. tests.
  6550. Enabling Runtime Tests on QEMU
  6551. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6552. In order to run tests, you need to do the following:
  6553. - *Set up to avoid interaction with sudo for networking:* To
  6554. accomplish this, you must do one of the following:
  6555. - Add ``NOPASSWD`` for your user in ``/etc/sudoers`` either for all
  6556. commands or just for ``runqemu-ifup``. You must provide the full
  6557. path as that can change if you are using multiple clones of the
  6558. source repository.
  6559. .. note::
  6560. On some distributions, you also need to comment out "Defaults
  6561. requiretty" in ``/etc/sudoers``.
  6562. - Manually configure a tap interface for your system.
  6563. - Run as root the script in ``scripts/runqemu-gen-tapdevs``, which
  6564. should generate a list of tap devices. This is the option
  6565. typically chosen for Autobuilder-type environments.
  6566. .. note::
  6567. - Be sure to use an absolute path when calling this script
  6568. with sudo.
  6569. - The package recipe ``qemu-helper-native`` is required to run
  6570. this script. Build the package using the following command:
  6571. ::
  6572. $ bitbake qemu-helper-native
  6573. - *Set the DISPLAY variable:* You need to set this variable so that
  6574. you have an X server available (e.g. start ``vncserver`` for a
  6575. headless machine).
  6576. - *Be sure your host's firewall accepts incoming connections from
  6577. 192.168.7.0/24:* Some of the tests (in particular DNF tests) start an
  6578. HTTP server on a random high number port, which is used to serve
  6579. files to the target. The DNF module serves
  6580. ``${WORKDIR}/oe-rootfs-repo`` so it can run DNF channel commands.
  6581. That means your host's firewall must accept incoming connections from
  6582. 192.168.7.0/24, which is the default IP range used for tap devices by
  6583. ``runqemu``.
  6584. - *Be sure your host has the correct packages installed:* Depending
  6585. your host's distribution, you need to have the following packages
  6586. installed:
  6587. - Ubuntu and Debian: ``sysstat`` and ``iproute2``
  6588. - openSUSE: ``sysstat`` and ``iproute2``
  6589. - Fedora: ``sysstat`` and ``iproute``
  6590. - CentOS: ``sysstat`` and ``iproute``
  6591. Once you start running the tests, the following happens:
  6592. 1. A copy of the root filesystem is written to ``${WORKDIR}/testimage``.
  6593. 2. The image is booted under QEMU using the standard ``runqemu`` script.
  6594. 3. A default timeout of 500 seconds occurs to allow for the boot process
  6595. to reach the login prompt. You can change the timeout period by
  6596. setting
  6597. :term:`TEST_QEMUBOOT_TIMEOUT`
  6598. in the ``local.conf`` file.
  6599. 4. Once the boot process is reached and the login prompt appears, the
  6600. tests run. The full boot log is written to
  6601. ``${WORKDIR}/testimage/qemu_boot_log``.
  6602. 5. Each test module loads in the order found in ``TEST_SUITES``. You can
  6603. find the full output of the commands run over SSH in
  6604. ``${WORKDIR}/testimgage/ssh_target_log``.
  6605. 6. If no failures occur, the task running the tests ends successfully.
  6606. You can find the output from the ``unittest`` in the task log at
  6607. ``${WORKDIR}/temp/log.do_testimage``.
  6608. Enabling Runtime Tests on Hardware
  6609. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6610. The OpenEmbedded build system can run tests on real hardware, and for
  6611. certain devices it can also deploy the image to be tested onto the
  6612. device beforehand.
  6613. For automated deployment, a "master image" is installed onto the
  6614. hardware once as part of setup. Then, each time tests are to be run, the
  6615. following occurs:
  6616. 1. The master image is booted into and used to write the image to be
  6617. tested to a second partition.
  6618. 2. The device is then rebooted using an external script that you need to
  6619. provide.
  6620. 3. The device boots into the image to be tested.
  6621. When running tests (independent of whether the image has been deployed
  6622. automatically or not), the device is expected to be connected to a
  6623. network on a pre-determined IP address. You can either use static IP
  6624. addresses written into the image, or set the image to use DHCP and have
  6625. your DHCP server on the test network assign a known IP address based on
  6626. the MAC address of the device.
  6627. In order to run tests on hardware, you need to set ``TEST_TARGET`` to an
  6628. appropriate value. For QEMU, you do not have to change anything, the
  6629. default value is "qemu". For running tests on hardware, the following
  6630. options exist:
  6631. - *"simpleremote":* Choose "simpleremote" if you are going to run tests
  6632. on a target system that is already running the image to be tested and
  6633. is available on the network. You can use "simpleremote" in
  6634. conjunction with either real hardware or an image running within a
  6635. separately started QEMU or any other virtual machine manager.
  6636. - *"SystemdbootTarget":* Choose "SystemdbootTarget" if your hardware is
  6637. an EFI-based machine with ``systemd-boot`` as bootloader and
  6638. ``core-image-testmaster`` (or something similar) is installed. Also,
  6639. your hardware under test must be in a DHCP-enabled network that gives
  6640. it the same IP address for each reboot.
  6641. If you choose "SystemdbootTarget", there are additional requirements
  6642. and considerations. See the
  6643. ":ref:`dev-manual/common-tasks:selecting systemdboottarget`" section, which
  6644. follows, for more information.
  6645. - *"BeagleBoneTarget":* Choose "BeagleBoneTarget" if you are deploying
  6646. images and running tests on the BeagleBone "Black" or original
  6647. "White" hardware. For information on how to use these tests, see the
  6648. comments at the top of the BeagleBoneTarget
  6649. ``meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py`` file.
  6650. - *"EdgeRouterTarget":* Choose "EdgeRouterTarget" if you are deploying
  6651. images and running tests on the Ubiquiti Networks EdgeRouter Lite.
  6652. For information on how to use these tests, see the comments at the
  6653. top of the EdgeRouterTarget
  6654. ``meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py`` file.
  6655. - *"GrubTarget":* Choose "GrubTarget" if you are deploying images and running
  6656. tests on any generic PC that boots using GRUB. For information on how
  6657. to use these tests, see the comments at the top of the GrubTarget
  6658. ``meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py`` file.
  6659. - *"your-target":* Create your own custom target if you want to run
  6660. tests when you are deploying images and running tests on a custom
  6661. machine within your BSP layer. To do this, you need to add a Python
  6662. unit that defines the target class under ``lib/oeqa/controllers/``
  6663. within your layer. You must also provide an empty ``__init__.py``.
  6664. For examples, see files in ``meta-yocto-bsp/lib/oeqa/controllers/``.
  6665. Selecting SystemdbootTarget
  6666. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6667. If you did not set ``TEST_TARGET`` to "SystemdbootTarget", then you do
  6668. not need any information in this section. You can skip down to the
  6669. ":ref:`dev-manual/common-tasks:running tests`" section.
  6670. If you did set ``TEST_TARGET`` to "SystemdbootTarget", you also need to
  6671. perform a one-time setup of your master image by doing the following:
  6672. 1. *Set EFI_PROVIDER:* Be sure that ``EFI_PROVIDER`` is as follows:
  6673. ::
  6674. EFI_PROVIDER = "systemd-boot"
  6675. 2. *Build the master image:* Build the ``core-image-testmaster`` image.
  6676. The ``core-image-testmaster`` recipe is provided as an example for a
  6677. "master" image and you can customize the image recipe as you would
  6678. any other recipe.
  6679. Here are the image recipe requirements:
  6680. - Inherits ``core-image`` so that kernel modules are installed.
  6681. - Installs normal linux utilities not BusyBox ones (e.g. ``bash``,
  6682. ``coreutils``, ``tar``, ``gzip``, and ``kmod``).
  6683. - Uses a custom Initial RAM Disk (initramfs) image with a custom
  6684. installer. A normal image that you can install usually creates a
  6685. single rootfs partition. This image uses another installer that
  6686. creates a specific partition layout. Not all Board Support
  6687. Packages (BSPs) can use an installer. For such cases, you need to
  6688. manually create the following partition layout on the target:
  6689. - First partition mounted under ``/boot``, labeled "boot".
  6690. - The main rootfs partition where this image gets installed,
  6691. which is mounted under ``/``.
  6692. - Another partition labeled "testrootfs" where test images get
  6693. deployed.
  6694. 3. *Install image:* Install the image that you just built on the target
  6695. system.
  6696. The final thing you need to do when setting ``TEST_TARGET`` to
  6697. "SystemdbootTarget" is to set up the test image:
  6698. 1. *Set up your local.conf file:* Make sure you have the following
  6699. statements in your ``local.conf`` file:
  6700. ::
  6701. IMAGE_FSTYPES += "tar.gz"
  6702. INHERIT += "testimage"
  6703. TEST_TARGET = "SystemdbootTarget"
  6704. TEST_TARGET_IP = "192.168.2.3"
  6705. 2. *Build your test image:* Use BitBake to build the image:
  6706. ::
  6707. $ bitbake core-image-sato
  6708. Power Control
  6709. ~~~~~~~~~~~~~
  6710. For most hardware targets other than "simpleremote", you can control
  6711. power:
  6712. - You can use ``TEST_POWERCONTROL_CMD`` together with
  6713. ``TEST_POWERCONTROL_EXTRA_ARGS`` as a command that runs on the host
  6714. and does power cycling. The test code passes one argument to that
  6715. command: off, on or cycle (off then on). Here is an example that
  6716. could appear in your ``local.conf`` file:
  6717. ::
  6718. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  6719. In this example, the expect
  6720. script does the following:
  6721. .. code-block:: shell
  6722. ssh test@10.11.12.1 "pyctl nuc1 arg"
  6723. It then runs a Python script that controls power for a label called
  6724. ``nuc1``.
  6725. .. note::
  6726. You need to customize ``TEST_POWERCONTROL_CMD`` and
  6727. ``TEST_POWERCONTROL_EXTRA_ARGS`` for your own setup. The one requirement
  6728. is that it accepts "on", "off", and "cycle" as the last argument.
  6729. - When no command is defined, it connects to the device over SSH and
  6730. uses the classic reboot command to reboot the device. Classic reboot
  6731. is fine as long as the machine actually reboots (i.e. the SSH test
  6732. has not failed). It is useful for scenarios where you have a simple
  6733. setup, typically with a single board, and where some manual
  6734. interaction is okay from time to time.
  6735. If you have no hardware to automatically perform power control but still
  6736. wish to experiment with automated hardware testing, you can use the
  6737. ``dialog-power-control`` script that shows a dialog prompting you to perform
  6738. the required power action. This script requires either KDialog or Zenity
  6739. to be installed. To use this script, set the
  6740. :term:`TEST_POWERCONTROL_CMD`
  6741. variable as follows:
  6742. ::
  6743. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  6744. Serial Console Connection
  6745. ~~~~~~~~~~~~~~~~~~~~~~~~~
  6746. For test target classes requiring a serial console to interact with the
  6747. bootloader (e.g. BeagleBoneTarget, EdgeRouterTarget, and GrubTarget),
  6748. you need to specify a command to use to connect to the serial console of
  6749. the target machine by using the
  6750. :term:`TEST_SERIALCONTROL_CMD`
  6751. variable and optionally the
  6752. :term:`TEST_SERIALCONTROL_EXTRA_ARGS`
  6753. variable.
  6754. These cases could be a serial terminal program if the machine is
  6755. connected to a local serial port, or a ``telnet`` or ``ssh`` command
  6756. connecting to a remote console server. Regardless of the case, the
  6757. command simply needs to connect to the serial console and forward that
  6758. connection to standard input and output as any normal terminal program
  6759. does. For example, to use the picocom terminal program on serial device
  6760. ``/dev/ttyUSB0`` at 115200bps, you would set the variable as follows:
  6761. ::
  6762. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  6763. For local
  6764. devices where the serial port device disappears when the device reboots,
  6765. an additional "serdevtry" wrapper script is provided. To use this
  6766. wrapper, simply prefix the terminal command with
  6767. ``${COREBASE}/scripts/contrib/serdevtry``:
  6768. ::
  6769. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b 115200 /dev/ttyUSB0"
  6770. Running Tests
  6771. -------------
  6772. You can start the tests automatically or manually:
  6773. - *Automatically running tests:* To run the tests automatically after
  6774. the OpenEmbedded build system successfully creates an image, first
  6775. set the
  6776. :term:`TESTIMAGE_AUTO`
  6777. variable to "1" in your ``local.conf`` file in the
  6778. :term:`Build Directory`:
  6779. ::
  6780. TESTIMAGE_AUTO = "1"
  6781. Next, build your image. If the image successfully builds, the
  6782. tests run:
  6783. ::
  6784. bitbake core-image-sato
  6785. - *Manually running tests:* To manually run the tests, first globally
  6786. inherit the
  6787. :ref:`testimage <ref-classes-testimage*>` class
  6788. by editing your ``local.conf`` file:
  6789. ::
  6790. INHERIT += "testimage"
  6791. Next, use BitBake to run the tests:
  6792. ::
  6793. bitbake -c testimage image
  6794. All test files reside in ``meta/lib/oeqa/runtime`` in the
  6795. :term:`Source Directory`. A test name maps
  6796. directly to a Python module. Each test module may contain a number of
  6797. individual tests. Tests are usually grouped together by the area tested
  6798. (e.g tests for systemd reside in ``meta/lib/oeqa/runtime/systemd.py``).
  6799. You can add tests to any layer provided you place them in the proper
  6800. area and you extend :term:`BBPATH` in
  6801. the ``local.conf`` file as normal. Be sure that tests reside in
  6802. ``layer/lib/oeqa/runtime``.
  6803. .. note::
  6804. Be sure that module names do not collide with module names used in
  6805. the default set of test modules in ``meta/lib/oeqa/runtime``.
  6806. You can change the set of tests run by appending or overriding
  6807. :term:`TEST_SUITES` variable in
  6808. ``local.conf``. Each name in ``TEST_SUITES`` represents a required test
  6809. for the image. Test modules named within ``TEST_SUITES`` cannot be
  6810. skipped even if a test is not suitable for an image (e.g. running the
  6811. RPM tests on an image without ``rpm``). Appending "auto" to
  6812. ``TEST_SUITES`` causes the build system to try to run all tests that are
  6813. suitable for the image (i.e. each test module may elect to skip itself).
  6814. The order you list tests in ``TEST_SUITES`` is important and influences
  6815. test dependencies. Consequently, tests that depend on other tests should
  6816. be added after the test on which they depend. For example, since the
  6817. ``ssh`` test depends on the ``ping`` test, "ssh" needs to come after
  6818. "ping" in the list. The test class provides no re-ordering or dependency
  6819. handling.
  6820. .. note::
  6821. Each module can have multiple classes with multiple test methods.
  6822. And, Python ``unittest`` rules apply.
  6823. Here are some things to keep in mind when running tests:
  6824. - The default tests for the image are defined as:
  6825. ::
  6826. DEFAULT_TEST_SUITES_pn-image = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  6827. - Add your own test to the list of the by using the following:
  6828. ::
  6829. TEST_SUITES_append = " mytest"
  6830. - Run a specific list of tests as follows:
  6831. ::
  6832. TEST_SUITES = "test1 test2 test3"
  6833. Remember, order is important. Be sure to place a test that is
  6834. dependent on another test later in the order.
  6835. Exporting Tests
  6836. ---------------
  6837. You can export tests so that they can run independently of the build
  6838. system. Exporting tests is required if you want to be able to hand the
  6839. test execution off to a scheduler. You can only export tests that are
  6840. defined in :term:`TEST_SUITES`.
  6841. If your image is already built, make sure the following are set in your
  6842. ``local.conf`` file:
  6843. ::
  6844. INHERIT += "testexport"
  6845. TEST_TARGET_IP = "IP-address-for-the-test-target"
  6846. TEST_SERVER_IP = "IP-address-for-the-test-server"
  6847. You can then export the tests with the
  6848. following BitBake command form:
  6849. ::
  6850. $ bitbake image -c testexport
  6851. Exporting the tests places them in the
  6852. :term:`Build Directory` in
  6853. ``tmp/testexport/``\ image, which is controlled by the
  6854. ``TEST_EXPORT_DIR`` variable.
  6855. You can now run the tests outside of the build environment:
  6856. ::
  6857. $ cd tmp/testexport/image
  6858. $ ./runexported.py testdata.json
  6859. Here is a complete example that shows IP addresses and uses the
  6860. ``core-image-sato`` image:
  6861. ::
  6862. INHERIT += "testexport"
  6863. TEST_TARGET_IP = "192.168.7.2"
  6864. TEST_SERVER_IP = "192.168.7.1"
  6865. Use BitBake to export the tests:
  6866. ::
  6867. $ bitbake core-image-sato -c testexport
  6868. Run the tests outside of
  6869. the build environment using the following:
  6870. ::
  6871. $ cd tmp/testexport/core-image-sato
  6872. $ ./runexported.py testdata.json
  6873. Writing New Tests
  6874. -----------------
  6875. As mentioned previously, all new test files need to be in the proper
  6876. place for the build system to find them. New tests for additional
  6877. functionality outside of the core should be added to the layer that adds
  6878. the functionality, in ``layer/lib/oeqa/runtime`` (as long as
  6879. :term:`BBPATH` is extended in the
  6880. layer's ``layer.conf`` file as normal). Just remember the following:
  6881. - Filenames need to map directly to test (module) names.
  6882. - Do not use module names that collide with existing core tests.
  6883. - Minimally, an empty ``__init__.py`` file must exist in the runtime
  6884. directory.
  6885. To create a new test, start by copying an existing module (e.g.
  6886. ``syslog.py`` or ``gcc.py`` are good ones to use). Test modules can use
  6887. code from ``meta/lib/oeqa/utils``, which are helper classes.
  6888. .. note::
  6889. Structure shell commands such that you rely on them and they return a
  6890. single code for success. Be aware that sometimes you will need to
  6891. parse the output. See the ``df.py`` and ``date.py`` modules for examples.
  6892. You will notice that all test classes inherit ``oeRuntimeTest``, which
  6893. is found in ``meta/lib/oetest.py``. This base class offers some helper
  6894. attributes, which are described in the following sections:
  6895. Class Methods
  6896. ~~~~~~~~~~~~~
  6897. Class methods are as follows:
  6898. - *hasPackage(pkg):* Returns "True" if ``pkg`` is in the installed
  6899. package list of the image, which is based on the manifest file that
  6900. is generated during the ``do_rootfs`` task.
  6901. - *hasFeature(feature):* Returns "True" if the feature is in
  6902. :term:`IMAGE_FEATURES` or
  6903. :term:`DISTRO_FEATURES`.
  6904. Class Attributes
  6905. ~~~~~~~~~~~~~~~~
  6906. Class attributes are as follows:
  6907. - *pscmd:* Equals "ps -ef" if ``procps`` is installed in the image.
  6908. Otherwise, ``pscmd`` equals "ps" (busybox).
  6909. - *tc:* The called test context, which gives access to the
  6910. following attributes:
  6911. - *d:* The BitBake datastore, which allows you to use stuff such
  6912. as ``oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")``.
  6913. - *testslist and testsrequired:* Used internally. The tests
  6914. do not need these.
  6915. - *filesdir:* The absolute path to
  6916. ``meta/lib/oeqa/runtime/files``, which contains helper files for
  6917. tests meant for copying on the target such as small files written
  6918. in C for compilation.
  6919. - *target:* The target controller object used to deploy and
  6920. start an image on a particular target (e.g. Qemu, SimpleRemote,
  6921. and SystemdbootTarget). Tests usually use the following:
  6922. - *ip:* The target's IP address.
  6923. - *server_ip:* The host's IP address, which is usually used
  6924. by the DNF test suite.
  6925. - *run(cmd, timeout=None):* The single, most used method.
  6926. This command is a wrapper for: ``ssh root@host "cmd"``. The
  6927. command returns a tuple: (status, output), which are what their
  6928. names imply - the return code of "cmd" and whatever output it
  6929. produces. The optional timeout argument represents the number
  6930. of seconds the test should wait for "cmd" to return. If the
  6931. argument is "None", the test uses the default instance's
  6932. timeout period, which is 300 seconds. If the argument is "0",
  6933. the test runs until the command returns.
  6934. - *copy_to(localpath, remotepath):*
  6935. ``scp localpath root@ip:remotepath``.
  6936. - *copy_from(remotepath, localpath):*
  6937. ``scp root@host:remotepath localpath``.
  6938. Instance Attributes
  6939. ~~~~~~~~~~~~~~~~~~~
  6940. A single instance attribute exists, which is ``target``. The ``target``
  6941. instance attribute is identical to the class attribute of the same name,
  6942. which is described in the previous section. This attribute exists as
  6943. both an instance and class attribute so tests can use
  6944. ``self.target.run(cmd)`` in instance methods instead of
  6945. ``oeRuntimeTest.tc.target.run(cmd)``.
  6946. Installing Packages in the DUT Without the Package Manager
  6947. ----------------------------------------------------------
  6948. When a test requires a package built by BitBake, it is possible to
  6949. install that package. Installing the package does not require a package
  6950. manager be installed in the device under test (DUT). It does, however,
  6951. require an SSH connection and the target must be using the
  6952. ``sshcontrol`` class.
  6953. .. note::
  6954. This method uses ``scp`` to copy files from the host to the target, which
  6955. causes permissions and special attributes to be lost.
  6956. A JSON file is used to define the packages needed by a test. This file
  6957. must be in the same path as the file used to define the tests.
  6958. Furthermore, the filename must map directly to the test module name with
  6959. a ``.json`` extension.
  6960. The JSON file must include an object with the test name as keys of an
  6961. object or an array. This object (or array of objects) uses the following
  6962. data:
  6963. - "pkg" - A mandatory string that is the name of the package to be
  6964. installed.
  6965. - "rm" - An optional boolean, which defaults to "false", that specifies
  6966. to remove the package after the test.
  6967. - "extract" - An optional boolean, which defaults to "false", that
  6968. specifies if the package must be extracted from the package format.
  6969. When set to "true", the package is not automatically installed into
  6970. the DUT.
  6971. Following is an example JSON file that handles test "foo" installing
  6972. package "bar" and test "foobar" installing packages "foo" and "bar".
  6973. Once the test is complete, the packages are removed from the DUT.
  6974. ::
  6975. {
  6976. "foo": {
  6977. "pkg": "bar"
  6978. },
  6979. "foobar": [
  6980. {
  6981. "pkg": "foo",
  6982. "rm": true
  6983. },
  6984. {
  6985. "pkg": "bar",
  6986. "rm": true
  6987. }
  6988. ]
  6989. }
  6990. Debugging Tools and Techniques
  6991. ==============================
  6992. The exact method for debugging build failures depends on the nature of
  6993. the problem and on the system's area from which the bug originates.
  6994. Standard debugging practices such as comparison against the last known
  6995. working version with examination of the changes and the re-application
  6996. of steps to identify the one causing the problem are valid for the Yocto
  6997. Project just as they are for any other system. Even though it is
  6998. impossible to detail every possible potential failure, this section
  6999. provides some general tips to aid in debugging given a variety of
  7000. situations.
  7001. .. note::
  7002. A useful feature for debugging is the error reporting tool.
  7003. Configuring the Yocto Project to use this tool causes the
  7004. OpenEmbedded build system to produce error reporting commands as part
  7005. of the console output. You can enter the commands after the build
  7006. completes to log error information into a common database, that can
  7007. help you figure out what might be going wrong. For information on how
  7008. to enable and use this feature, see the
  7009. ":ref:`dev-manual/common-tasks:using the error reporting tool`"
  7010. section.
  7011. The following list shows the debugging topics in the remainder of this
  7012. section:
  7013. - ":ref:`dev-manual/common-tasks:viewing logs from failed tasks`" describes
  7014. how to find and view logs from tasks that failed during the build
  7015. process.
  7016. - ":ref:`dev-manual/common-tasks:viewing variable values`" describes how to
  7017. use the BitBake ``-e`` option to examine variable values after a
  7018. recipe has been parsed.
  7019. - ":ref:`dev-manual/common-tasks:viewing package information with \`\`oe-pkgdata-util\`\``"
  7020. describes how to use the ``oe-pkgdata-util`` utility to query
  7021. :term:`PKGDATA_DIR` and
  7022. display package-related information for built packages.
  7023. - ":ref:`dev-manual/common-tasks:viewing dependencies between recipes and tasks`"
  7024. describes how to use the BitBake ``-g`` option to display recipe
  7025. dependency information used during the build.
  7026. - ":ref:`dev-manual/common-tasks:viewing task variable dependencies`" describes
  7027. how to use the ``bitbake-dumpsig`` command in conjunction with key
  7028. subdirectories in the
  7029. :term:`Build Directory` to determine
  7030. variable dependencies.
  7031. - ":ref:`dev-manual/common-tasks:running specific tasks`" describes
  7032. how to use several BitBake options (e.g. ``-c``, ``-C``, and ``-f``)
  7033. to run specific tasks in the build chain. It can be useful to run
  7034. tasks "out-of-order" when trying isolate build issues.
  7035. - ":ref:`dev-manual/common-tasks:general bitbake problems`" describes how
  7036. to use BitBake's ``-D`` debug output option to reveal more about what
  7037. BitBake is doing during the build.
  7038. - ":ref:`dev-manual/common-tasks:building with no dependencies`"
  7039. describes how to use the BitBake ``-b`` option to build a recipe
  7040. while ignoring dependencies.
  7041. - ":ref:`dev-manual/common-tasks:recipe logging mechanisms`"
  7042. describes how to use the many recipe logging functions to produce
  7043. debugging output and report errors and warnings.
  7044. - ":ref:`dev-manual/common-tasks:debugging parallel make races`"
  7045. describes how to debug situations where the build consists of several
  7046. parts that are run simultaneously and when the output or result of
  7047. one part is not ready for use with a different part of the build that
  7048. depends on that output.
  7049. - ":ref:`dev-manual/common-tasks:debugging with the gnu project debugger (gdb) remotely`"
  7050. describes how to use GDB to allow you to examine running programs, which can
  7051. help you fix problems.
  7052. - ":ref:`dev-manual/common-tasks:debugging with the gnu project debugger (gdb) on the target`"
  7053. describes how to use GDB directly on target hardware for debugging.
  7054. - ":ref:`dev-manual/common-tasks:other debugging tips`" describes
  7055. miscellaneous debugging tips that can be useful.
  7056. Viewing Logs from Failed Tasks
  7057. ------------------------------
  7058. You can find the log for a task in the file
  7059. ``${``\ :term:`WORKDIR`\ ``}/temp/log.do_``\ `taskname`.
  7060. For example, the log for the
  7061. :ref:`ref-tasks-compile` task of the
  7062. QEMU minimal image for the x86 machine (``qemux86``) might be in
  7063. ``tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile``.
  7064. To see the commands :term:`BitBake` ran
  7065. to generate a log, look at the corresponding ``run.do_``\ `taskname` file
  7066. in the same directory.
  7067. ``log.do_``\ `taskname` and ``run.do_``\ `taskname` are actually symbolic
  7068. links to ``log.do_``\ `taskname`\ ``.``\ `pid` and
  7069. ``log.run_``\ `taskname`\ ``.``\ `pid`, where `pid` is the PID the task had
  7070. when it ran. The symlinks always point to the files corresponding to the
  7071. most recent run.
  7072. Viewing Variable Values
  7073. -----------------------
  7074. Sometimes you need to know the value of a variable as a result of
  7075. BitBake's parsing step. This could be because some unexpected behavior
  7076. occurred in your project. Perhaps an attempt to :ref:`modify a variable
  7077. <bitbake:bitbake-user-manual/bitbake-user-manual-metadata:modifying existing
  7078. variables>` did not work out as expected.
  7079. BitBake's ``-e`` option is used to display variable values after
  7080. parsing. The following command displays the variable values after the
  7081. configuration files (i.e. ``local.conf``, ``bblayers.conf``,
  7082. ``bitbake.conf`` and so forth) have been parsed:
  7083. ::
  7084. $ bitbake -e
  7085. The following command displays variable values after a specific recipe has
  7086. been parsed. The variables include those from the configuration as well:
  7087. ::
  7088. $ bitbake -e recipename
  7089. .. note::
  7090. Each recipe has its own private set of variables (datastore).
  7091. Internally, after parsing the configuration, a copy of the resulting
  7092. datastore is made prior to parsing each recipe. This copying implies
  7093. that variables set in one recipe will not be visible to other
  7094. recipes.
  7095. Likewise, each task within a recipe gets a private datastore based on
  7096. the recipe datastore, which means that variables set within one task
  7097. will not be visible to other tasks.
  7098. In the output of ``bitbake -e``, each variable is preceded by a
  7099. description of how the variable got its value, including temporary
  7100. values that were later overridden. This description also includes
  7101. variable flags (varflags) set on the variable. The output can be very
  7102. helpful during debugging.
  7103. Variables that are exported to the environment are preceded by
  7104. ``export`` in the output of ``bitbake -e``. See the following example:
  7105. ::
  7106. export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
  7107. In addition to variable values, the output of the ``bitbake -e`` and
  7108. ``bitbake -e`` recipe commands includes the following information:
  7109. - The output starts with a tree listing all configuration files and
  7110. classes included globally, recursively listing the files they include
  7111. or inherit in turn. Much of the behavior of the OpenEmbedded build
  7112. system (including the behavior of the :ref:`ref-manual/tasks:normal recipe build tasks`) is
  7113. implemented in the
  7114. :ref:`base <ref-classes-base>` class and the
  7115. classes it inherits, rather than being built into BitBake itself.
  7116. - After the variable values, all functions appear in the output. For
  7117. shell functions, variables referenced within the function body are
  7118. expanded. If a function has been modified using overrides or using
  7119. override-style operators like ``_append`` and ``_prepend``, then the
  7120. final assembled function body appears in the output.
  7121. Viewing Package Information with ``oe-pkgdata-util``
  7122. ----------------------------------------------------
  7123. You can use the ``oe-pkgdata-util`` command-line utility to query
  7124. :term:`PKGDATA_DIR` and display
  7125. various package-related information. When you use the utility, you must
  7126. use it to view information on packages that have already been built.
  7127. Following are a few of the available ``oe-pkgdata-util`` subcommands.
  7128. .. note::
  7129. You can use the standard \* and ? globbing wildcards as part of
  7130. package names and paths.
  7131. - ``oe-pkgdata-util list-pkgs [pattern]``: Lists all packages
  7132. that have been built, optionally limiting the match to packages that
  7133. match pattern.
  7134. - ``oe-pkgdata-util list-pkg-files package ...``: Lists the
  7135. files and directories contained in the given packages.
  7136. .. note::
  7137. A different way to view the contents of a package is to look at
  7138. the
  7139. ``${``\ :term:`WORKDIR`\ ``}/packages-split``
  7140. directory of the recipe that generates the package. This directory
  7141. is created by the
  7142. :ref:`ref-tasks-package` task
  7143. and has one subdirectory for each package the recipe generates,
  7144. which contains the files stored in that package.
  7145. If you want to inspect the ``${WORKDIR}/packages-split``
  7146. directory, make sure that
  7147. :ref:`rm_work <ref-classes-rm-work>` is not
  7148. enabled when you build the recipe.
  7149. - ``oe-pkgdata-util find-path path ...``: Lists the names of
  7150. the packages that contain the given paths. For example, the following
  7151. tells us that ``/usr/share/man/man1/make.1`` is contained in the
  7152. ``make-doc`` package:
  7153. ::
  7154. $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
  7155. make-doc: /usr/share/man/man1/make.1
  7156. - ``oe-pkgdata-util lookup-recipe package ...``: Lists the name
  7157. of the recipes that produce the given packages.
  7158. For more information on the ``oe-pkgdata-util`` command, use the help
  7159. facility:
  7160. ::
  7161. $ oe-pkgdata-util --help
  7162. $ oe-pkgdata-util subcommand --help
  7163. Viewing Dependencies Between Recipes and Tasks
  7164. ----------------------------------------------
  7165. Sometimes it can be hard to see why BitBake wants to build other recipes
  7166. before the one you have specified. Dependency information can help you
  7167. understand why a recipe is built.
  7168. To generate dependency information for a recipe, run the following
  7169. command:
  7170. ::
  7171. $ bitbake -g recipename
  7172. This command writes the following files in the current directory:
  7173. - ``pn-buildlist``: A list of recipes/targets involved in building
  7174. `recipename`. "Involved" here means that at least one task from the
  7175. recipe needs to run when building `recipename` from scratch. Targets
  7176. that are in
  7177. :term:`ASSUME_PROVIDED`
  7178. are not listed.
  7179. - ``task-depends.dot``: A graph showing dependencies between tasks.
  7180. The graphs are in
  7181. `DOT <https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29>`__
  7182. format and can be converted to images (e.g. using the ``dot`` tool from
  7183. `Graphviz <https://www.graphviz.org/>`__).
  7184. .. note::
  7185. - DOT files use a plain text format. The graphs generated using the
  7186. ``bitbake -g`` command are often so large as to be difficult to
  7187. read without special pruning (e.g. with Bitbake's ``-I`` option)
  7188. and processing. Despite the form and size of the graphs, the
  7189. corresponding ``.dot`` files can still be possible to read and
  7190. provide useful information.
  7191. As an example, the ``task-depends.dot`` file contains lines such
  7192. as the following:
  7193. ::
  7194. "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
  7195. The above example line reveals that the
  7196. :ref:`ref-tasks-configure`
  7197. task in ``libxslt`` depends on the
  7198. :ref:`ref-tasks-populate_sysroot`
  7199. task in ``libxml2``, which is a normal
  7200. :term:`DEPENDS` dependency
  7201. between the two recipes.
  7202. - For an example of how ``.dot`` files can be processed, see the
  7203. ``scripts/contrib/graph-tool`` Python script, which finds and
  7204. displays paths between graph nodes.
  7205. You can use a different method to view dependency information by using
  7206. the following command:
  7207. ::
  7208. $ bitbake -g -u taskexp recipename
  7209. This command
  7210. displays a GUI window from which you can view build-time and runtime
  7211. dependencies for the recipes involved in building recipename.
  7212. Viewing Task Variable Dependencies
  7213. ----------------------------------
  7214. As mentioned in the
  7215. ":ref:`bitbake:bitbake-user-manual/bitbake-user-manual-execution:checksums (signatures)`" section of the BitBake
  7216. User Manual, BitBake tries to automatically determine what variables a
  7217. task depends on so that it can rerun the task if any values of the
  7218. variables change. This determination is usually reliable. However, if
  7219. you do things like construct variable names at runtime, then you might
  7220. have to manually declare dependencies on those variables using
  7221. ``vardeps`` as described in the
  7222. ":ref:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata:variable flags`" section of the BitBake
  7223. User Manual.
  7224. If you are unsure whether a variable dependency is being picked up
  7225. automatically for a given task, you can list the variable dependencies
  7226. BitBake has determined by doing the following:
  7227. 1. Build the recipe containing the task:
  7228. ::
  7229. $ bitbake recipename
  7230. 2. Inside the :term:`STAMPS_DIR`
  7231. directory, find the signature data (``sigdata``) file that
  7232. corresponds to the task. The ``sigdata`` files contain a pickled
  7233. Python database of all the metadata that went into creating the input
  7234. checksum for the task. As an example, for the
  7235. :ref:`ref-tasks-fetch` task of the
  7236. ``db`` recipe, the ``sigdata`` file might be found in the following
  7237. location:
  7238. ::
  7239. ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  7240. For tasks that are accelerated through the shared state
  7241. (:ref:`sstate <overview-manual/concepts:shared state cache>`) cache, an
  7242. additional ``siginfo`` file is written into
  7243. :term:`SSTATE_DIR` along with
  7244. the cached task output. The ``siginfo`` files contain exactly the
  7245. same information as ``sigdata`` files.
  7246. 3. Run ``bitbake-dumpsig`` on the ``sigdata`` or ``siginfo`` file. Here
  7247. is an example:
  7248. ::
  7249. $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  7250. In the output of the above command, you will find a line like the
  7251. following, which lists all the (inferred) variable dependencies for
  7252. the task. This list also includes indirect dependencies from
  7253. variables depending on other variables, recursively.
  7254. ::
  7255. Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
  7256. .. note::
  7257. Functions (e.g. ``base_do_fetch``) also count as variable dependencies.
  7258. These functions in turn depend on the variables they reference.
  7259. The output of ``bitbake-dumpsig`` also includes the value each
  7260. variable had, a list of dependencies for each variable, and
  7261. :term:`bitbake:BB_HASHBASE_WHITELIST`
  7262. information.
  7263. There is also a ``bitbake-diffsigs`` command for comparing two
  7264. ``siginfo`` or ``sigdata`` files. This command can be helpful when
  7265. trying to figure out what changed between two versions of a task. If you
  7266. call ``bitbake-diffsigs`` with just one file, the command behaves like
  7267. ``bitbake-dumpsig``.
  7268. You can also use BitBake to dump out the signature construction
  7269. information without executing tasks by using either of the following
  7270. BitBake command-line options:
  7271. ::
  7272. ‐‐dump-signatures=SIGNATURE_HANDLER
  7273. -S SIGNATURE_HANDLER
  7274. .. note::
  7275. Two common values for `SIGNATURE_HANDLER` are "none" and "printdiff", which
  7276. dump only the signature or compare the dumped signature with the cached one,
  7277. respectively.
  7278. Using BitBake with either of these options causes BitBake to dump out
  7279. ``sigdata`` files in the ``stamps`` directory for every task it would
  7280. have executed instead of building the specified target package.
  7281. Viewing Metadata Used to Create the Input Signature of a Shared State Task
  7282. --------------------------------------------------------------------------
  7283. Seeing what metadata went into creating the input signature of a shared
  7284. state (sstate) task can be a useful debugging aid. This information is
  7285. available in signature information (``siginfo``) files in
  7286. :term:`SSTATE_DIR`. For
  7287. information on how to view and interpret information in ``siginfo``
  7288. files, see the
  7289. ":ref:`dev-manual/common-tasks:viewing task variable dependencies`" section.
  7290. For conceptual information on shared state, see the
  7291. ":ref:`overview-manual/concepts:shared state`"
  7292. section in the Yocto Project Overview and Concepts Manual.
  7293. Invalidating Shared State to Force a Task to Run
  7294. ------------------------------------------------
  7295. The OpenEmbedded build system uses
  7296. :ref:`checksums <overview-manual/concepts:checksums (signatures)>` and
  7297. :ref:`overview-manual/concepts:shared state` cache to avoid unnecessarily
  7298. rebuilding tasks. Collectively, this scheme is known as "shared state
  7299. code".
  7300. As with all schemes, this one has some drawbacks. It is possible that
  7301. you could make implicit changes to your code that the checksum
  7302. calculations do not take into account. These implicit changes affect a
  7303. task's output but do not trigger the shared state code into rebuilding a
  7304. recipe. Consider an example during which a tool changes its output.
  7305. Assume that the output of ``rpmdeps`` changes. The result of the change
  7306. should be that all the ``package`` and ``package_write_rpm`` shared
  7307. state cache items become invalid. However, because the change to the
  7308. output is external to the code and therefore implicit, the associated
  7309. shared state cache items do not become invalidated. In this case, the
  7310. build process uses the cached items rather than running the task again.
  7311. Obviously, these types of implicit changes can cause problems.
  7312. To avoid these problems during the build, you need to understand the
  7313. effects of any changes you make. Realize that changes you make directly
  7314. to a function are automatically factored into the checksum calculation.
  7315. Thus, these explicit changes invalidate the associated area of shared
  7316. state cache. However, you need to be aware of any implicit changes that
  7317. are not obvious changes to the code and could affect the output of a
  7318. given task.
  7319. When you identify an implicit change, you can easily take steps to
  7320. invalidate the cache and force the tasks to run. The steps you can take
  7321. are as simple as changing a function's comments in the source code. For
  7322. example, to invalidate package shared state files, change the comment
  7323. statements of
  7324. :ref:`ref-tasks-package` or the
  7325. comments of one of the functions it calls. Even though the change is
  7326. purely cosmetic, it causes the checksum to be recalculated and forces
  7327. the build system to run the task again.
  7328. .. note::
  7329. For an example of a commit that makes a cosmetic change to invalidate
  7330. shared state, see this
  7331. :yocto_git:`commit </poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54>`.
  7332. Running Specific Tasks
  7333. ----------------------
  7334. Any given recipe consists of a set of tasks. The standard BitBake
  7335. behavior in most cases is: ``do_fetch``, ``do_unpack``, ``do_patch``,
  7336. ``do_configure``, ``do_compile``, ``do_install``, ``do_package``,
  7337. ``do_package_write_*``, and ``do_build``. The default task is
  7338. ``do_build`` and any tasks on which it depends build first. Some tasks,
  7339. such as ``do_devshell``, are not part of the default build chain. If you
  7340. wish to run a task that is not part of the default build chain, you can
  7341. use the ``-c`` option in BitBake. Here is an example:
  7342. ::
  7343. $ bitbake matchbox-desktop -c devshell
  7344. The ``-c`` option respects task dependencies, which means that all other
  7345. tasks (including tasks from other recipes) that the specified task
  7346. depends on will be run before the task. Even when you manually specify a
  7347. task to run with ``-c``, BitBake will only run the task if it considers
  7348. it "out of date". See the
  7349. ":ref:`overview-manual/concepts:stamp files and the rerunning of tasks`"
  7350. section in the Yocto Project Overview and Concepts Manual for how
  7351. BitBake determines whether a task is "out of date".
  7352. If you want to force an up-to-date task to be rerun (e.g. because you
  7353. made manual modifications to the recipe's
  7354. :term:`WORKDIR` that you want to try
  7355. out), then you can use the ``-f`` option.
  7356. .. note::
  7357. The reason ``-f`` is never required when running the
  7358. :ref:`ref-tasks-devshell` task is because the
  7359. [\ :ref:`nostamp <bitbake:bitbake-user-manual/bitbake-user-manual-metadata:variable flags>`\ ]
  7360. variable flag is already set for the task.
  7361. The following example shows one way you can use the ``-f`` option:
  7362. ::
  7363. $ bitbake matchbox-desktop
  7364. .
  7365. .
  7366. make some changes to the source code in the work directory
  7367. .
  7368. .
  7369. $ bitbake matchbox-desktop -c compile -f
  7370. $ bitbake matchbox-desktop
  7371. This sequence first builds and then recompiles ``matchbox-desktop``. The
  7372. last command reruns all tasks (basically the packaging tasks) after the
  7373. compile. BitBake recognizes that the ``do_compile`` task was rerun and
  7374. therefore understands that the other tasks also need to be run again.
  7375. Another, shorter way to rerun a task and all
  7376. :ref:`ref-manual/tasks:normal recipe build tasks`
  7377. that depend on it is to use the ``-C`` option.
  7378. .. note::
  7379. This option is upper-cased and is separate from the ``-c``
  7380. option, which is lower-cased.
  7381. Using this option invalidates the given task and then runs the
  7382. :ref:`ref-tasks-build` task, which is
  7383. the default task if no task is given, and the tasks on which it depends.
  7384. You could replace the final two commands in the previous example with
  7385. the following single command:
  7386. ::
  7387. $ bitbake matchbox-desktop -C compile
  7388. Internally, the ``-f`` and ``-C`` options work by tainting (modifying)
  7389. the input checksum of the specified task. This tainting indirectly
  7390. causes the task and its dependent tasks to be rerun through the normal
  7391. task dependency mechanisms.
  7392. .. note::
  7393. BitBake explicitly keeps track of which tasks have been tainted in
  7394. this fashion, and will print warnings such as the following for
  7395. builds involving such tasks:
  7396. .. code-block:: none
  7397. WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
  7398. The purpose of the warning is to let you know that the work directory
  7399. and build output might not be in the clean state they would be in for
  7400. a "normal" build, depending on what actions you took. To get rid of
  7401. such warnings, you can remove the work directory and rebuild the
  7402. recipe, as follows:
  7403. ::
  7404. $ bitbake matchbox-desktop -c clean
  7405. $ bitbake matchbox-desktop
  7406. You can view a list of tasks in a given package by running the
  7407. ``do_listtasks`` task as follows:
  7408. ::
  7409. $ bitbake matchbox-desktop -c listtasks
  7410. The results appear as output to the console and are also in
  7411. the file ``${WORKDIR}/temp/log.do_listtasks``.
  7412. General BitBake Problems
  7413. ------------------------
  7414. You can see debug output from BitBake by using the ``-D`` option. The
  7415. debug output gives more information about what BitBake is doing and the
  7416. reason behind it. Each ``-D`` option you use increases the logging
  7417. level. The most common usage is ``-DDD``.
  7418. The output from ``bitbake -DDD -v targetname`` can reveal why BitBake
  7419. chose a certain version of a package or why BitBake picked a certain
  7420. provider. This command could also help you in a situation where you
  7421. think BitBake did something unexpected.
  7422. Building with No Dependencies
  7423. -----------------------------
  7424. To build a specific recipe (``.bb`` file), you can use the following
  7425. command form:
  7426. ::
  7427. $ bitbake -b somepath/somerecipe.bb
  7428. This command form does
  7429. not check for dependencies. Consequently, you should use it only when
  7430. you know existing dependencies have been met.
  7431. .. note::
  7432. You can also specify fragments of the filename. In this case, BitBake
  7433. checks for a unique match.
  7434. Recipe Logging Mechanisms
  7435. -------------------------
  7436. The Yocto Project provides several logging functions for producing
  7437. debugging output and reporting errors and warnings. For Python
  7438. functions, the following logging functions exist. All of these functions
  7439. log to ``${T}/log.do_``\ `task`, and can also log to standard output
  7440. (stdout) with the right settings:
  7441. - ``bb.plain(msg)``: Writes msg as is to the log while also
  7442. logging to stdout.
  7443. - ``bb.note(msg)``: Writes "NOTE: msg" to the log. Also logs to
  7444. stdout if BitBake is called with "-v".
  7445. - ``bb.debug(level, msg)``: Writes "DEBUG: msg" to the
  7446. log. Also logs to stdout if the log level is greater than or equal to
  7447. level. See the ":ref:`-D <bitbake:bitbake-user-manual/bitbake-user-manual-intro:usage and syntax>`" option
  7448. in the BitBake User Manual for more information.
  7449. - ``bb.warn(msg)``: Writes "WARNING: msg" to the log while also
  7450. logging to stdout.
  7451. - ``bb.error(msg)``: Writes "ERROR: msg" to the log while also
  7452. logging to standard out (stdout).
  7453. .. note::
  7454. Calling this function does not cause the task to fail.
  7455. - ``bb.fatal(``\ msg\ ``)``: This logging function is similar to
  7456. ``bb.error(``\ msg\ ``)`` but also causes the calling task to fail.
  7457. .. note::
  7458. ``bb.fatal()`` raises an exception, which means you do not need to put a
  7459. "return" statement after the function.
  7460. The same logging functions are also available in shell functions, under
  7461. the names ``bbplain``, ``bbnote``, ``bbdebug``, ``bbwarn``, ``bberror``,
  7462. and ``bbfatal``. The
  7463. :ref:`logging <ref-classes-logging>` class
  7464. implements these functions. See that class in the ``meta/classes``
  7465. folder of the :term:`Source Directory` for information.
  7466. Logging With Python
  7467. ~~~~~~~~~~~~~~~~~~~
  7468. When creating recipes using Python and inserting code that handles build
  7469. logs, keep in mind the goal is to have informative logs while keeping
  7470. the console as "silent" as possible. Also, if you want status messages
  7471. in the log, use the "debug" loglevel.
  7472. Following is an example written in Python. The code handles logging for
  7473. a function that determines the number of tasks needed to be run. See the
  7474. ":ref:`ref-tasks-listtasks`"
  7475. section for additional information:
  7476. ::
  7477. python do_listtasks() {
  7478. bb.debug(2, "Starting to figure out the task list")
  7479. if noteworthy_condition:
  7480. bb.note("There are 47 tasks to run")
  7481. bb.debug(2, "Got to point xyz")
  7482. if warning_trigger:
  7483. bb.warn("Detected warning_trigger, this might be a problem later.")
  7484. if recoverable_error:
  7485. bb.error("Hit recoverable_error, you really need to fix this!")
  7486. if fatal_error:
  7487. bb.fatal("fatal_error detected, unable to print the task list")
  7488. bb.plain("The tasks present are abc")
  7489. bb.debug(2, "Finished figuring out the tasklist")
  7490. }
  7491. Logging With Bash
  7492. ~~~~~~~~~~~~~~~~~
  7493. When creating recipes using Bash and inserting code that handles build
  7494. logs, you have the same goals - informative with minimal console output.
  7495. The syntax you use for recipes written in Bash is similar to that of
  7496. recipes written in Python described in the previous section.
  7497. Following is an example written in Bash. The code logs the progress of
  7498. the ``do_my_function`` function.
  7499. ::
  7500. do_my_function() {
  7501. bbdebug 2 "Running do_my_function"
  7502. if [ exceptional_condition ]; then
  7503. bbnote "Hit exceptional_condition"
  7504. fi
  7505. bbdebug 2 "Got to point xyz"
  7506. if [ warning_trigger ]; then
  7507. bbwarn "Detected warning_trigger, this might cause a problem later."
  7508. fi
  7509. if [ recoverable_error ]; then
  7510. bberror "Hit recoverable_error, correcting"
  7511. fi
  7512. if [ fatal_error ]; then
  7513. bbfatal "fatal_error detected"
  7514. fi
  7515. bbdebug 2 "Completed do_my_function"
  7516. }
  7517. Debugging Parallel Make Races
  7518. -----------------------------
  7519. A parallel ``make`` race occurs when the build consists of several parts
  7520. that are run simultaneously and a situation occurs when the output or
  7521. result of one part is not ready for use with a different part of the
  7522. build that depends on that output. Parallel make races are annoying and
  7523. can sometimes be difficult to reproduce and fix. However, some simple
  7524. tips and tricks exist that can help you debug and fix them. This section
  7525. presents a real-world example of an error encountered on the Yocto
  7526. Project autobuilder and the process used to fix it.
  7527. .. note::
  7528. If you cannot properly fix a ``make`` race condition, you can work around it
  7529. by clearing either the :term:`PARALLEL_MAKE` or :term:`PARALLEL_MAKEINST`
  7530. variables.
  7531. The Failure
  7532. ~~~~~~~~~~~
  7533. For this example, assume that you are building an image that depends on
  7534. the "neard" package. And, during the build, BitBake runs into problems
  7535. and creates the following output.
  7536. .. note::
  7537. This example log file has longer lines artificially broken to make
  7538. the listing easier to read.
  7539. If you examine the output or the log file, you see the failure during
  7540. ``make``:
  7541. .. code-block:: none
  7542. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  7543. | DEBUG: Executing shell function do_compile
  7544. | NOTE: make -j 16
  7545. | make --no-print-directory all-am
  7546. | /bin/mkdir -p include/near
  7547. | /bin/mkdir -p include/near
  7548. | /bin/mkdir -p include/near
  7549. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7550. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  7551. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7552. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  7553. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7554. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  7555. | /bin/mkdir -p include/near
  7556. | /bin/mkdir -p include/near
  7557. | /bin/mkdir -p include/near
  7558. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7559. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  7560. | /bin/mkdir -p include/near
  7561. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7562. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  7563. | /bin/mkdir -p include/near
  7564. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7565. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  7566. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7567. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  7568. | /bin/mkdir -p include/near
  7569. | /bin/mkdir -p include/near
  7570. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7571. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  7572. | /bin/mkdir -p include/near
  7573. | /bin/mkdir -p include/near
  7574. | /bin/mkdir -p include/near
  7575. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7576. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  7577. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7578. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  7579. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7580. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  7581. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7582. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  7583. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7584. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  7585. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  7586. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  7587. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  7588. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  7589. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  7590. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  7591. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  7592. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  7593. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  7594. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  7595. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  7596. -o tools/snep-send.o tools/snep-send.c
  7597. | In file included from tools/snep-send.c:16:0:
  7598. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  7599. | #include <near/dbus.h>
  7600. | ^
  7601. | compilation terminated.
  7602. | make[1]: *** [tools/snep-send.o] Error 1
  7603. | make[1]: *** Waiting for unfinished jobs....
  7604. | make: *** [all] Error 2
  7605. | ERROR: oe_runmake failed
  7606. Reproducing the Error
  7607. ~~~~~~~~~~~~~~~~~~~~~
  7608. Because race conditions are intermittent, they do not manifest
  7609. themselves every time you do the build. In fact, most times the build
  7610. will complete without problems even though the potential race condition
  7611. exists. Thus, once the error surfaces, you need a way to reproduce it.
  7612. In this example, compiling the "neard" package is causing the problem.
  7613. So the first thing to do is build "neard" locally. Before you start the
  7614. build, set the
  7615. :term:`PARALLEL_MAKE` variable
  7616. in your ``local.conf`` file to a high number (e.g. "-j 20"). Using a
  7617. high value for ``PARALLEL_MAKE`` increases the chances of the race
  7618. condition showing up:
  7619. ::
  7620. $ bitbake neard
  7621. Once the local build for "neard" completes, start a ``devshell`` build:
  7622. ::
  7623. $ bitbake neard -c devshell
  7624. For information on how to use a ``devshell``, see the
  7625. ":ref:`dev-manual/common-tasks:using a development shell`" section.
  7626. In the ``devshell``, do the following:
  7627. ::
  7628. $ make clean
  7629. $ make tools/snep-send.o
  7630. The ``devshell`` commands cause the failure to clearly
  7631. be visible. In this case, a missing dependency exists for the "neard"
  7632. Makefile target. Here is some abbreviated, sample output with the
  7633. missing dependency clearly visible at the end:
  7634. ::
  7635. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  7636. .
  7637. .
  7638. .
  7639. tools/snep-send.c
  7640. In file included from tools/snep-send.c:16:0:
  7641. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  7642. #include <near/dbus.h>
  7643. ^
  7644. compilation terminated.
  7645. make: *** [tools/snep-send.o] Error 1
  7646. $
  7647. Creating a Patch for the Fix
  7648. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7649. Because there is a missing dependency for the Makefile target, you need
  7650. to patch the ``Makefile.am`` file, which is generated from
  7651. ``Makefile.in``. You can use Quilt to create the patch:
  7652. ::
  7653. $ quilt new parallelmake.patch
  7654. Patch patches/parallelmake.patch is now on top
  7655. $ quilt add Makefile.am
  7656. File Makefile.am added to patch patches/parallelmake.patch
  7657. For more information on using Quilt, see the
  7658. ":ref:`dev-manual/common-tasks:using quilt in your workflow`" section.
  7659. At this point you need to make the edits to ``Makefile.am`` to add the
  7660. missing dependency. For our example, you have to add the following line
  7661. to the file:
  7662. ::
  7663. tools/snep-send.$(OBJEXT): include/near/dbus.h
  7664. Once you have edited the file, use the ``refresh`` command to create the
  7665. patch:
  7666. ::
  7667. $ quilt refresh
  7668. Refreshed patch patches/parallelmake.patch
  7669. Once
  7670. the patch file exists, you need to add it back to the originating recipe
  7671. folder. Here is an example assuming a top-level
  7672. :term:`Source Directory` named ``poky``:
  7673. ::
  7674. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  7675. The final thing you need to do to implement the fix in the build is to
  7676. update the "neard" recipe (i.e. ``neard-0.14.bb``) so that the
  7677. :term:`SRC_URI` statement includes
  7678. the patch file. The recipe file is in the folder above the patch. Here
  7679. is what the edited ``SRC_URI`` statement would look like:
  7680. ::
  7681. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  7682. file://neard.in \
  7683. file://neard.service.in \
  7684. file://parallelmake.patch \
  7685. "
  7686. With the patch complete and moved to the correct folder and the
  7687. ``SRC_URI`` statement updated, you can exit the ``devshell``:
  7688. ::
  7689. $ exit
  7690. Testing the Build
  7691. ~~~~~~~~~~~~~~~~~
  7692. With everything in place, you can get back to trying the build again
  7693. locally:
  7694. ::
  7695. $ bitbake neard
  7696. This build should succeed.
  7697. Now you can open up a ``devshell`` again and repeat the clean and make
  7698. operations as follows:
  7699. ::
  7700. $ bitbake neard -c devshell
  7701. $ make clean
  7702. $ make tools/snep-send.o
  7703. The build should work without issue.
  7704. As with all solved problems, if they originated upstream, you need to
  7705. submit the fix for the recipe in OE-Core and upstream so that the
  7706. problem is taken care of at its source. See the
  7707. ":ref:`dev-manual/common-tasks:submitting a change to the yocto project`"
  7708. section for more information.
  7709. Debugging With the GNU Project Debugger (GDB) Remotely
  7710. ------------------------------------------------------
  7711. GDB allows you to examine running programs, which in turn helps you to
  7712. understand and fix problems. It also allows you to perform post-mortem
  7713. style analysis of program crashes. GDB is available as a package within
  7714. the Yocto Project and is installed in SDK images by default. See the
  7715. ":ref:`ref-manual/images:Images`" chapter in the Yocto
  7716. Project Reference Manual for a description of these images. You can find
  7717. information on GDB at https://sourceware.org/gdb/.
  7718. .. note::
  7719. For best results, install debug (``-dbg``) packages for the applications you
  7720. are going to debug. Doing so makes extra debug symbols available that give
  7721. you more meaningful output.
  7722. Sometimes, due to memory or disk space constraints, it is not possible
  7723. to use GDB directly on the remote target to debug applications. These
  7724. constraints arise because GDB needs to load the debugging information
  7725. and the binaries of the process being debugged. Additionally, GDB needs
  7726. to perform many computations to locate information such as function
  7727. names, variable names and values, stack traces and so forth - even
  7728. before starting the debugging process. These extra computations place
  7729. more load on the target system and can alter the characteristics of the
  7730. program being debugged.
  7731. To help get past the previously mentioned constraints, there are two
  7732. methods you can use: running a debuginfod server and using gdbserver.
  7733. Using the debuginfod server method
  7734. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7735. "debuginfod" from "elfutils" is a way to distribute "debuginfo" files.
  7736. Running a "debuginfod" server makes debug symbols readily available,
  7737. which means you don't need to download debugging information
  7738. and the binaries of the process being debugged. You can just fetch
  7739. debug symbols from the server.
  7740. To run a debuginfod server, you need to do the following:
  7741. - Ensure that this variable is set in your ``local.conf`` file:
  7742. ::
  7743. PACKAGECONFIG_pn-elfutils-native = "debuginfod libdebuginfod"
  7744. This :term:`PACKAGECONFIG` option enables debuginfod and libdebuginfod for
  7745. "elfutils-native".
  7746. - Run the following commands to set up the "debuginfod" server:
  7747. ::
  7748. $ oe-debuginfod
  7749. To use debuginfod on the target, you need the following:
  7750. - Ensure that this variable is set in your ``local.conf`` file:
  7751. ::
  7752. DEBUGINFOD_URLS = "http://localhost:8002/"
  7753. This :term:`DEBUGINFOD_URLS` option does the client configuration.
  7754. ::
  7755. PACKAGECONFIG_pn-gdb = "debuginfod"
  7756. This :term:`PACKAGECONFIG` option enables "debuginfod" for "gdb".
  7757. Using the gdbserver method
  7758. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7759. gdbserver, which runs on the remote target and does not load any
  7760. debugging information from the debugged process. Instead, a GDB instance
  7761. processes the debugging information that is run on a remote computer -
  7762. the host GDB. The host GDB then sends control commands to gdbserver to
  7763. make it stop or start the debugged program, as well as read or write
  7764. memory regions of that debugged program. All the debugging information
  7765. loaded and processed as well as all the heavy debugging is done by the
  7766. host GDB. Offloading these processes gives the gdbserver running on the
  7767. target a chance to remain small and fast.
  7768. Because the host GDB is responsible for loading the debugging
  7769. information and for doing the necessary processing to make actual
  7770. debugging happen, you have to make sure the host can access the
  7771. unstripped binaries complete with their debugging information and also
  7772. be sure the target is compiled with no optimizations. The host GDB must
  7773. also have local access to all the libraries used by the debugged
  7774. program. Because gdbserver does not need any local debugging
  7775. information, the binaries on the remote target can remain stripped.
  7776. However, the binaries must also be compiled without optimization so they
  7777. match the host's binaries.
  7778. To remain consistent with GDB documentation and terminology, the binary
  7779. being debugged on the remote target machine is referred to as the
  7780. "inferior" binary. For documentation on GDB see the `GDB
  7781. site <https://sourceware.org/gdb/documentation/>`__.
  7782. The following steps show you how to debug using the GNU project
  7783. debugger.
  7784. 1. *Configure your build system to construct the companion debug
  7785. filesystem:*
  7786. In your ``local.conf`` file, set the following:
  7787. ::
  7788. IMAGE_GEN_DEBUGFS = "1"
  7789. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  7790. These options cause the
  7791. OpenEmbedded build system to generate a special companion filesystem
  7792. fragment, which contains the matching source and debug symbols to
  7793. your deployable filesystem. The build system does this by looking at
  7794. what is in the deployed filesystem, and pulling the corresponding
  7795. ``-dbg`` packages.
  7796. The companion debug filesystem is not a complete filesystem, but only
  7797. contains the debug fragments. This filesystem must be combined with
  7798. the full filesystem for debugging. Subsequent steps in this procedure
  7799. show how to combine the partial filesystem with the full filesystem.
  7800. 2. *Configure the system to include gdbserver in the target filesystem:*
  7801. Make the following addition in either your ``local.conf`` file or in
  7802. an image recipe:
  7803. ::
  7804. IMAGE_INSTALL_append = " gdbserver"
  7805. The change makes
  7806. sure the ``gdbserver`` package is included.
  7807. 3. *Build the environment:*
  7808. Use the following command to construct the image and the companion
  7809. Debug Filesystem:
  7810. ::
  7811. $ bitbake image
  7812. Build the cross GDB component and
  7813. make it available for debugging. Build the SDK that matches the
  7814. image. Building the SDK is best for a production build that can be
  7815. used later for debugging, especially during long term maintenance:
  7816. ::
  7817. $ bitbake -c populate_sdk image
  7818. Alternatively, you can build the minimal toolchain components that
  7819. match the target. Doing so creates a smaller than typical SDK and
  7820. only contains a minimal set of components with which to build simple
  7821. test applications, as well as run the debugger:
  7822. ::
  7823. $ bitbake meta-toolchain
  7824. A final method is to build Gdb itself within the build system:
  7825. ::
  7826. $ bitbake gdb-cross-<architecture>
  7827. Doing so produces a temporary copy of
  7828. ``cross-gdb`` you can use for debugging during development. While
  7829. this is the quickest approach, the two previous methods in this step
  7830. are better when considering long-term maintenance strategies.
  7831. .. note::
  7832. If you run ``bitbake gdb-cross``, the OpenEmbedded build system suggests
  7833. the actual image (e.g. ``gdb-cross-i586``). The suggestion is usually the
  7834. actual name you want to use.
  7835. 4. *Set up the* ``debugfs``\ *:*
  7836. Run the following commands to set up the ``debugfs``:
  7837. ::
  7838. $ mkdir debugfs
  7839. $ cd debugfs
  7840. $ tar xvfj build-dir/tmp-glibc/deploy/images/machine/image.rootfs.tar.bz2
  7841. $ tar xvfj build-dir/tmp-glibc/deploy/images/machine/image-dbg.rootfs.tar.bz2
  7842. 5. *Set up GDB:*
  7843. Install the SDK (if you built one) and then source the correct
  7844. environment file. Sourcing the environment file puts the SDK in your
  7845. ``PATH`` environment variable.
  7846. If you are using the build system, Gdb is located in
  7847. `build-dir`\ ``/tmp/sysroots/``\ `host`\ ``/usr/bin/``\ `architecture`\ ``/``\ `architecture`\ ``-gdb``
  7848. 6. *Boot the target:*
  7849. For information on how to run QEMU, see the `QEMU
  7850. Documentation <https://wiki.qemu.org/Documentation/GettingStartedDevelopers>`__.
  7851. .. note::
  7852. Be sure to verify that your host can access the target via TCP.
  7853. 7. *Debug a program:*
  7854. Debugging a program involves running gdbserver on the target and then
  7855. running Gdb on the host. The example in this step debugs ``gzip``:
  7856. .. code-block:: shell
  7857. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  7858. For
  7859. additional gdbserver options, see the `GDB Server
  7860. Documentation <https://www.gnu.org/software/gdb/documentation/>`__.
  7861. After running gdbserver on the target, you need to run Gdb on the
  7862. host and configure it and connect to the target. Use these commands:
  7863. ::
  7864. $ cd directory-holding-the-debugfs-directory
  7865. $ arch-gdb
  7866. (gdb) set sysroot debugfs
  7867. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  7868. (gdb) target remote IP-of-target:1234
  7869. At this
  7870. point, everything should automatically load (i.e. matching binaries,
  7871. symbols and headers).
  7872. .. note::
  7873. The Gdb ``set`` commands in the previous example can be placed into the
  7874. users ``~/.gdbinit`` file. Upon starting, Gdb automatically runs whatever
  7875. commands are in that file.
  7876. 8. *Deploying without a full image rebuild:*
  7877. In many cases, during development you want a quick method to deploy a
  7878. new binary to the target and debug it, without waiting for a full
  7879. image build.
  7880. One approach to solving this situation is to just build the component
  7881. you want to debug. Once you have built the component, copy the
  7882. executable directly to both the target and the host ``debugfs``.
  7883. If the binary is processed through the debug splitting in
  7884. OpenEmbedded, you should also copy the debug items (i.e. ``.debug``
  7885. contents and corresponding ``/usr/src/debug`` files) from the work
  7886. directory. Here is an example:
  7887. ::
  7888. $ bitbake bash
  7889. $ bitbake -c devshell bash
  7890. $ cd ..
  7891. $ scp packages-split/bash/bin/bash target:/bin/bash
  7892. $ cp -a packages-split/bash-dbg/\* path/debugfs
  7893. Debugging with the GNU Project Debugger (GDB) on the Target
  7894. -----------------------------------------------------------
  7895. The previous section addressed using GDB remotely for debugging
  7896. purposes, which is the most usual case due to the inherent hardware
  7897. limitations on many embedded devices. However, debugging in the target
  7898. hardware itself is also possible with more powerful devices. This
  7899. section describes what you need to do in order to support using GDB to
  7900. debug on the target hardware.
  7901. To support this kind of debugging, you need do the following:
  7902. - Ensure that GDB is on the target. You can do this by adding "gdb" to
  7903. :term:`IMAGE_INSTALL`:
  7904. ::
  7905. IMAGE_INSTALL_append = " gdb"
  7906. Alternatively, you can add "tools-debug" to :term:`IMAGE_FEATURES`:
  7907. ::
  7908. IMAGE_FEATURES_append = " tools-debug"
  7909. - Ensure that debug symbols are present. You can make sure these
  7910. symbols are present by installing ``-dbg``:
  7911. ::
  7912. IMAGE_INSTALL_append = "packagename-dbg"
  7913. Alternatively, you can do the following to include
  7914. all the debug symbols:
  7915. ::
  7916. IMAGE_FEATURES_append = " dbg-pkgs"
  7917. .. note::
  7918. To improve the debug information accuracy, you can reduce the level
  7919. of optimization used by the compiler. For example, when adding the
  7920. following line to your ``local.conf`` file, you will reduce optimization
  7921. from :term:`FULL_OPTIMIZATION` of "-O2" to :term:`DEBUG_OPTIMIZATION`
  7922. of "-O -fno-omit-frame-pointer":
  7923. ::
  7924. DEBUG_BUILD = "1"
  7925. Consider that this will reduce the application's performance and is
  7926. recommended only for debugging purposes.
  7927. Other Debugging Tips
  7928. --------------------
  7929. Here are some other tips that you might find useful:
  7930. - When adding new packages, it is worth watching for undesirable items
  7931. making their way into compiler command lines. For example, you do not
  7932. want references to local system files like ``/usr/lib/`` or
  7933. ``/usr/include/``.
  7934. - If you want to remove the ``psplash`` boot splashscreen, add
  7935. ``psplash=false`` to the kernel command line. Doing so prevents
  7936. ``psplash`` from loading and thus allows you to see the console. It
  7937. is also possible to switch out of the splashscreen by switching the
  7938. virtual console (e.g. Fn+Left or Fn+Right on a Zaurus).
  7939. - Removing :term:`TMPDIR` (usually
  7940. ``tmp/``, within the
  7941. :term:`Build Directory`) can often fix
  7942. temporary build issues. Removing ``TMPDIR`` is usually a relatively
  7943. cheap operation, because task output will be cached in
  7944. :term:`SSTATE_DIR` (usually
  7945. ``sstate-cache/``, which is also in the Build Directory).
  7946. .. note::
  7947. Removing ``TMPDIR`` might be a workaround rather than a fix.
  7948. Consequently, trying to determine the underlying cause of an issue before
  7949. removing the directory is a good idea.
  7950. - Understanding how a feature is used in practice within existing
  7951. recipes can be very helpful. It is recommended that you configure
  7952. some method that allows you to quickly search through files.
  7953. Using GNU Grep, you can use the following shell function to
  7954. recursively search through common recipe-related files, skipping
  7955. binary files, ``.git`` directories, and the Build Directory (assuming
  7956. its name starts with "build"):
  7957. ::
  7958. g() {
  7959. grep -Ir \
  7960. --exclude-dir=.git \
  7961. --exclude-dir='build*' \
  7962. --include='*.bb*' \
  7963. --include='*.inc*' \
  7964. --include='*.conf*' \
  7965. --include='*.py*' \
  7966. "$@"
  7967. }
  7968. Following are some usage examples:
  7969. ::
  7970. $ g FOO # Search recursively for "FOO"
  7971. $ g -i foo # Search recursively for "foo", ignoring case
  7972. $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
  7973. If figuring
  7974. out how some feature works requires a lot of searching, it might
  7975. indicate that the documentation should be extended or improved. In
  7976. such cases, consider filing a documentation bug using the Yocto
  7977. Project implementation of
  7978. :yocto_bugs:`Bugzilla <>`. For information on
  7979. how to submit a bug against the Yocto Project, see the Yocto Project
  7980. Bugzilla :yocto_wiki:`wiki page </Bugzilla_Configuration_and_Bug_Tracking>`
  7981. and the
  7982. ":ref:`dev-manual/common-tasks:submitting a defect against the yocto project`"
  7983. section.
  7984. .. note::
  7985. The manuals might not be the right place to document variables
  7986. that are purely internal and have a limited scope (e.g. internal
  7987. variables used to implement a single ``.bbclass`` file).
  7988. Making Changes to the Yocto Project
  7989. ===================================
  7990. Because the Yocto Project is an open-source, community-based project,
  7991. you can effect changes to the project. This section presents procedures
  7992. that show you how to submit a defect against the project and how to
  7993. submit a change.
  7994. Submitting a Defect Against the Yocto Project
  7995. ---------------------------------------------
  7996. Use the Yocto Project implementation of
  7997. `Bugzilla <https://www.bugzilla.org/about/>`__ to submit a defect (bug)
  7998. against the Yocto Project. For additional information on this
  7999. implementation of Bugzilla see the ":ref:`Yocto Project
  8000. Bugzilla <resources-bugtracker>`" section in the
  8001. Yocto Project Reference Manual. For more detail on any of the following
  8002. steps, see the Yocto Project
  8003. :yocto_wiki:`Bugzilla wiki page </Bugzilla_Configuration_and_Bug_Tracking>`.
  8004. Use the following general steps to submit a bug:
  8005. 1. Open the Yocto Project implementation of :yocto_bugs:`Bugzilla <>`.
  8006. 2. Click "File a Bug" to enter a new bug.
  8007. 3. Choose the appropriate "Classification", "Product", and "Component"
  8008. for which the bug was found. Bugs for the Yocto Project fall into
  8009. one of several classifications, which in turn break down into
  8010. several products and components. For example, for a bug against the
  8011. ``meta-intel`` layer, you would choose "Build System, Metadata &
  8012. Runtime", "BSPs", and "bsps-meta-intel", respectively.
  8013. 4. Choose the "Version" of the Yocto Project for which you found the
  8014. bug (e.g. &DISTRO;).
  8015. 5. Determine and select the "Severity" of the bug. The severity
  8016. indicates how the bug impacted your work.
  8017. 6. Choose the "Hardware" that the bug impacts.
  8018. 7. Choose the "Architecture" that the bug impacts.
  8019. 8. Choose a "Documentation change" item for the bug. Fixing a bug might
  8020. or might not affect the Yocto Project documentation. If you are
  8021. unsure of the impact to the documentation, select "Don't Know".
  8022. 9. Provide a brief "Summary" of the bug. Try to limit your summary to
  8023. just a line or two and be sure to capture the essence of the bug.
  8024. 10. Provide a detailed "Description" of the bug. You should provide as
  8025. much detail as you can about the context, behavior, output, and so
  8026. forth that surrounds the bug. You can even attach supporting files
  8027. for output from logs by using the "Add an attachment" button.
  8028. 11. Click the "Submit Bug" button submit the bug. A new Bugzilla number
  8029. is assigned to the bug and the defect is logged in the bug tracking
  8030. system.
  8031. Once you file a bug, the bug is processed by the Yocto Project Bug
  8032. Triage Team and further details concerning the bug are assigned (e.g.
  8033. priority and owner). You are the "Submitter" of the bug and any further
  8034. categorization, progress, or comments on the bug result in Bugzilla
  8035. sending you an automated email concerning the particular change or
  8036. progress to the bug.
  8037. Submitting a Change to the Yocto Project
  8038. ----------------------------------------
  8039. Contributions to the Yocto Project and OpenEmbedded are very welcome.
  8040. Because the system is extremely configurable and flexible, we recognize
  8041. that developers will want to extend, configure or optimize it for their
  8042. specific uses.
  8043. The Yocto Project uses a mailing list and a patch-based workflow that is
  8044. similar to the Linux kernel but contains important differences. In
  8045. general, a mailing list exists through which you can submit patches. You
  8046. should send patches to the appropriate mailing list so that they can be
  8047. reviewed and merged by the appropriate maintainer. The specific mailing
  8048. list you need to use depends on the location of the code you are
  8049. changing. Each component (e.g. layer) should have a ``README`` file that
  8050. indicates where to send the changes and which process to follow.
  8051. You can send the patch to the mailing list using whichever approach you
  8052. feel comfortable with to generate the patch. Once sent, the patch is
  8053. usually reviewed by the community at large. If somebody has concerns
  8054. with the patch, they will usually voice their concern over the mailing
  8055. list. If a patch does not receive any negative reviews, the maintainer
  8056. of the affected layer typically takes the patch, tests it, and then
  8057. based on successful testing, merges the patch.
  8058. The "poky" repository, which is the Yocto Project's reference build
  8059. environment, is a hybrid repository that contains several individual
  8060. pieces (e.g. BitBake, Metadata, documentation, and so forth) built using
  8061. the combo-layer tool. The upstream location used for submitting changes
  8062. varies by component:
  8063. - *Core Metadata:* Send your patch to the
  8064. :oe_lists:`openembedded-core </g/openembedded-core>`
  8065. mailing list. For example, a change to anything under the ``meta`` or
  8066. ``scripts`` directories should be sent to this mailing list.
  8067. - *BitBake:* For changes to BitBake (i.e. anything under the
  8068. ``bitbake`` directory), send your patch to the
  8069. :oe_lists:`bitbake-devel </g/bitbake-devel>`
  8070. mailing list.
  8071. - *"meta-\*" trees:* These trees contain Metadata. Use the
  8072. :yocto_lists:`poky </g/poky>` mailing list.
  8073. - *Documentation*: For changes to the Yocto Project documentation, use the
  8074. :yocto_lists:`docs </g/docs>` mailing list.
  8075. For changes to other layers hosted in the Yocto Project source
  8076. repositories (i.e. ``yoctoproject.org``) and tools use the
  8077. :yocto_lists:`Yocto Project </g/yocto/>` general mailing list.
  8078. .. note::
  8079. Sometimes a layer's documentation specifies to use a particular
  8080. mailing list. If so, use that list.
  8081. For additional recipes that do not fit into the core Metadata, you
  8082. should determine which layer the recipe should go into and submit the
  8083. change in the manner recommended by the documentation (e.g. the
  8084. ``README`` file) supplied with the layer. If in doubt, please ask on the
  8085. Yocto general mailing list or on the openembedded-devel mailing list.
  8086. You can also push a change upstream and request a maintainer to pull the
  8087. change into the component's upstream repository. You do this by pushing
  8088. to a contribution repository that is upstream. See the
  8089. ":ref:`overview-manual/development-environment:git workflows and the yocto project`"
  8090. section in the Yocto Project Overview and Concepts Manual for additional
  8091. concepts on working in the Yocto Project development environment.
  8092. Maintainers commonly use ``-next`` branches to test submissions prior to
  8093. merging patches. Thus, you can get an idea of the status of a patch based on
  8094. whether the patch has been merged into one of these branches. The commonly
  8095. used testing branches for OpenEmbedded-Core are as follows:
  8096. - *openembedded-core "master-next" branch:* This branch is part of the
  8097. :oe_git:`openembedded-core </openembedded-core/>` repository and contains
  8098. proposed changes to the core metadata.
  8099. - *poky "master-next" branch:* This branch is part of the
  8100. :yocto_git:`poky </poky/>` repository and combines proposed
  8101. changes to bitbake, the core metadata and the poky distro.
  8102. Similarly, stable branches maintained by the project may have corresponding
  8103. ``-next`` branches which collect proposed changes. For example,
  8104. ``&DISTRO_NAME_NO_CAP;-next`` and ``&DISTRO_NAME_NO_CAP_MINUS_ONE;-next``
  8105. branches in both the "openembdedded-core" and "poky" repositories.
  8106. Other layers may have similar testing branches but there is no formal
  8107. requirement or standard for these so please check the documentation for the
  8108. layers you are contributing to.
  8109. The following sections provide procedures for submitting a change.
  8110. Preparing Changes for Submission
  8111. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8112. 1. *Make Your Changes Locally:* Make your changes in your local Git
  8113. repository. You should make small, controlled, isolated changes.
  8114. Keeping changes small and isolated aids review, makes
  8115. merging/rebasing easier and keeps the change history clean should
  8116. anyone need to refer to it in future.
  8117. 2. *Stage Your Changes:* Stage your changes by using the ``git add``
  8118. command on each file you changed.
  8119. 3. *Commit Your Changes:* Commit the change by using the ``git commit``
  8120. command. Make sure your commit information follows standards by
  8121. following these accepted conventions:
  8122. - Be sure to include a "Signed-off-by:" line in the same style as
  8123. required by the Linux kernel. Adding this line signifies that you,
  8124. the submitter, have agreed to the Developer's Certificate of
  8125. Origin 1.1 as follows:
  8126. .. code-block:: none
  8127. Developer's Certificate of Origin 1.1
  8128. By making a contribution to this project, I certify that:
  8129. (a) The contribution was created in whole or in part by me and I
  8130. have the right to submit it under the open source license
  8131. indicated in the file; or
  8132. (b) The contribution is based upon previous work that, to the best
  8133. of my knowledge, is covered under an appropriate open source
  8134. license and I have the right under that license to submit that
  8135. work with modifications, whether created in whole or in part
  8136. by me, under the same open source license (unless I am
  8137. permitted to submit under a different license), as indicated
  8138. in the file; or
  8139. (c) The contribution was provided directly to me by some other
  8140. person who certified (a), (b) or (c) and I have not modified
  8141. it.
  8142. (d) I understand and agree that this project and the contribution
  8143. are public and that a record of the contribution (including all
  8144. personal information I submit with it, including my sign-off) is
  8145. maintained indefinitely and may be redistributed consistent with
  8146. this project or the open source license(s) involved.
  8147. - Provide a single-line summary of the change and, if more
  8148. explanation is needed, provide more detail in the body of the
  8149. commit. This summary is typically viewable in the "shortlist" of
  8150. changes. Thus, providing something short and descriptive that
  8151. gives the reader a summary of the change is useful when viewing a
  8152. list of many commits. You should prefix this short description
  8153. with the recipe name (if changing a recipe), or else with the
  8154. short form path to the file being changed.
  8155. - For the body of the commit message, provide detailed information
  8156. that describes what you changed, why you made the change, and the
  8157. approach you used. It might also be helpful if you mention how you
  8158. tested the change. Provide as much detail as you can in the body
  8159. of the commit message.
  8160. .. note::
  8161. You do not need to provide a more detailed explanation of a
  8162. change if the change is minor to the point of the single line
  8163. summary providing all the information.
  8164. - If the change addresses a specific bug or issue that is associated
  8165. with a bug-tracking ID, include a reference to that ID in your
  8166. detailed description. For example, the Yocto Project uses a
  8167. specific convention for bug references - any commit that addresses
  8168. a specific bug should use the following form for the detailed
  8169. description. Be sure to use the actual bug-tracking ID from
  8170. Bugzilla for bug-id:
  8171. ::
  8172. Fixes [YOCTO #bug-id]
  8173. detailed description of change
  8174. Using Email to Submit a Patch
  8175. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8176. Depending on the components changed, you need to submit the email to a
  8177. specific mailing list. For some guidance on which mailing list to use,
  8178. see the
  8179. :ref:`list <dev-manual/common-tasks:submitting a change to the yocto project>`
  8180. at the beginning of this section. For a description of all the available
  8181. mailing lists, see the ":ref:`Mailing Lists <resources-mailinglist>`" section in the
  8182. Yocto Project Reference Manual.
  8183. Here is the general procedure on how to submit a patch through email
  8184. without using the scripts once the steps in
  8185. :ref:`dev-manual/common-tasks:preparing changes for submission` have been followed:
  8186. 1. *Format the Commit:* Format the commit into an email message. To
  8187. format commits, use the ``git format-patch`` command. When you
  8188. provide the command, you must include a revision list or a number of
  8189. patches as part of the command. For example, either of these two
  8190. commands takes your most recent single commit and formats it as an
  8191. email message in the current directory:
  8192. ::
  8193. $ git format-patch -1
  8194. or ::
  8195. $ git format-patch HEAD~
  8196. After the command is run, the current directory contains a numbered
  8197. ``.patch`` file for the commit.
  8198. If you provide several commits as part of the command, the
  8199. ``git format-patch`` command produces a series of numbered files in
  8200. the current directory – one for each commit. If you have more than
  8201. one patch, you should also use the ``--cover`` option with the
  8202. command, which generates a cover letter as the first "patch" in the
  8203. series. You can then edit the cover letter to provide a description
  8204. for the series of patches. For information on the
  8205. ``git format-patch`` command, see ``GIT_FORMAT_PATCH(1)`` displayed
  8206. using the ``man git-format-patch`` command.
  8207. .. note::
  8208. If you are or will be a frequent contributor to the Yocto Project
  8209. or to OpenEmbedded, you might consider requesting a contrib area
  8210. and the necessary associated rights.
  8211. 2. *Send the patches via email:* Send the patches to the recipients and
  8212. relevant mailing lists by using the ``git send-email`` command.
  8213. .. note::
  8214. In order to use ``git send-email``, you must have the proper Git packages
  8215. installed on your host.
  8216. For Ubuntu, Debian, and Fedora the package is ``git-email``.
  8217. The ``git send-email`` command sends email by using a local or remote
  8218. Mail Transport Agent (MTA) such as ``msmtp``, ``sendmail``, or
  8219. through a direct ``smtp`` configuration in your Git ``~/.gitconfig``
  8220. file. If you are submitting patches through email only, it is very
  8221. important that you submit them without any whitespace or HTML
  8222. formatting that either you or your mailer introduces. The maintainer
  8223. that receives your patches needs to be able to save and apply them
  8224. directly from your emails. A good way to verify that what you are
  8225. sending will be applicable by the maintainer is to do a dry run and
  8226. send them to yourself and then save and apply them as the maintainer
  8227. would.
  8228. The ``git send-email`` command is the preferred method for sending
  8229. your patches using email since there is no risk of compromising
  8230. whitespace in the body of the message, which can occur when you use
  8231. your own mail client. The command also has several options that let
  8232. you specify recipients and perform further editing of the email
  8233. message. For information on how to use the ``git send-email``
  8234. command, see ``GIT-SEND-EMAIL(1)`` displayed using the
  8235. ``man git-send-email`` command.
  8236. The Yocto Project uses a `Patchwork instance <https://patchwork.openembedded.org/>`__
  8237. to track the status of patches submitted to the various mailing lists and to
  8238. support automated patch testing. Each submitted patch is checked for common
  8239. mistakes and deviations from the expected patch format and submitters are
  8240. notified by patchtest if such mistakes are found. This process helps to
  8241. reduce the burden of patch review on maintainers.
  8242. .. note::
  8243. This system is imperfect and changes can sometimes get lost in the flow.
  8244. Asking about the status of a patch or change is reasonable if the change
  8245. has been idle for a while with no feedback.
  8246. Using Scripts to Push a Change Upstream and Request a Pull
  8247. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8248. For larger patch series it is preferable to send a pull request which not
  8249. only includes the patch but also a pointer to a branch that can be pulled
  8250. from. This involves making a local branch for your changes, pushing this
  8251. branch to an accessible repository and then using the ``create-pull-request``
  8252. and ``send-pull-request`` scripts from openembedded-core to create and send a
  8253. patch series with a link to the branch for review.
  8254. Follow this procedure to push a change to an upstream "contrib" Git
  8255. repository once the steps in :ref:`dev-manual/common-tasks:preparing changes for submission` have
  8256. been followed:
  8257. .. note::
  8258. You can find general Git information on how to push a change upstream
  8259. in the
  8260. `Git Community Book <https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows>`__.
  8261. 1. *Push Your Commits to a "Contrib" Upstream:* If you have arranged for
  8262. permissions to push to an upstream contrib repository, push the
  8263. change to that repository:
  8264. ::
  8265. $ git push upstream_remote_repo local_branch_name
  8266. For example, suppose you have permissions to push
  8267. into the upstream ``meta-intel-contrib`` repository and you are
  8268. working in a local branch named `your_name`\ ``/README``. The following
  8269. command pushes your local commits to the ``meta-intel-contrib``
  8270. upstream repository and puts the commit in a branch named
  8271. `your_name`\ ``/README``:
  8272. ::
  8273. $ git push meta-intel-contrib your_name/README
  8274. 2. *Determine Who to Notify:* Determine the maintainer or the mailing
  8275. list that you need to notify for the change.
  8276. Before submitting any change, you need to be sure who the maintainer
  8277. is or what mailing list that you need to notify. Use either these
  8278. methods to find out:
  8279. - *Maintenance File:* Examine the ``maintainers.inc`` file, which is
  8280. located in the :term:`Source Directory` at
  8281. ``meta/conf/distro/include``, to see who is responsible for code.
  8282. - *Search by File:* Using :ref:`overview-manual/development-environment:git`, you can
  8283. enter the following command to bring up a short list of all
  8284. commits against a specific file:
  8285. ::
  8286. git shortlog -- filename
  8287. Just provide the name of the file for which you are interested. The
  8288. information returned is not ordered by history but does include a
  8289. list of everyone who has committed grouped by name. From the list,
  8290. you can see who is responsible for the bulk of the changes against
  8291. the file.
  8292. - *Examine the List of Mailing Lists:* For a list of the Yocto
  8293. Project and related mailing lists, see the ":ref:`Mailing
  8294. lists <resources-mailinglist>`" section in
  8295. the Yocto Project Reference Manual.
  8296. 3. *Make a Pull Request:* Notify the maintainer or the mailing list that
  8297. you have pushed a change by making a pull request.
  8298. The Yocto Project provides two scripts that conveniently let you
  8299. generate and send pull requests to the Yocto Project. These scripts
  8300. are ``create-pull-request`` and ``send-pull-request``. You can find
  8301. these scripts in the ``scripts`` directory within the
  8302. :term:`Source Directory` (e.g.
  8303. ``poky/scripts``).
  8304. Using these scripts correctly formats the requests without
  8305. introducing any whitespace or HTML formatting. The maintainer that
  8306. receives your patches either directly or through the mailing list
  8307. needs to be able to save and apply them directly from your emails.
  8308. Using these scripts is the preferred method for sending patches.
  8309. First, create the pull request. For example, the following command
  8310. runs the script, specifies the upstream repository in the contrib
  8311. directory into which you pushed the change, and provides a subject
  8312. line in the created patch files:
  8313. ::
  8314. $ poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
  8315. Running this script forms ``*.patch`` files in a folder named
  8316. ``pull-``\ `PID` in the current directory. One of the patch files is a
  8317. cover letter.
  8318. Before running the ``send-pull-request`` script, you must edit the
  8319. cover letter patch to insert information about your change. After
  8320. editing the cover letter, send the pull request. For example, the
  8321. following command runs the script and specifies the patch directory
  8322. and email address. In this example, the email address is a mailing
  8323. list:
  8324. ::
  8325. $ poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@yoctoproject.org
  8326. You need to follow the prompts as the script is interactive.
  8327. .. note::
  8328. For help on using these scripts, simply provide the ``-h``
  8329. argument as follows:
  8330. ::
  8331. $ poky/scripts/create-pull-request -h
  8332. $ poky/scripts/send-pull-request -h
  8333. Responding to Patch Review
  8334. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  8335. You may get feedback on your submitted patches from other community members
  8336. or from the automated patchtest service. If issues are identified in your
  8337. patch then it is usually necessary to address these before the patch will be
  8338. accepted into the project. In this case you should amend the patch according
  8339. to the feedback and submit an updated version to the relevant mailing list,
  8340. copying in the reviewers who provided feedback to the previous version of the
  8341. patch.
  8342. The patch should be amended using ``git commit --amend`` or perhaps ``git
  8343. rebase`` for more expert git users. You should also modify the ``[PATCH]``
  8344. tag in the email subject line when sending the revised patch to mark the new
  8345. iteration as ``[PATCH v2]``, ``[PATCH v3]``, etc as appropriate. This can be
  8346. done by passing the ``-v`` argument to ``git format-patch`` with a version
  8347. number.
  8348. Lastly please ensure that you also test your revised changes. In particular
  8349. please don't just edit the patch file written out by ``git format-patch`` and
  8350. resend it.
  8351. Submitting Changes to Stable Release Branches
  8352. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8353. The process for proposing changes to a Yocto Project stable branch differs
  8354. from the steps described above. Changes to a stable branch must address
  8355. identified bugs or CVEs and should be made carefully in order to avoid the
  8356. risk of introducing new bugs or breaking backwards compatibility. Typically
  8357. bug fixes must already be accepted into the master branch before they can be
  8358. backported to a stable branch unless the bug in question does not affect the
  8359. master branch or the fix on the master branch is unsuitable for backporting.
  8360. The list of stable branches along with the status and maintainer for each
  8361. branch can be obtained from the
  8362. :yocto_wiki:`Releases wiki page </Releases>`.
  8363. .. note::
  8364. Changes will not typically be accepted for branches which are marked as
  8365. End-Of-Life (EOL).
  8366. With this in mind, the steps to submit a change for a stable branch are as
  8367. follows:
  8368. 1. *Identify the bug or CVE to be fixed:* This information should be
  8369. collected so that it can be included in your submission.
  8370. 2. *Check if the fix is already present in the master branch:* This will
  8371. result in the most straightforward path into the stable branch for the
  8372. fix.
  8373. a. *If the fix is present in the master branch - Submit a backport request
  8374. by email:* You should send an email to the relevant stable branch
  8375. maintainer and the mailing list with details of the bug or CVE to be
  8376. fixed, the commit hash on the master branch that fixes the issue and
  8377. the stable branches which you would like this fix to be backported to.
  8378. b. *If the fix is not present in the master branch - Submit the fix to the
  8379. master branch first:* This will ensure that the fix passes through the
  8380. project's usual patch review and test processes before being accepted.
  8381. It will also ensure that bugs are not left unresolved in the master
  8382. branch itself. Once the fix is accepted in the master branch a backport
  8383. request can be submitted as above.
  8384. c. *If the fix is unsuitable for the master branch - Submit a patch
  8385. directly for the stable branch:* This method should be considered as a
  8386. last resort. It is typically necessary when the master branch is using
  8387. a newer version of the software which includes an upstream fix for the
  8388. issue or when the issue has been fixed on the master branch in a way
  8389. that introduces backwards incompatible changes. In this case follow the
  8390. steps in :ref:`dev-manual/common-tasks:preparing changes for submission` and
  8391. :ref:`dev-manual/common-tasks:using email to submit a patch` but modify the subject header of your patch
  8392. email to include the name of the stable branch which you are
  8393. targetting. This can be done using the ``--subject-prefix`` argument to
  8394. ``git format-patch``, for example to submit a patch to the dunfell
  8395. branch use
  8396. ``git format-patch --subject-prefix='&DISTRO_NAME_NO_CAP_MINUS_ONE;][PATCH' ...``.
  8397. Working With Licenses
  8398. =====================
  8399. As mentioned in the ":ref:`overview-manual/development-environment:licensing`"
  8400. section in the Yocto Project Overview and Concepts Manual, open source
  8401. projects are open to the public and they consequently have different
  8402. licensing structures in place. This section describes the mechanism by
  8403. which the :term:`OpenEmbedded Build System`
  8404. tracks changes to
  8405. licensing text and covers how to maintain open source license compliance
  8406. during your project's lifecycle. The section also describes how to
  8407. enable commercially licensed recipes, which by default are disabled.
  8408. Tracking License Changes
  8409. ------------------------
  8410. The license of an upstream project might change in the future. In order
  8411. to prevent these changes going unnoticed, the
  8412. :term:`LIC_FILES_CHKSUM`
  8413. variable tracks changes to the license text. The checksums are validated
  8414. at the end of the configure step, and if the checksums do not match, the
  8415. build will fail.
  8416. Specifying the ``LIC_FILES_CHKSUM`` Variable
  8417. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8418. The ``LIC_FILES_CHKSUM`` variable contains checksums of the license text
  8419. in the source code for the recipe. Following is an example of how to
  8420. specify ``LIC_FILES_CHKSUM``:
  8421. ::
  8422. LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \
  8423. file://licfile1.txt;beginline=5;endline=29;md5=yyyy \
  8424. file://licfile2.txt;endline=50;md5=zzzz \
  8425. ..."
  8426. .. note::
  8427. - When using "beginline" and "endline", realize that line numbering
  8428. begins with one and not zero. Also, the included lines are
  8429. inclusive (i.e. lines five through and including 29 in the
  8430. previous example for ``licfile1.txt``).
  8431. - When a license check fails, the selected license text is included
  8432. as part of the QA message. Using this output, you can determine
  8433. the exact start and finish for the needed license text.
  8434. The build system uses the :term:`S`
  8435. variable as the default directory when searching files listed in
  8436. ``LIC_FILES_CHKSUM``. The previous example employs the default
  8437. directory.
  8438. Consider this next example:
  8439. ::
  8440. LIC_FILES_CHKSUM = "file://src/ls.c;beginline=5;endline=16;\
  8441. md5=bb14ed3c4cda583abc85401304b5cd4e"
  8442. LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6"
  8443. The first line locates a file in ``${S}/src/ls.c`` and isolates lines
  8444. five through 16 as license text. The second line refers to a file in
  8445. :term:`WORKDIR`.
  8446. Note that ``LIC_FILES_CHKSUM`` variable is mandatory for all recipes,
  8447. unless the ``LICENSE`` variable is set to "CLOSED".
  8448. Explanation of Syntax
  8449. ~~~~~~~~~~~~~~~~~~~~~
  8450. As mentioned in the previous section, the ``LIC_FILES_CHKSUM`` variable
  8451. lists all the important files that contain the license text for the
  8452. source code. It is possible to specify a checksum for an entire file, or
  8453. a specific section of a file (specified by beginning and ending line
  8454. numbers with the "beginline" and "endline" parameters, respectively).
  8455. The latter is useful for source files with a license notice header,
  8456. README documents, and so forth. If you do not use the "beginline"
  8457. parameter, then it is assumed that the text begins on the first line of
  8458. the file. Similarly, if you do not use the "endline" parameter, it is
  8459. assumed that the license text ends with the last line of the file.
  8460. The "md5" parameter stores the md5 checksum of the license text. If the
  8461. license text changes in any way as compared to this parameter then a
  8462. mismatch occurs. This mismatch triggers a build failure and notifies the
  8463. developer. Notification allows the developer to review and address the
  8464. license text changes. Also note that if a mismatch occurs during the
  8465. build, the correct md5 checksum is placed in the build log and can be
  8466. easily copied to the recipe.
  8467. There is no limit to how many files you can specify using the
  8468. ``LIC_FILES_CHKSUM`` variable. Generally, however, every project
  8469. requires a few specifications for license tracking. Many projects have a
  8470. "COPYING" file that stores the license information for all the source
  8471. code files. This practice allows you to just track the "COPYING" file as
  8472. long as it is kept up to date.
  8473. .. note::
  8474. - If you specify an empty or invalid "md5" parameter,
  8475. :term:`BitBake` returns an md5
  8476. mis-match error and displays the correct "md5" parameter value
  8477. during the build. The correct parameter is also captured in the
  8478. build log.
  8479. - If the whole file contains only license text, you do not need to
  8480. use the "beginline" and "endline" parameters.
  8481. Enabling Commercially Licensed Recipes
  8482. --------------------------------------
  8483. By default, the OpenEmbedded build system disables components that have
  8484. commercial or other special licensing requirements. Such requirements
  8485. are defined on a recipe-by-recipe basis through the
  8486. :term:`LICENSE_FLAGS` variable
  8487. definition in the affected recipe. For instance, the
  8488. ``poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly`` recipe
  8489. contains the following statement:
  8490. ::
  8491. LICENSE_FLAGS = "commercial"
  8492. Here is a
  8493. slightly more complicated example that contains both an explicit recipe
  8494. name and version (after variable expansion):
  8495. ::
  8496. LICENSE_FLAGS = "license_${PN}_${PV}"
  8497. In order for a component restricted by a
  8498. ``LICENSE_FLAGS`` definition to be enabled and included in an image, it
  8499. needs to have a matching entry in the global
  8500. :term:`LICENSE_FLAGS_WHITELIST`
  8501. variable, which is a variable typically defined in your ``local.conf``
  8502. file. For example, to enable the
  8503. ``poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly`` package, you
  8504. could add either the string "commercial_gst-plugins-ugly" or the more
  8505. general string "commercial" to ``LICENSE_FLAGS_WHITELIST``. See the
  8506. ":ref:`dev-manual/common-tasks:license flag matching`" section for a full
  8507. explanation of how ``LICENSE_FLAGS`` matching works. Here is the
  8508. example:
  8509. ::
  8510. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly"
  8511. Likewise, to additionally enable the package built from the recipe
  8512. containing ``LICENSE_FLAGS = "license_${PN}_${PV}"``, and assuming that
  8513. the actual recipe name was ``emgd_1.10.bb``, the following string would
  8514. enable that package as well as the original ``gst-plugins-ugly``
  8515. package:
  8516. ::
  8517. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10"
  8518. As a convenience, you do not need to specify the
  8519. complete license string in the whitelist for every package. You can use
  8520. an abbreviated form, which consists of just the first portion or
  8521. portions of the license string before the initial underscore character
  8522. or characters. A partial string will match any license that contains the
  8523. given string as the first portion of its license. For example, the
  8524. following whitelist string will also match both of the packages
  8525. previously mentioned as well as any other packages that have licenses
  8526. starting with "commercial" or "license".
  8527. ::
  8528. LICENSE_FLAGS_WHITELIST = "commercial license"
  8529. License Flag Matching
  8530. ~~~~~~~~~~~~~~~~~~~~~
  8531. License flag matching allows you to control what recipes the
  8532. OpenEmbedded build system includes in the build. Fundamentally, the
  8533. build system attempts to match ``LICENSE_FLAGS`` strings found in
  8534. recipes against ``LICENSE_FLAGS_WHITELIST`` strings found in the
  8535. whitelist. A match causes the build system to include a recipe in the
  8536. build, while failure to find a match causes the build system to exclude
  8537. a recipe.
  8538. In general, license flag matching is simple. However, understanding some
  8539. concepts will help you correctly and effectively use matching.
  8540. Before a flag defined by a particular recipe is tested against the
  8541. contents of the whitelist, the expanded string ``_${PN}`` is appended to
  8542. the flag. This expansion makes each ``LICENSE_FLAGS`` value
  8543. recipe-specific. After expansion, the string is then matched against the
  8544. whitelist. Thus, specifying ``LICENSE_FLAGS = "commercial"`` in recipe
  8545. "foo", for example, results in the string ``"commercial_foo"``. And, to
  8546. create a match, that string must appear in the whitelist.
  8547. Judicious use of the ``LICENSE_FLAGS`` strings and the contents of the
  8548. ``LICENSE_FLAGS_WHITELIST`` variable allows you a lot of flexibility for
  8549. including or excluding recipes based on licensing. For example, you can
  8550. broaden the matching capabilities by using license flags string subsets
  8551. in the whitelist.
  8552. .. note::
  8553. When using a string subset, be sure to use the part of the expanded
  8554. string that precedes the appended underscore character (e.g.
  8555. ``usethispart_1.3``, ``usethispart_1.4``, and so forth).
  8556. For example, simply specifying the string "commercial" in the whitelist
  8557. matches any expanded ``LICENSE_FLAGS`` definition that starts with the
  8558. string "commercial" such as "commercial_foo" and "commercial_bar", which
  8559. are the strings the build system automatically generates for
  8560. hypothetical recipes named "foo" and "bar" assuming those recipes simply
  8561. specify the following:
  8562. ::
  8563. LICENSE_FLAGS = "commercial"
  8564. Thus, you can choose
  8565. to exhaustively enumerate each license flag in the whitelist and allow
  8566. only specific recipes into the image, or you can use a string subset
  8567. that causes a broader range of matches to allow a range of recipes into
  8568. the image.
  8569. This scheme works even if the ``LICENSE_FLAGS`` string already has
  8570. ``_${PN}`` appended. For example, the build system turns the license
  8571. flag "commercial_1.2_foo" into "commercial_1.2_foo_foo" and would match
  8572. both the general "commercial" and the specific "commercial_1.2_foo"
  8573. strings found in the whitelist, as expected.
  8574. Here are some other scenarios:
  8575. - You can specify a versioned string in the recipe such as
  8576. "commercial_foo_1.2" in a "foo" recipe. The build system expands this
  8577. string to "commercial_foo_1.2_foo". Combine this license flag with a
  8578. whitelist that has the string "commercial" and you match the flag
  8579. along with any other flag that starts with the string "commercial".
  8580. - Under the same circumstances, you can use "commercial_foo" in the
  8581. whitelist and the build system not only matches "commercial_foo_1.2"
  8582. but also matches any license flag with the string "commercial_foo",
  8583. regardless of the version.
  8584. - You can be very specific and use both the package and version parts
  8585. in the whitelist (e.g. "commercial_foo_1.2") to specifically match a
  8586. versioned recipe.
  8587. Other Variables Related to Commercial Licenses
  8588. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8589. Other helpful variables related to commercial license handling exist and
  8590. are defined in the
  8591. ``poky/meta/conf/distro/include/default-distrovars.inc`` file:
  8592. ::
  8593. COMMERCIAL_AUDIO_PLUGINS ?= ""
  8594. COMMERCIAL_VIDEO_PLUGINS ?= ""
  8595. If you
  8596. want to enable these components, you can do so by making sure you have
  8597. statements similar to the following in your ``local.conf`` configuration
  8598. file:
  8599. ::
  8600. COMMERCIAL_AUDIO_PLUGINS = "gst-plugins-ugly-mad \
  8601. gst-plugins-ugly-mpegaudioparse"
  8602. COMMERCIAL_VIDEO_PLUGINS = "gst-plugins-ugly-mpeg2dec \
  8603. gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse"
  8604. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly commercial_gst-plugins-bad commercial_qmmp"
  8605. Of course, you could also create a matching whitelist for those
  8606. components using the more general "commercial" in the whitelist, but
  8607. that would also enable all the other packages with ``LICENSE_FLAGS``
  8608. containing "commercial", which you may or may not want:
  8609. ::
  8610. LICENSE_FLAGS_WHITELIST = "commercial"
  8611. Specifying audio and video plugins as part of the
  8612. ``COMMERCIAL_AUDIO_PLUGINS`` and ``COMMERCIAL_VIDEO_PLUGINS`` statements
  8613. (along with the enabling ``LICENSE_FLAGS_WHITELIST``) includes the
  8614. plugins or components into built images, thus adding support for media
  8615. formats or components.
  8616. Maintaining Open Source License Compliance During Your Product's Lifecycle
  8617. --------------------------------------------------------------------------
  8618. One of the concerns for a development organization using open source
  8619. software is how to maintain compliance with various open source
  8620. licensing during the lifecycle of the product. While this section does
  8621. not provide legal advice or comprehensively cover all scenarios, it does
  8622. present methods that you can use to assist you in meeting the compliance
  8623. requirements during a software release.
  8624. With hundreds of different open source licenses that the Yocto Project
  8625. tracks, it is difficult to know the requirements of each and every
  8626. license. However, the requirements of the major FLOSS licenses can begin
  8627. to be covered by assuming that three main areas of concern exist:
  8628. - Source code must be provided.
  8629. - License text for the software must be provided.
  8630. - Compilation scripts and modifications to the source code must be
  8631. provided.
  8632. - spdx files can be provided.
  8633. There are other requirements beyond the scope of these three and the
  8634. methods described in this section (e.g. the mechanism through which
  8635. source code is distributed).
  8636. As different organizations have different methods of complying with open
  8637. source licensing, this section is not meant to imply that there is only
  8638. one single way to meet your compliance obligations, but rather to
  8639. describe one method of achieving compliance. The remainder of this
  8640. section describes methods supported to meet the previously mentioned
  8641. three requirements. Once you take steps to meet these requirements, and
  8642. prior to releasing images, sources, and the build system, you should
  8643. audit all artifacts to ensure completeness.
  8644. .. note::
  8645. The Yocto Project generates a license manifest during image creation
  8646. that is located in ``${DEPLOY_DIR}/licenses/``\ `image_name`\ ``-``\ `datestamp`
  8647. to assist with any audits.
  8648. Providing the Source Code
  8649. ~~~~~~~~~~~~~~~~~~~~~~~~~
  8650. Compliance activities should begin before you generate the final image.
  8651. The first thing you should look at is the requirement that tops the list
  8652. for most compliance groups - providing the source. The Yocto Project has
  8653. a few ways of meeting this requirement.
  8654. One of the easiest ways to meet this requirement is to provide the
  8655. entire :term:`DL_DIR` used by the
  8656. build. This method, however, has a few issues. The most obvious is the
  8657. size of the directory since it includes all sources used in the build
  8658. and not just the source used in the released image. It will include
  8659. toolchain source, and other artifacts, which you would not generally
  8660. release. However, the more serious issue for most companies is
  8661. accidental release of proprietary software. The Yocto Project provides
  8662. an :ref:`archiver <ref-classes-archiver>` class to
  8663. help avoid some of these concerns.
  8664. Before you employ ``DL_DIR`` or the ``archiver`` class, you need to
  8665. decide how you choose to provide source. The source ``archiver`` class
  8666. can generate tarballs and SRPMs and can create them with various levels
  8667. of compliance in mind.
  8668. One way of doing this (but certainly not the only way) is to release
  8669. just the source as a tarball. You can do this by adding the following to
  8670. the ``local.conf`` file found in the
  8671. :term:`Build Directory`:
  8672. ::
  8673. INHERIT += "archiver"
  8674. ARCHIVER_MODE[src] = "original"
  8675. During the creation of your
  8676. image, the source from all recipes that deploy packages to the image is
  8677. placed within subdirectories of ``DEPLOY_DIR/sources`` based on the
  8678. :term:`LICENSE` for each recipe.
  8679. Releasing the entire directory enables you to comply with requirements
  8680. concerning providing the unmodified source. It is important to note that
  8681. the size of the directory can get large.
  8682. A way to help mitigate the size issue is to only release tarballs for
  8683. licenses that require the release of source. Let us assume you are only
  8684. concerned with GPL code as identified by running the following script:
  8685. .. code-block:: shell
  8686. # Script to archive a subset of packages matching specific license(s)
  8687. # Source and license files are copied into sub folders of package folder
  8688. # Must be run from build folder
  8689. #!/bin/bash
  8690. src_release_dir="source-release"
  8691. mkdir -p $src_release_dir
  8692. for a in tmp/deploy/sources/*; do
  8693. for d in $a/*; do
  8694. # Get package name from path
  8695. p=`basename $d`
  8696. p=${p%-*}
  8697. p=${p%-*}
  8698. # Only archive GPL packages (update *GPL* regex for your license check)
  8699. numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
  8700. if [ $numfiles -gt 1 ]; then
  8701. echo Archiving $p
  8702. mkdir -p $src_release_dir/$p/source
  8703. cp $d/* $src_release_dir/$p/source 2> /dev/null
  8704. mkdir -p $src_release_dir/$p/license
  8705. cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
  8706. fi
  8707. done
  8708. done
  8709. At this point, you
  8710. could create a tarball from the ``gpl_source_release`` directory and
  8711. provide that to the end user. This method would be a step toward
  8712. achieving compliance with section 3a of GPLv2 and with section 6 of
  8713. GPLv3.
  8714. Providing License Text
  8715. ~~~~~~~~~~~~~~~~~~~~~~
  8716. One requirement that is often overlooked is inclusion of license text.
  8717. This requirement also needs to be dealt with prior to generating the
  8718. final image. Some licenses require the license text to accompany the
  8719. binary. You can achieve this by adding the following to your
  8720. ``local.conf`` file:
  8721. ::
  8722. COPY_LIC_MANIFEST = "1"
  8723. COPY_LIC_DIRS = "1"
  8724. LICENSE_CREATE_PACKAGE = "1"
  8725. Adding these statements to the
  8726. configuration file ensures that the licenses collected during package
  8727. generation are included on your image.
  8728. .. note::
  8729. Setting all three variables to "1" results in the image having two
  8730. copies of the same license file. One copy resides in
  8731. ``/usr/share/common-licenses`` and the other resides in
  8732. ``/usr/share/license``.
  8733. The reason for this behavior is because
  8734. :term:`COPY_LIC_DIRS` and
  8735. :term:`COPY_LIC_MANIFEST`
  8736. add a copy of the license when the image is built but do not offer a
  8737. path for adding licenses for newly installed packages to an image.
  8738. :term:`LICENSE_CREATE_PACKAGE`
  8739. adds a separate package and an upgrade path for adding licenses to an
  8740. image.
  8741. As the source ``archiver`` class has already archived the original
  8742. unmodified source that contains the license files, you would have
  8743. already met the requirements for inclusion of the license information
  8744. with source as defined by the GPL and other open source licenses.
  8745. Providing Compilation Scripts and Source Code Modifications
  8746. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8747. At this point, we have addressed all we need to prior to generating the
  8748. image. The next two requirements are addressed during the final
  8749. packaging of the release.
  8750. By releasing the version of the OpenEmbedded build system and the layers
  8751. used during the build, you will be providing both compilation scripts
  8752. and the source code modifications in one step.
  8753. If the deployment team has a :ref:`overview-manual/concepts:bsp layer`
  8754. and a distro layer, and those
  8755. those layers are used to patch, compile, package, or modify (in any way)
  8756. any open source software included in your released images, you might be
  8757. required to release those layers under section 3 of GPLv2 or section 1
  8758. of GPLv3. One way of doing that is with a clean checkout of the version
  8759. of the Yocto Project and layers used during your build. Here is an
  8760. example:
  8761. .. code-block:: shell
  8762. # We built using the dunfell branch of the poky repo
  8763. $ git clone -b dunfell git://git.yoctoproject.org/poky
  8764. $ cd poky
  8765. # We built using the release_branch for our layers
  8766. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  8767. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  8768. # clean up the .git repos
  8769. $ find . -name ".git" -type d -exec rm -rf {} \;
  8770. One
  8771. thing a development organization might want to consider for end-user
  8772. convenience is to modify ``meta-poky/conf/bblayers.conf.sample`` to
  8773. ensure that when the end user utilizes the released build system to
  8774. build an image, the development organization's layers are included in
  8775. the ``bblayers.conf`` file automatically:
  8776. ::
  8777. # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
  8778. # changes incompatibly
  8779. POKY_BBLAYERS_CONF_VERSION = "2"
  8780. BBPATH = "${TOPDIR}"
  8781. BBFILES ?= ""
  8782. BBLAYERS ?= " \
  8783. ##OEROOT##/meta \
  8784. ##OEROOT##/meta-poky \
  8785. ##OEROOT##/meta-yocto-bsp \
  8786. ##OEROOT##/meta-mylayer \
  8787. "
  8788. Creating and
  8789. providing an archive of the :term:`Metadata`
  8790. layers (recipes, configuration files, and so forth) enables you to meet
  8791. your requirements to include the scripts to control compilation as well
  8792. as any modifications to the original source.
  8793. Providing spdx files
  8794. ~~~~~~~~~~~~~~~~~~~~~~~~~
  8795. The spdx module has been integrated to a layer named meta-spdxscanner.
  8796. meta-spdxscanner provides several kinds of scanner. If you want to enable
  8797. this function, you have to follow the following steps:
  8798. 1. Add meta-spdxscanner layer into ``bblayers.conf``.
  8799. 2. Refer to the README in meta-spdxscanner to setup the environment (e.g,
  8800. setup a fossology server) needed for the scanner.
  8801. 3. Meta-spdxscanner provides several methods within the bbclass to create spdx files.
  8802. Please choose one that you want to use and enable the spdx task. You have to
  8803. add some config options in ``local.conf`` file in your :term:`Build
  8804. Directory`. The following is an example showing how to generate spdx files
  8805. during bitbake using the fossology-python.bbclass::
  8806. # Select fossology-python.bbclass.
  8807. INHERIT += "fossology-python"
  8808. # For fossology-python.bbclass, TOKEN is necessary, so, after setup a
  8809. # Fossology server, you have to create a token.
  8810. TOKEN = "eyJ0eXAiO..."
  8811. # The fossology server is necessary for fossology-python.bbclass.
  8812. FOSSOLOGY_SERVER = "http://xx.xx.xx.xx:8081/repo"
  8813. # If you want to upload the source code to a special folder:
  8814. FOLDER_NAME = "xxxx" //Optional
  8815. # If you don't want to put spdx files in tmp/deploy/spdx, you can enable:
  8816. SPDX_DEPLOY_DIR = "${DEPLOY_DIR}" //Optional
  8817. For more usage information refer to :yocto_git:`the meta-spdxscanner repository
  8818. </meta-spdxscanner/>`.
  8819. Copying Licenses that Do Not Exist
  8820. ----------------------------------
  8821. Some packages, such as the linux-firmware package, have many licenses
  8822. that are not in any way common. You can avoid adding a lot of these
  8823. types of common license files, which are only applicable to a specific
  8824. package, by using the
  8825. :term:`NO_GENERIC_LICENSE`
  8826. variable. Using this variable also avoids QA errors when you use a
  8827. non-common, non-CLOSED license in a recipe.
  8828. The following is an example that uses the ``LICENSE.Abilis.txt`` file as
  8829. the license from the fetched source:
  8830. ::
  8831. NO_GENERIC_LICENSE[Firmware-Abilis] = "LICENSE.Abilis.txt"
  8832. Using the Error Reporting Tool
  8833. ==============================
  8834. The error reporting tool allows you to submit errors encountered during
  8835. builds to a central database. Outside of the build environment, you can
  8836. use a web interface to browse errors, view statistics, and query for
  8837. errors. The tool works using a client-server system where the client
  8838. portion is integrated with the installed Yocto Project
  8839. :term:`Source Directory` (e.g. ``poky``).
  8840. The server receives the information collected and saves it in a
  8841. database.
  8842. A live instance of the error reporting server exists at
  8843. https://errors.yoctoproject.org. This server exists so that when
  8844. you want to get help with build failures, you can submit all of the
  8845. information on the failure easily and then point to the URL in your bug
  8846. report or send an email to the mailing list.
  8847. .. note::
  8848. If you send error reports to this server, the reports become publicly
  8849. visible.
  8850. Enabling and Using the Tool
  8851. ---------------------------
  8852. By default, the error reporting tool is disabled. You can enable it by
  8853. inheriting the
  8854. :ref:`report-error <ref-classes-report-error>`
  8855. class by adding the following statement to the end of your
  8856. ``local.conf`` file in your
  8857. :term:`Build Directory`.
  8858. ::
  8859. INHERIT += "report-error"
  8860. By default, the error reporting feature stores information in
  8861. ``${``\ :term:`LOG_DIR`\ ``}/error-report``.
  8862. However, you can specify a directory to use by adding the following to
  8863. your ``local.conf`` file:
  8864. ::
  8865. ERR_REPORT_DIR = "path"
  8866. Enabling error
  8867. reporting causes the build process to collect the errors and store them
  8868. in a file as previously described. When the build system encounters an
  8869. error, it includes a command as part of the console output. You can run
  8870. the command to send the error file to the server. For example, the
  8871. following command sends the errors to an upstream server:
  8872. ::
  8873. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  8874. In the previous example, the errors are sent to a public database
  8875. available at https://errors.yoctoproject.org, which is used by the
  8876. entire community. If you specify a particular server, you can send the
  8877. errors to a different database. Use the following command for more
  8878. information on available options:
  8879. ::
  8880. $ send-error-report --help
  8881. When sending the error file, you are prompted to review the data being
  8882. sent as well as to provide a name and optional email address. Once you
  8883. satisfy these prompts, the command returns a link from the server that
  8884. corresponds to your entry in the database. For example, here is a
  8885. typical link: https://errors.yoctoproject.org/Errors/Details/9522/
  8886. Following the link takes you to a web interface where you can browse,
  8887. query the errors, and view statistics.
  8888. Disabling the Tool
  8889. ------------------
  8890. To disable the error reporting feature, simply remove or comment out the
  8891. following statement from the end of your ``local.conf`` file in your
  8892. :term:`Build Directory`.
  8893. ::
  8894. INHERIT += "report-error"
  8895. Setting Up Your Own Error Reporting Server
  8896. ------------------------------------------
  8897. If you want to set up your own error reporting server, you can obtain
  8898. the code from the Git repository at :yocto_git:`/error-report-web/`.
  8899. Instructions on how to set it up are in the README document.
  8900. Using Wayland and Weston
  8901. ========================
  8902. `Wayland <https://en.wikipedia.org/wiki/Wayland_(display_server_protocol)>`__
  8903. is a computer display server protocol that provides a method for
  8904. compositing window managers to communicate directly with applications
  8905. and video hardware and expects them to communicate with input hardware
  8906. using other libraries. Using Wayland with supporting targets can result
  8907. in better control over graphics frame rendering than an application
  8908. might otherwise achieve.
  8909. The Yocto Project provides the Wayland protocol libraries and the
  8910. reference
  8911. `Weston <https://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston>`__
  8912. compositor as part of its release. You can find the integrated packages
  8913. in the ``meta`` layer of the :term:`Source Directory`.
  8914. Specifically, you
  8915. can find the recipes that build both Wayland and Weston at
  8916. ``meta/recipes-graphics/wayland``.
  8917. You can build both the Wayland and Weston packages for use only with
  8918. targets that accept the `Mesa 3D and Direct Rendering
  8919. Infrastructure <https://en.wikipedia.org/wiki/Mesa_(computer_graphics)>`__,
  8920. which is also known as Mesa DRI. This implies that you cannot build and
  8921. use the packages if your target uses, for example, the Intel Embedded
  8922. Media and Graphics Driver (Intel EMGD) that overrides Mesa DRI.
  8923. .. note::
  8924. Due to lack of EGL support, Weston 1.0.3 will not run directly on the
  8925. emulated QEMU hardware. However, this version of Weston will run
  8926. under X emulation without issues.
  8927. This section describes what you need to do to implement Wayland and use
  8928. the Weston compositor when building an image for a supporting target.
  8929. Enabling Wayland in an Image
  8930. ----------------------------
  8931. To enable Wayland, you need to enable it to be built and enable it to be
  8932. included (installed) in the image.
  8933. Building Wayland
  8934. ~~~~~~~~~~~~~~~~
  8935. To cause Mesa to build the ``wayland-egl`` platform and Weston to build
  8936. Wayland with Kernel Mode Setting
  8937. (`KMS <https://wiki.archlinux.org/index.php/Kernel_Mode_Setting>`__)
  8938. support, include the "wayland" flag in the
  8939. :term:`DISTRO_FEATURES`
  8940. statement in your ``local.conf`` file:
  8941. ::
  8942. DISTRO_FEATURES_append = " wayland"
  8943. .. note::
  8944. If X11 has been enabled elsewhere, Weston will build Wayland with X11
  8945. support
  8946. Installing Wayland and Weston
  8947. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8948. To install the Wayland feature into an image, you must include the
  8949. following
  8950. :term:`CORE_IMAGE_EXTRA_INSTALL`
  8951. statement in your ``local.conf`` file:
  8952. ::
  8953. CORE_IMAGE_EXTRA_INSTALL += "wayland weston"
  8954. Running Weston
  8955. --------------
  8956. To run Weston inside X11, enabling it as described earlier and building
  8957. a Sato image is sufficient. If you are running your image under Sato, a
  8958. Weston Launcher appears in the "Utility" category.
  8959. Alternatively, you can run Weston through the command-line interpretor
  8960. (CLI), which is better suited for development work. To run Weston under
  8961. the CLI, you need to do the following after your image is built:
  8962. 1. Run these commands to export ``XDG_RUNTIME_DIR``:
  8963. ::
  8964. mkdir -p /tmp/$USER-weston
  8965. chmod 0700 /tmp/$USER-weston
  8966. export XDG_RUNTIME_DIR=/tmp/$USER-weston
  8967. 2. Launch Weston in the shell:
  8968. ::
  8969. weston