common-tasks.rst 455 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582
  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/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 `OpenEmbedded Metadata
  34. Index <https://layers.openembedded.org/layerindex/layers/>`__ for a
  35. list of layers from the OpenEmbedded community that can be used in
  36. the Yocto Project. You could find a layer that is identical or close
  37. to what you need.
  38. 2. *Create a Directory:* Create the directory for your layer. When you
  39. create the layer, be sure to create the directory in an area not
  40. associated with the Yocto Project :term:`Source Directory`
  41. (e.g. the cloned ``poky`` repository).
  42. While not strictly required, prepend the name of the directory with
  43. the string "meta-". For example:
  44. ::
  45. meta-mylayer
  46. meta-GUI_xyz
  47. meta-mymachine
  48. With rare exceptions, a layer's name follows this form:
  49. ::
  50. meta-root_name
  51. Following this layer naming convention can save
  52. you trouble later when tools, components, or variables "assume" your
  53. layer name begins with "meta-". A notable example is in configuration
  54. files as shown in the following step where layer names without the
  55. "meta-" string are appended to several variables used in the
  56. configuration.
  57. 3. *Create a Layer Configuration File:* Inside your new layer folder,
  58. you need to create a ``conf/layer.conf`` file. It is easiest to take
  59. an existing layer configuration file and copy that to your layer's
  60. ``conf`` directory and then modify the file as needed.
  61. The ``meta-yocto-bsp/conf/layer.conf`` file in the Yocto Project
  62. :yocto_git:`Source Repositories </poky/tree/meta-yocto-bsp/conf>`
  63. demonstrates the required syntax. For your layer, you need to replace
  64. "yoctobsp" with a unique identifier for your layer (e.g. "machinexyz"
  65. for a layer named "meta-machinexyz"):
  66. ::
  67. # We have a conf and classes directory, add to BBPATH
  68. BBPATH .= ":${LAYERDIR}"
  69. # We have recipes-* directories, add to BBFILES
  70. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  71. ${LAYERDIR}/recipes-*/*/*.bbappend"
  72. BBFILE_COLLECTIONS += "yoctobsp"
  73. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  74. BBFILE_PRIORITY_yoctobsp = "5"
  75. LAYERVERSION_yoctobsp = "4"
  76. LAYERSERIES_COMPAT_yoctobsp = "dunfell"
  77. Following is an explanation of the layer configuration file:
  78. - :term:`BBPATH`: Adds the layer's
  79. root directory to BitBake's search path. Through the use of the
  80. ``BBPATH`` variable, BitBake locates class files (``.bbclass``),
  81. configuration files, and files that are included with ``include``
  82. and ``require`` statements. For these cases, BitBake uses the
  83. first file that matches the name found in ``BBPATH``. This is
  84. similar to the way the ``PATH`` variable is used for binaries. It
  85. is recommended, therefore, that you use unique class and
  86. configuration filenames in your custom layer.
  87. - :term:`BBFILES`: Defines the
  88. location for all recipes in the layer.
  89. - :term:`BBFILE_COLLECTIONS`:
  90. Establishes the current layer through a unique identifier that is
  91. used throughout the OpenEmbedded build system to refer to the
  92. layer. In this example, the identifier "yoctobsp" is the
  93. representation for the container layer named "meta-yocto-bsp".
  94. - :term:`BBFILE_PATTERN`:
  95. Expands immediately during parsing to provide the directory of the
  96. layer.
  97. - :term:`BBFILE_PRIORITY`:
  98. Establishes a priority to use for recipes in the layer when the
  99. OpenEmbedded build finds recipes of the same name in different
  100. layers.
  101. - :term:`LAYERVERSION`:
  102. Establishes a version number for the layer. You can use this
  103. version number to specify this exact version of the layer as a
  104. dependency when using the
  105. :term:`LAYERDEPENDS`
  106. variable.
  107. - :term:`LAYERDEPENDS`:
  108. Lists all layers on which this layer depends (if any).
  109. - :term:`LAYERSERIES_COMPAT`:
  110. Lists the :yocto_wiki:`Yocto Project </Releases>`
  111. releases for which the current version is compatible. This
  112. variable is a good way to indicate if your particular layer is
  113. current.
  114. 4. *Add Content:* Depending on the type of layer, add the content. If
  115. the layer adds support for a machine, add the machine configuration
  116. in a ``conf/machine/`` file within the layer. If the layer adds
  117. distro policy, add the distro configuration in a ``conf/distro/``
  118. file within the layer. If the layer introduces new recipes, put the
  119. recipes you need in ``recipes-*`` subdirectories within the layer.
  120. .. note::
  121. For an explanation of layer hierarchy that is compliant with the
  122. Yocto Project, see the ":ref:`bsp-guide/bsp:example filesystem layout`"
  123. section in the Yocto Project Board Support Package (BSP) Developer's Guide.
  124. 5. *Optionally Test for Compatibility:* If you want permission to use
  125. the Yocto Project Compatibility logo with your layer or application
  126. that uses your layer, perform the steps to apply for compatibility.
  127. See the "`Making Sure Your Layer is Compatible With Yocto
  128. Project <#making-sure-your-layer-is-compatible-with-yocto-project>`__"
  129. section for more information.
  130. Following Best Practices When Creating Layers
  131. ---------------------------------------------
  132. To create layers that are easier to maintain and that will not impact
  133. builds for other machines, you should consider the information in the
  134. following list:
  135. - *Avoid "Overlaying" Entire Recipes from Other Layers in Your
  136. Configuration:* In other words, do not copy an entire recipe into
  137. your layer and then modify it. Rather, use an append file
  138. (``.bbappend``) to override only those parts of the original recipe
  139. you need to modify.
  140. - *Avoid Duplicating Include Files:* Use append files (``.bbappend``)
  141. for each recipe that uses an include file. Or, if you are introducing
  142. a new recipe that requires the included file, use the path relative
  143. to the original layer directory to refer to the file. For example,
  144. use ``require recipes-core/``\ `package`\ ``/``\ `file`\ ``.inc`` instead
  145. of ``require`` `file`\ ``.inc``. If you're finding you have to overlay
  146. the include file, it could indicate a deficiency in the include file
  147. in the layer to which it originally belongs. If this is the case, you
  148. should try to address that deficiency instead of overlaying the
  149. include file. For example, you could address this by getting the
  150. maintainer of the include file to add a variable or variables to make
  151. it easy to override the parts needing to be overridden.
  152. - *Structure Your Layers:* Proper use of overrides within append files
  153. and placement of machine-specific files within your layer can ensure
  154. that a build is not using the wrong Metadata and negatively impacting
  155. a build for a different machine. Following are some examples:
  156. - *Modify Variables to Support a Different Machine:* Suppose you
  157. have a layer named ``meta-one`` that adds support for building
  158. machine "one". To do so, you use an append file named
  159. ``base-files.bbappend`` and create a dependency on "foo" by
  160. altering the :term:`DEPENDS`
  161. variable:
  162. ::
  163. DEPENDS = "foo"
  164. The dependency is created during any
  165. build that includes the layer ``meta-one``. However, you might not
  166. want this dependency for all machines. For example, suppose you
  167. are building for machine "two" but your ``bblayers.conf`` file has
  168. the ``meta-one`` layer included. During the build, the
  169. ``base-files`` for machine "two" will also have the dependency on
  170. ``foo``.
  171. To make sure your changes apply only when building machine "one",
  172. use a machine override with the ``DEPENDS`` statement:
  173. ::
  174. DEPENDS_one = "foo"
  175. You should follow the same strategy when using ``_append``
  176. and ``_prepend`` operations:
  177. ::
  178. DEPENDS_append_one = " foo"
  179. DEPENDS_prepend_one = "foo "
  180. As an actual example, here's a
  181. snippet from the generic kernel include file ``linux-yocto.inc``,
  182. wherein the kernel compile and link options are adjusted in the
  183. case of a subset of the supported architectures:
  184. ::
  185. DEPENDS_append_aarch64 = " libgcc"
  186. KERNEL_CC_append_aarch64 = " ${TOOLCHAIN_OPTIONS}"
  187. KERNEL_LD_append_aarch64 = " ${TOOLCHAIN_OPTIONS}"
  188. DEPENDS_append_nios2 = " libgcc"
  189. KERNEL_CC_append_nios2 = " ${TOOLCHAIN_OPTIONS}"
  190. KERNEL_LD_append_nios2 = " ${TOOLCHAIN_OPTIONS}"
  191. DEPENDS_append_arc = " libgcc"
  192. KERNEL_CC_append_arc = " ${TOOLCHAIN_OPTIONS}"
  193. KERNEL_LD_append_arc = " ${TOOLCHAIN_OPTIONS}"
  194. KERNEL_FEATURES_append_qemuall=" features/debug/printk.scc"
  195. .. note::
  196. Avoiding "+=" and "=+" and using machine-specific ``_append``
  197. and ``_prepend`` operations is recommended as well.
  198. - *Place Machine-Specific Files in Machine-Specific Locations:* When
  199. you have a base recipe, such as ``base-files.bb``, that contains a
  200. :term:`SRC_URI` statement to a
  201. file, you can use an append file to cause the build to use your
  202. own version of the file. For example, an append file in your layer
  203. at ``meta-one/recipes-core/base-files/base-files.bbappend`` could
  204. extend :term:`FILESPATH` using :term:`FILESEXTRAPATHS` as follows:
  205. ::
  206. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  207. The build for machine "one" will pick up your machine-specific file as
  208. long as you have the file in
  209. ``meta-one/recipes-core/base-files/base-files/``. However, if you
  210. are building for a different machine and the ``bblayers.conf``
  211. file includes the ``meta-one`` layer and the location of your
  212. machine-specific file is the first location where that file is
  213. found according to ``FILESPATH``, builds for all machines will
  214. also use that machine-specific file.
  215. You can make sure that a machine-specific file is used for a
  216. particular machine by putting the file in a subdirectory specific
  217. to the machine. For example, rather than placing the file in
  218. ``meta-one/recipes-core/base-files/base-files/`` as shown above,
  219. put it in ``meta-one/recipes-core/base-files/base-files/one/``.
  220. Not only does this make sure the file is used only when building
  221. for machine "one", but the build process locates the file more
  222. quickly.
  223. In summary, you need to place all files referenced from
  224. ``SRC_URI`` in a machine-specific subdirectory within the layer in
  225. order to restrict those files to machine-specific builds.
  226. - *Perform Steps to Apply for Yocto Project Compatibility:* If you want
  227. permission to use the Yocto Project Compatibility logo with your
  228. layer or application that uses your layer, perform the steps to apply
  229. for compatibility. See the "`Making Sure Your Layer is Compatible
  230. With Yocto
  231. Project <#making-sure-your-layer-is-compatible-with-yocto-project>`__"
  232. section for more information.
  233. - *Follow the Layer Naming Convention:* Store custom layers in a Git
  234. repository that use the ``meta-layer_name`` format.
  235. - *Group Your Layers Locally:* Clone your repository alongside other
  236. cloned ``meta`` directories from the :term:`Source Directory`.
  237. Making Sure Your Layer is Compatible With Yocto Project
  238. -------------------------------------------------------
  239. When you create a layer used with the Yocto Project, it is advantageous
  240. to make sure that the layer interacts well with existing Yocto Project
  241. layers (i.e. the layer is compatible with the Yocto Project). Ensuring
  242. compatibility makes the layer easy to be consumed by others in the Yocto
  243. Project community and could allow you permission to use the Yocto
  244. Project Compatible Logo.
  245. .. note::
  246. Only Yocto Project member organizations are permitted to use the
  247. Yocto Project Compatible Logo. The logo is not available for general
  248. use. For information on how to become a Yocto Project member
  249. organization, see the :yocto_home:`Yocto Project Website <>`.
  250. The Yocto Project Compatibility Program consists of a layer application
  251. process that requests permission to use the Yocto Project Compatibility
  252. Logo for your layer and application. The process consists of two parts:
  253. 1. Successfully passing a script (``yocto-check-layer``) that when run
  254. against your layer, tests it against constraints based on experiences
  255. of how layers have worked in the real world and where pitfalls have
  256. been found. Getting a "PASS" result from the script is required for
  257. successful compatibility registration.
  258. 2. Completion of an application acceptance form, which you can find at
  259. https://www.yoctoproject.org/webform/yocto-project-compatible-registration.
  260. To be granted permission to use the logo, you need to satisfy the
  261. following:
  262. - Be able to check the box indicating that you got a "PASS" when
  263. running the script against your layer.
  264. - Answer "Yes" to the questions on the form or have an acceptable
  265. explanation for any questions answered "No".
  266. - Be a Yocto Project Member Organization.
  267. The remainder of this section presents information on the registration
  268. form and on the ``yocto-check-layer`` script.
  269. Yocto Project Compatible Program Application
  270. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  271. Use the form to apply for your layer's approval. Upon successful
  272. application, you can use the Yocto Project Compatibility Logo with your
  273. layer and the application that uses your layer.
  274. To access the form, use this link:
  275. https://www.yoctoproject.org/webform/yocto-project-compatible-registration.
  276. Follow the instructions on the form to complete your application.
  277. The application consists of the following sections:
  278. - *Contact Information:* Provide your contact information as the fields
  279. require. Along with your information, provide the released versions
  280. of the Yocto Project for which your layer is compatible.
  281. - *Acceptance Criteria:* Provide "Yes" or "No" answers for each of the
  282. items in the checklist. Space exists at the bottom of the form for
  283. any explanations for items for which you answered "No".
  284. - *Recommendations:* Provide answers for the questions regarding Linux
  285. kernel use and build success.
  286. ``yocto-check-layer`` Script
  287. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  288. The ``yocto-check-layer`` script provides you a way to assess how
  289. compatible your layer is with the Yocto Project. You should run this
  290. script prior to using the form to apply for compatibility as described
  291. in the previous section. You need to achieve a "PASS" result in order to
  292. have your application form successfully processed.
  293. The script divides tests into three areas: COMMON, BSP, and DISTRO. For
  294. example, given a distribution layer (DISTRO), the layer must pass both
  295. the COMMON and DISTRO related tests. Furthermore, if your layer is a BSP
  296. layer, the layer must pass the COMMON and BSP set of tests.
  297. To execute the script, enter the following commands from your build
  298. directory:
  299. ::
  300. $ source oe-init-build-env
  301. $ yocto-check-layer your_layer_directory
  302. Be sure to provide the actual directory for your
  303. layer as part of the command.
  304. Entering the command causes the script to determine the type of layer
  305. and then to execute a set of specific tests against the layer. The
  306. following list overviews the test:
  307. - ``common.test_readme``: Tests if a ``README`` file exists in the
  308. layer and the file is not empty.
  309. - ``common.test_parse``: Tests to make sure that BitBake can parse the
  310. files without error (i.e. ``bitbake -p``).
  311. - ``common.test_show_environment``: Tests that the global or per-recipe
  312. environment is in order without errors (i.e. ``bitbake -e``).
  313. - ``common.test_world``: Verifies that ``bitbake world`` works.
  314. - ``common.test_signatures``: Tests to be sure that BSP and DISTRO
  315. layers do not come with recipes that change signatures.
  316. - ``common.test_layerseries_compat``: Verifies layer compatibility is
  317. set properly.
  318. - ``bsp.test_bsp_defines_machines``: Tests if a BSP layer has machine
  319. configurations.
  320. - ``bsp.test_bsp_no_set_machine``: Tests to ensure a BSP layer does not
  321. set the machine when the layer is added.
  322. - ``bsp.test_machine_world``: Verifies that ``bitbake world`` works
  323. regardless of which machine is selected.
  324. - ``bsp.test_machine_signatures``: Verifies that building for a
  325. particular machine affects only the signature of tasks specific to
  326. that machine.
  327. - ``distro.test_distro_defines_distros``: Tests if a DISTRO layer has
  328. distro configurations.
  329. - ``distro.test_distro_no_set_distros``: Tests to ensure a DISTRO layer
  330. does not set the distribution when the layer is added.
  331. Enabling Your Layer
  332. -------------------
  333. Before the OpenEmbedded build system can use your new layer, you need to
  334. enable it. To enable your layer, simply add your layer's path to the
  335. ``BBLAYERS`` variable in your ``conf/bblayers.conf`` file, which is
  336. found in the :term:`Build Directory`.
  337. The following example shows how to enable a layer named
  338. ``meta-mylayer``:
  339. ::
  340. # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
  341. # changes incompatibly
  342. POKY_BBLAYERS_CONF_VERSION = "2"
  343. BBPATH = "${TOPDIR}"
  344. BBFILES ?= ""
  345. BBLAYERS ?= " \
  346. /home/user/poky/meta \
  347. /home/user/poky/meta-poky \
  348. /home/user/poky/meta-yocto-bsp \
  349. /home/user/poky/meta-mylayer \
  350. "
  351. BitBake parses each ``conf/layer.conf`` file from the top down as
  352. specified in the ``BBLAYERS`` variable within the ``conf/bblayers.conf``
  353. file. During the processing of each ``conf/layer.conf`` file, BitBake
  354. adds the recipes, classes and configurations contained within the
  355. particular layer to the source directory.
  356. Using .bbappend Files in Your Layer
  357. -----------------------------------
  358. A recipe that appends Metadata to another recipe is called a BitBake
  359. append file. A BitBake append file uses the ``.bbappend`` file type
  360. suffix, while the corresponding recipe to which Metadata is being
  361. appended uses the ``.bb`` file type suffix.
  362. You can use a ``.bbappend`` file in your layer to make additions or
  363. changes to the content of another layer's recipe without having to copy
  364. the other layer's recipe into your layer. Your ``.bbappend`` file
  365. resides in your layer, while the main ``.bb`` recipe file to which you
  366. are appending Metadata resides in a different layer.
  367. Being able to append information to an existing recipe not only avoids
  368. duplication, but also automatically applies recipe changes from a
  369. different layer into your layer. If you were copying recipes, you would
  370. have to manually merge changes as they occur.
  371. When you create an append file, you must use the same root name as the
  372. corresponding recipe file. For example, the append file
  373. ``someapp_3.1.bbappend`` must apply to ``someapp_3.1.bb``. This
  374. means the original recipe and append file names are version
  375. number-specific. If the corresponding recipe is renamed to update to a
  376. newer version, you must also rename and possibly update the
  377. corresponding ``.bbappend`` as well. During the build process, BitBake
  378. displays an error on starting if it detects a ``.bbappend`` file that
  379. does not have a corresponding recipe with a matching name. See the
  380. :term:`BB_DANGLINGAPPENDS_WARNONLY`
  381. variable for information on how to handle this error.
  382. As an example, consider the main formfactor recipe and a corresponding
  383. formfactor append file both from the :term:`Source Directory`.
  384. Here is the main
  385. formfactor recipe, which is named ``formfactor_0.0.bb`` and located in
  386. the "meta" layer at ``meta/recipes-bsp/formfactor``:
  387. ::
  388. SUMMARY = "Device formfactor information"
  389. DESCRIPTION = "A formfactor configuration file provides information about the \
  390. target hardware for which the image is being built and information that the \
  391. build system cannot obtain from other sources such as the kernel."
  392. SECTION = "base"
  393. LICENSE = "MIT"
  394. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  395. PR = "r45"
  396. SRC_URI = "file://config file://machconfig"
  397. S = "${WORKDIR}"
  398. PACKAGE_ARCH = "${MACHINE_ARCH}"
  399. INHIBIT_DEFAULT_DEPS = "1"
  400. do_install() {
  401. # Install file only if it has contents
  402. install -d ${D}${sysconfdir}/formfactor/
  403. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  404. if [ -s "${S}/machconfig" ]; then
  405. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  406. fi
  407. }
  408. In the main recipe, note the :term:`SRC_URI`
  409. variable, which tells the OpenEmbedded build system where to find files
  410. during the build.
  411. Following is the append file, which is named ``formfactor_0.0.bbappend``
  412. and is from the Raspberry Pi BSP Layer named ``meta-raspberrypi``. The
  413. file is in the layer at ``recipes-bsp/formfactor``:
  414. ::
  415. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  416. By default, the build system uses the
  417. :term:`FILESPATH` variable to
  418. locate files. This append file extends the locations by setting the
  419. :term:`FILESEXTRAPATHS`
  420. variable. Setting this variable in the ``.bbappend`` file is the most
  421. reliable and recommended method for adding directories to the search
  422. path used by the build system to find files.
  423. The statement in this example extends the directories to include
  424. ``${``\ :term:`THISDIR`\ ``}/${``\ :term:`PN`\ ``}``,
  425. which resolves to a directory named ``formfactor`` in the same directory
  426. in which the append file resides (i.e.
  427. ``meta-raspberrypi/recipes-bsp/formfactor``. This implies that you must
  428. have the supporting directory structure set up that will contain any
  429. files or patches you will be including from the layer.
  430. Using the immediate expansion assignment operator ``:=`` is important
  431. because of the reference to ``THISDIR``. The trailing colon character is
  432. important as it ensures that items in the list remain colon-separated.
  433. .. note::
  434. BitBake automatically defines the ``THISDIR`` variable. You should
  435. never set this variable yourself. Using "_prepend" as part of the
  436. ``FILESEXTRAPATHS`` ensures your path will be searched prior to other
  437. paths in the final list.
  438. Also, not all append files add extra files. Many append files simply
  439. exist to add build options (e.g. ``systemd``). For these cases, your
  440. append file would not even use the ``FILESEXTRAPATHS`` statement.
  441. Prioritizing Your Layer
  442. -----------------------
  443. Each layer is assigned a priority value. Priority values control which
  444. layer takes precedence if there are recipe files with the same name in
  445. multiple layers. For these cases, the recipe file from the layer with a
  446. higher priority number takes precedence. Priority values also affect the
  447. order in which multiple ``.bbappend`` files for the same recipe are
  448. applied. You can either specify the priority manually, or allow the
  449. build system to calculate it based on the layer's dependencies.
  450. To specify the layer's priority manually, use the
  451. :term:`BBFILE_PRIORITY`
  452. variable and append the layer's root name:
  453. ::
  454. BBFILE_PRIORITY_mylayer = "1"
  455. .. note::
  456. It is possible for a recipe with a lower version number
  457. :term:`PV` in a layer that has a higher
  458. priority to take precedence.
  459. Also, the layer priority does not currently affect the precedence
  460. order of ``.conf`` or ``.bbclass`` files. Future versions of BitBake
  461. might address this.
  462. Managing Layers
  463. ---------------
  464. You can use the BitBake layer management tool ``bitbake-layers`` to
  465. provide a view into the structure of recipes across a multi-layer
  466. project. Being able to generate output that reports on configured layers
  467. with their paths and priorities and on ``.bbappend`` files and their
  468. applicable recipes can help to reveal potential problems.
  469. For help on the BitBake layer management tool, use the following
  470. command:
  471. ::
  472. $ bitbake-layers --help
  473. NOTE: Starting bitbake server...
  474. usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ...
  475. BitBake layers utility
  476. optional arguments:
  477. -d, --debug Enable debug output
  478. -q, --quiet Print only errors
  479. -F, --force Force add without recipe parse verification
  480. --color COLOR Colorize output (where COLOR is auto, always, never)
  481. -h, --help show this help message and exit
  482. subcommands:
  483. <subcommand>
  484. layerindex-fetch Fetches a layer from a layer index along with its
  485. dependent layers, and adds them to conf/bblayers.conf.
  486. layerindex-show-depends
  487. Find layer dependencies from layer index.
  488. add-layer Add one or more layers to bblayers.conf.
  489. remove-layer Remove one or more layers from bblayers.conf.
  490. flatten flatten layer configuration into a separate output
  491. directory.
  492. show-layers show current configured layers.
  493. show-overlayed list overlayed recipes (where the same recipe exists
  494. in another layer)
  495. show-recipes list available recipes, showing the layer they are
  496. provided by
  497. show-appends list bbappend files and recipe files they apply to
  498. show-cross-depends Show dependencies between recipes that cross layer
  499. boundaries.
  500. create-layer Create a basic layer
  501. Use bitbake-layers <subcommand> --help to get help on a specific command
  502. The following list describes the available commands:
  503. - ``help:`` Displays general help or help on a specified command.
  504. - ``show-layers:`` Shows the current configured layers.
  505. - ``show-overlayed:`` Lists overlayed recipes. A recipe is overlayed
  506. when a recipe with the same name exists in another layer that has a
  507. higher layer priority.
  508. - ``show-recipes:`` Lists available recipes and the layers that
  509. provide them.
  510. - ``show-appends:`` Lists ``.bbappend`` files and the recipe files to
  511. which they apply.
  512. - ``show-cross-depends:`` Lists dependency relationships between
  513. recipes that cross layer boundaries.
  514. - ``add-layer:`` Adds a layer to ``bblayers.conf``.
  515. - ``remove-layer:`` Removes a layer from ``bblayers.conf``
  516. - ``flatten:`` Flattens the layer configuration into a separate
  517. output directory. Flattening your layer configuration builds a
  518. "flattened" directory that contains the contents of all layers, with
  519. any overlayed recipes removed and any ``.bbappend`` files appended to
  520. the corresponding recipes. You might have to perform some manual
  521. cleanup of the flattened layer as follows:
  522. - Non-recipe files (such as patches) are overwritten. The flatten
  523. command shows a warning for these files.
  524. - Anything beyond the normal layer setup has been added to the
  525. ``layer.conf`` file. Only the lowest priority layer's
  526. ``layer.conf`` is used.
  527. - Overridden and appended items from ``.bbappend`` files need to be
  528. cleaned up. The contents of each ``.bbappend`` end up in the
  529. flattened recipe. However, if there are appended or changed
  530. variable values, you need to tidy these up yourself. Consider the
  531. following example. Here, the ``bitbake-layers`` command adds the
  532. line ``#### bbappended ...`` so that you know where the following
  533. lines originate:
  534. ::
  535. ...
  536. DESCRIPTION = "A useful utility"
  537. ...
  538. EXTRA_OECONF = "--enable-something"
  539. ...
  540. #### bbappended from meta-anotherlayer ####
  541. DESCRIPTION = "Customized utility"
  542. EXTRA_OECONF += "--enable-somethingelse"
  543. Ideally, you would tidy up these utilities as follows:
  544. ::
  545. ...
  546. DESCRIPTION = "Customized utility"
  547. ...
  548. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  549. ...
  550. - ``layerindex-fetch``: Fetches a layer from a layer index, along
  551. with its dependent layers, and adds the layers to the
  552. ``conf/bblayers.conf`` file.
  553. - ``layerindex-show-depends``: Finds layer dependencies from the
  554. layer index.
  555. - ``create-layer``: Creates a basic layer.
  556. Creating a General Layer Using the ``bitbake-layers`` Script
  557. ------------------------------------------------------------
  558. The ``bitbake-layers`` script with the ``create-layer`` subcommand
  559. simplifies creating a new general layer.
  560. .. note::
  561. - For information on BSP layers, see the ":ref:`bsp-guide/bsp:bsp layers`"
  562. section in the Yocto
  563. Project Board Specific (BSP) Developer's Guide.
  564. - In order to use a layer with the OpenEmbedded build system, you
  565. need to add the layer to your ``bblayers.conf`` configuration
  566. file. See the ":ref:`dev-manual/common-tasks:adding a layer using the \`\`bitbake-layers\`\` script`"
  567. section for more information.
  568. The default mode of the script's operation with this subcommand is to
  569. create a layer with the following:
  570. - A layer priority of 6.
  571. - A ``conf`` subdirectory that contains a ``layer.conf`` file.
  572. - A ``recipes-example`` subdirectory that contains a further
  573. subdirectory named ``example``, which contains an ``example.bb``
  574. recipe file.
  575. - A ``COPYING.MIT``, which is the license statement for the layer. The
  576. script assumes you want to use the MIT license, which is typical for
  577. most layers, for the contents of the layer itself.
  578. - A ``README`` file, which is a file describing the contents of your
  579. new layer.
  580. In its simplest form, you can use the following command form to create a
  581. layer. The command creates a layer whose name corresponds to
  582. "your_layer_name" in the current directory:
  583. ::
  584. $ bitbake-layers create-layer your_layer_name
  585. As an example, the following command creates a layer named ``meta-scottrif``
  586. in your home directory:
  587. ::
  588. $ cd /usr/home
  589. $ bitbake-layers create-layer meta-scottrif
  590. NOTE: Starting bitbake server...
  591. Add your new layer with 'bitbake-layers add-layer meta-scottrif'
  592. If you want to set the priority of the layer to other than the default
  593. value of "6", you can either use the ``--priority`` option or you
  594. can edit the
  595. :term:`BBFILE_PRIORITY` value
  596. in the ``conf/layer.conf`` after the script creates it. Furthermore, if
  597. you want to give the example recipe file some name other than the
  598. default, you can use the ``--example-recipe-name`` option.
  599. The easiest way to see how the ``bitbake-layers create-layer`` command
  600. works is to experiment with the script. You can also read the usage
  601. information by entering the following:
  602. ::
  603. $ bitbake-layers create-layer --help
  604. NOTE: Starting bitbake server...
  605. usage: bitbake-layers create-layer [-h] [--priority PRIORITY]
  606. [--example-recipe-name EXAMPLERECIPE]
  607. layerdir
  608. Create a basic layer
  609. positional arguments:
  610. layerdir Layer directory to create
  611. optional arguments:
  612. -h, --help show this help message and exit
  613. --priority PRIORITY, -p PRIORITY
  614. Layer directory to create
  615. --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE
  616. Filename of the example recipe
  617. Adding a Layer Using the ``bitbake-layers`` Script
  618. --------------------------------------------------
  619. Once you create your general layer, you must add it to your
  620. ``bblayers.conf`` file. Adding the layer to this configuration file
  621. makes the OpenEmbedded build system aware of your layer so that it can
  622. search it for metadata.
  623. Add your layer by using the ``bitbake-layers add-layer`` command:
  624. ::
  625. $ bitbake-layers add-layer your_layer_name
  626. Here is an example that adds a
  627. layer named ``meta-scottrif`` to the configuration file. Following the
  628. command that adds the layer is another ``bitbake-layers`` command that
  629. shows the layers that are in your ``bblayers.conf`` file:
  630. ::
  631. $ bitbake-layers add-layer meta-scottrif
  632. NOTE: Starting bitbake server...
  633. Parsing recipes: 100% |##########################################################| Time: 0:00:49
  634. Parsing of 1441 .bb files complete (0 cached, 1441 parsed). 2055 targets, 56 skipped, 0 masked, 0 errors.
  635. $ bitbake-layers show-layers
  636. NOTE: Starting bitbake server...
  637. layer path priority
  638. ==========================================================================
  639. meta /home/scottrif/poky/meta 5
  640. meta-poky /home/scottrif/poky/meta-poky 5
  641. meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5
  642. workspace /home/scottrif/poky/build/workspace 99
  643. meta-scottrif /home/scottrif/poky/build/meta-scottrif 6
  644. Adding the layer to this file
  645. enables the build system to locate the layer during the build.
  646. .. note::
  647. During a build, the OpenEmbedded build system looks in the layers
  648. from the top of the list down to the bottom in that order.
  649. Customizing Images
  650. ==================
  651. You can customize images to satisfy particular requirements. This
  652. section describes several methods and provides guidelines for each.
  653. Customizing Images Using ``local.conf``
  654. ---------------------------------------
  655. Probably the easiest way to customize an image is to add a package by
  656. way of the ``local.conf`` configuration file. Because it is limited to
  657. local use, this method generally only allows you to add packages and is
  658. not as flexible as creating your own customized image. When you add
  659. packages using local variables this way, you need to realize that these
  660. variable changes are in effect for every build and consequently affect
  661. all images, which might not be what you require.
  662. To add a package to your image using the local configuration file, use
  663. the ``IMAGE_INSTALL`` variable with the ``_append`` operator:
  664. ::
  665. IMAGE_INSTALL_append = " strace"
  666. Use of the syntax is important -
  667. specifically, the space between the quote and the package name, which is
  668. ``strace`` in this example. This space is required since the ``_append``
  669. operator does not add the space.
  670. Furthermore, you must use ``_append`` instead of the ``+=`` operator if
  671. you want to avoid ordering issues. The reason for this is because doing
  672. so unconditionally appends to the variable and avoids ordering problems
  673. due to the variable being set in image recipes and ``.bbclass`` files
  674. with operators like ``?=``. Using ``_append`` ensures the operation
  675. takes effect.
  676. As shown in its simplest use, ``IMAGE_INSTALL_append`` affects all
  677. images. It is possible to extend the syntax so that the variable applies
  678. to a specific image only. Here is an example:
  679. ::
  680. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  681. This example adds ``strace`` to the ``core-image-minimal`` image only.
  682. You can add packages using a similar approach through the
  683. ``CORE_IMAGE_EXTRA_INSTALL`` variable. If you use this variable, only
  684. ``core-image-*`` images are affected.
  685. Customizing Images Using Custom ``IMAGE_FEATURES`` and ``EXTRA_IMAGE_FEATURES``
  686. -------------------------------------------------------------------------------
  687. Another method for customizing your image is to enable or disable
  688. high-level image features by using the
  689. :term:`IMAGE_FEATURES` and
  690. :term:`EXTRA_IMAGE_FEATURES`
  691. variables. Although the functions for both variables are nearly
  692. equivalent, best practices dictate using ``IMAGE_FEATURES`` from within
  693. a recipe and using ``EXTRA_IMAGE_FEATURES`` from within your
  694. ``local.conf`` file, which is found in the
  695. :term:`Build Directory`.
  696. To understand how these features work, the best reference is
  697. ``meta/classes/core-image.bbclass``. This class lists out the available
  698. ``IMAGE_FEATURES`` of which most map to package groups while some, such
  699. as ``debug-tweaks`` and ``read-only-rootfs``, resolve as general
  700. configuration settings.
  701. In summary, the file looks at the contents of the ``IMAGE_FEATURES``
  702. variable and then maps or configures the feature accordingly. Based on
  703. this information, the build system automatically adds the appropriate
  704. packages or configurations to the
  705. :term:`IMAGE_INSTALL` variable.
  706. Effectively, you are enabling extra features by extending the class or
  707. creating a custom class for use with specialized image ``.bb`` files.
  708. Use the ``EXTRA_IMAGE_FEATURES`` variable from within your local
  709. configuration file. Using a separate area from which to enable features
  710. with this variable helps you avoid overwriting the features in the image
  711. recipe that are enabled with ``IMAGE_FEATURES``. The value of
  712. ``EXTRA_IMAGE_FEATURES`` is added to ``IMAGE_FEATURES`` within
  713. ``meta/conf/bitbake.conf``.
  714. To illustrate how you can use these variables to modify your image,
  715. consider an example that selects the SSH server. The Yocto Project ships
  716. with two SSH servers you can use with your images: Dropbear and OpenSSH.
  717. Dropbear is a minimal SSH server appropriate for resource-constrained
  718. environments, while OpenSSH is a well-known standard SSH server
  719. implementation. By default, the ``core-image-sato`` image is configured
  720. to use Dropbear. The ``core-image-full-cmdline`` and ``core-image-lsb``
  721. images both include OpenSSH. The ``core-image-minimal`` image does not
  722. contain an SSH server.
  723. You can customize your image and change these defaults. Edit the
  724. ``IMAGE_FEATURES`` variable in your recipe or use the
  725. ``EXTRA_IMAGE_FEATURES`` in your ``local.conf`` file so that it
  726. configures the image you are working with to include
  727. ``ssh-server-dropbear`` or ``ssh-server-openssh``.
  728. .. note::
  729. See the ":ref:`ref-manual/ref-features:image features`" section in the Yocto
  730. Project Reference Manual for a complete list of image features that ship
  731. with the Yocto Project.
  732. Customizing Images Using Custom .bb Files
  733. -----------------------------------------
  734. You can also customize an image by creating a custom recipe that defines
  735. additional software as part of the image. The following example shows
  736. the form for the two lines you need:
  737. ::
  738. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  739. inherit core-image
  740. Defining the software using a custom recipe gives you total control over
  741. the contents of the image. It is important to use the correct names of
  742. packages in the ``IMAGE_INSTALL`` variable. You must use the
  743. OpenEmbedded notation and not the Debian notation for the names (e.g.
  744. ``glibc-dev`` instead of ``libc6-dev``).
  745. The other method for creating a custom image is to base it on an
  746. existing image. For example, if you want to create an image based on
  747. ``core-image-sato`` but add the additional package ``strace`` to the
  748. image, copy the ``meta/recipes-sato/images/core-image-sato.bb`` to a new
  749. ``.bb`` and add the following line to the end of the copy:
  750. ::
  751. IMAGE_INSTALL += "strace"
  752. Customizing Images Using Custom Package Groups
  753. ----------------------------------------------
  754. For complex custom images, the best approach for customizing an image is
  755. to create a custom package group recipe that is used to build the image
  756. or images. A good example of a package group recipe is
  757. ``meta/recipes-core/packagegroups/packagegroup-base.bb``.
  758. If you examine that recipe, you see that the ``PACKAGES`` variable lists
  759. the package group packages to produce. The ``inherit packagegroup``
  760. statement sets appropriate default values and automatically adds
  761. ``-dev``, ``-dbg``, and ``-ptest`` complementary packages for each
  762. package specified in the ``PACKAGES`` statement.
  763. .. note::
  764. The ``inherit packagegroup`` line should be located near the top of the
  765. recipe, certainly before the ``PACKAGES`` statement.
  766. For each package you specify in ``PACKAGES``, you can use ``RDEPENDS``
  767. and ``RRECOMMENDS`` entries to provide a list of packages the parent
  768. task package should contain. You can see examples of these further down
  769. in the ``packagegroup-base.bb`` recipe.
  770. Here is a short, fabricated example showing the same basic pieces for a
  771. hypothetical packagegroup defined in ``packagegroup-custom.bb``, where
  772. the variable ``PN`` is the standard way to abbreviate the reference to
  773. the full packagegroup name ``packagegroup-custom``:
  774. ::
  775. DESCRIPTION = "My Custom Package Groups"
  776. inherit packagegroup
  777. PACKAGES = "\
  778. ${PN}-apps \
  779. ${PN}-tools \
  780. "
  781. RDEPENDS_${PN}-apps = "\
  782. dropbear \
  783. portmap \
  784. psplash"
  785. RDEPENDS_${PN}-tools = "\
  786. oprofile \
  787. oprofileui-server \
  788. lttng-tools"
  789. RRECOMMENDS_${PN}-tools = "\
  790. kernel-module-oprofile"
  791. In the previous example, two package group packages are created with
  792. their dependencies and their recommended package dependencies listed:
  793. ``packagegroup-custom-apps``, and ``packagegroup-custom-tools``. To
  794. build an image using these package group packages, you need to add
  795. ``packagegroup-custom-apps`` and/or ``packagegroup-custom-tools`` to
  796. ``IMAGE_INSTALL``. For other forms of image dependencies see the other
  797. areas of this section.
  798. Customizing an Image Hostname
  799. -----------------------------
  800. By default, the configured hostname (i.e. ``/etc/hostname``) in an image
  801. is the same as the machine name. For example, if
  802. :term:`MACHINE` equals "qemux86", the
  803. configured hostname written to ``/etc/hostname`` is "qemux86".
  804. You can customize this name by altering the value of the "hostname"
  805. variable in the ``base-files`` recipe using either an append file or a
  806. configuration file. Use the following in an append file:
  807. ::
  808. hostname = "myhostname"
  809. Use the following in a configuration file:
  810. ::
  811. hostname_pn-base-files = "myhostname"
  812. Changing the default value of the variable "hostname" can be useful in
  813. certain situations. For example, suppose you need to do extensive
  814. testing on an image and you would like to easily identify the image
  815. under test from existing images with typical default hostnames. In this
  816. situation, you could change the default hostname to "testme", which
  817. results in all the images using the name "testme". Once testing is
  818. complete and you do not need to rebuild the image for test any longer,
  819. you can easily reset the default hostname.
  820. Another point of interest is that if you unset the variable, the image
  821. will have no default hostname in the filesystem. Here is an example that
  822. unsets the variable in a configuration file:
  823. ::
  824. hostname_pn-base-files = ""
  825. Having no default hostname in the filesystem is suitable for
  826. environments that use dynamic hostnames such as virtual machines.
  827. Writing a New Recipe
  828. ====================
  829. Recipes (``.bb`` files) are fundamental components in the Yocto Project
  830. environment. Each software component built by the OpenEmbedded build
  831. system requires a recipe to define the component. This section describes
  832. how to create, write, and test a new recipe.
  833. .. note::
  834. For information on variables that are useful for recipes and for
  835. information about recipe naming issues, see the
  836. ":ref:`ref-manual/ref-varlocality:recipes`" section of the Yocto Project
  837. Reference Manual.
  838. Overview
  839. --------
  840. The following figure shows the basic process for creating a new recipe.
  841. The remainder of the section provides details for the steps.
  842. .. image:: figures/recipe-workflow.png
  843. :align: center
  844. Locate or Automatically Create a Base Recipe
  845. --------------------------------------------
  846. You can always write a recipe from scratch. However, three choices exist
  847. that can help you quickly get a start on a new recipe:
  848. - ``devtool add``: A command that assists in creating a recipe and an
  849. environment conducive to development.
  850. - ``recipetool create``: A command provided by the Yocto Project that
  851. automates creation of a base recipe based on the source files.
  852. - *Existing Recipes:* Location and modification of an existing recipe
  853. that is similar in function to the recipe you need.
  854. .. note::
  855. For information on recipe syntax, see the
  856. ":ref:`dev-manual/common-tasks:recipe syntax`" section.
  857. Creating the Base Recipe Using ``devtool add``
  858. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  859. The ``devtool add`` command uses the same logic for auto-creating the
  860. recipe as ``recipetool create``, which is listed below. Additionally,
  861. however, ``devtool add`` sets up an environment that makes it easy for
  862. you to patch the source and to make changes to the recipe as is often
  863. necessary when adding a recipe to build a new piece of software to be
  864. included in a build.
  865. You can find a complete description of the ``devtool add`` command in
  866. the ":ref:`sdk-manual/sdk-extensible:a closer look at \`\`devtool add\`\``" section
  867. in the Yocto Project Application Development and the Extensible Software
  868. Development Kit (eSDK) manual.
  869. Creating the Base Recipe Using ``recipetool create``
  870. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  871. ``recipetool create`` automates creation of a base recipe given a set of
  872. source code files. As long as you can extract or point to the source
  873. files, the tool will construct a recipe and automatically configure all
  874. pre-build information into the recipe. For example, suppose you have an
  875. application that builds using Autotools. Creating the base recipe using
  876. ``recipetool`` results in a recipe that has the pre-build dependencies,
  877. license requirements, and checksums configured.
  878. To run the tool, you just need to be in your
  879. :term:`Build Directory` and have sourced the
  880. build environment setup script (i.e.
  881. :ref:`structure-core-script`).
  882. To get help on the tool, use the following command:
  883. ::
  884. $ recipetool -h
  885. NOTE: Starting bitbake server...
  886. usage: recipetool [-d] [-q] [--color COLOR] [-h] <subcommand> ...
  887. OpenEmbedded recipe tool
  888. options:
  889. -d, --debug Enable debug output
  890. -q, --quiet Print only errors
  891. --color COLOR Colorize output (where COLOR is auto, always, never)
  892. -h, --help show this help message and exit
  893. subcommands:
  894. create Create a new recipe
  895. newappend Create a bbappend for the specified target in the specified
  896. layer
  897. setvar Set a variable within a recipe
  898. appendfile Create/update a bbappend to replace a target file
  899. appendsrcfiles Create/update a bbappend to add or replace source files
  900. appendsrcfile Create/update a bbappend to add or replace a source file
  901. Use recipetool <subcommand> --help to get help on a specific command
  902. Running ``recipetool create -o OUTFILE`` creates the base recipe and
  903. locates it properly in the layer that contains your source files.
  904. Following are some syntax examples:
  905. - Use this syntax to generate a recipe based on source. Once generated,
  906. the recipe resides in the existing source code layer:
  907. ::
  908. recipetool create -o OUTFILE source
  909. - Use this syntax to generate a recipe using code that
  910. you extract from source. The extracted code is placed in its own layer
  911. defined by ``EXTERNALSRC``.
  912. ::
  913. recipetool create -o OUTFILE -x EXTERNALSRC source
  914. - Use this syntax to generate a recipe based on source. The options
  915. direct ``recipetool`` to generate debugging information. Once generated,
  916. the recipe resides in the existing source code layer:
  917. ::
  918. recipetool create -d -o OUTFILE source
  919. Locating and Using a Similar Recipe
  920. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  921. Before writing a recipe from scratch, it is often useful to discover
  922. whether someone else has already written one that meets (or comes close
  923. to meeting) your needs. The Yocto Project and OpenEmbedded communities
  924. maintain many recipes that might be candidates for what you are doing.
  925. You can find a good central index of these recipes in the `OpenEmbedded
  926. Layer Index <https://layers.openembedded.org>`__.
  927. Working from an existing recipe or a skeleton recipe is the best way to
  928. get started. Here are some points on both methods:
  929. - *Locate and modify a recipe that is close to what you want to do:*
  930. This method works when you are familiar with the current recipe
  931. space. The method does not work so well for those new to the Yocto
  932. Project or writing recipes.
  933. Some risks associated with this method are using a recipe that has
  934. areas totally unrelated to what you are trying to accomplish with
  935. your recipe, not recognizing areas of the recipe that you might have
  936. to add from scratch, and so forth. All these risks stem from
  937. unfamiliarity with the existing recipe space.
  938. - *Use and modify the following skeleton recipe:* If for some reason
  939. you do not want to use ``recipetool`` and you cannot find an existing
  940. recipe that is close to meeting your needs, you can use the following
  941. structure to provide the fundamental areas of a new recipe.
  942. ::
  943. DESCRIPTION = ""
  944. HOMEPAGE = ""
  945. LICENSE = ""
  946. SECTION = ""
  947. DEPENDS = ""
  948. LIC_FILES_CHKSUM = ""
  949. SRC_URI = ""
  950. Storing and Naming the Recipe
  951. -----------------------------
  952. Once you have your base recipe, you should put it in your own layer and
  953. name it appropriately. Locating it correctly ensures that the
  954. OpenEmbedded build system can find it when you use BitBake to process
  955. the recipe.
  956. - *Storing Your Recipe:* The OpenEmbedded build system locates your
  957. recipe through the layer's ``conf/layer.conf`` file and the
  958. :term:`BBFILES` variable. This
  959. variable sets up a path from which the build system can locate
  960. recipes. Here is the typical use:
  961. ::
  962. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  963. ${LAYERDIR}/recipes-*/*/*.bbappend"
  964. Consequently, you need to be sure you locate your new recipe inside
  965. your layer such that it can be found.
  966. You can find more information on how layers are structured in the
  967. "`Understanding and Creating
  968. Layers <#understanding-and-creating-layers>`__" section.
  969. - *Naming Your Recipe:* When you name your recipe, you need to follow
  970. this naming convention:
  971. ::
  972. basename_version.bb
  973. Use lower-cased characters and do not include the reserved suffixes
  974. ``-native``, ``-cross``, ``-initial``, or ``-dev`` casually (i.e. do not use
  975. them as part of your recipe name unless the string applies). Here are some
  976. examples:
  977. .. code-block:: none
  978. cups_1.7.0.bb
  979. gawk_4.0.2.bb
  980. irssi_0.8.16-rc1.bb
  981. Running a Build on the Recipe
  982. -----------------------------
  983. Creating a new recipe is usually an iterative process that requires
  984. using BitBake to process the recipe multiple times in order to
  985. progressively discover and add information to the recipe file.
  986. Assuming you have sourced the build environment setup script (i.e.
  987. :ref:`structure-core-script`) and you are in
  988. the :term:`Build Directory`, use
  989. BitBake to process your recipe. All you need to provide is the
  990. ``basename`` of the recipe as described in the previous section:
  991. ::
  992. $ bitbake basename
  993. During the build, the OpenEmbedded build system creates a temporary work
  994. directory for each recipe
  995. (``${``\ :term:`WORKDIR`\ ``}``)
  996. where it keeps extracted source files, log files, intermediate
  997. compilation and packaging files, and so forth.
  998. The path to the per-recipe temporary work directory depends on the
  999. context in which it is being built. The quickest way to find this path
  1000. is to have BitBake return it by running the following:
  1001. ::
  1002. $ bitbake -e basename | grep ^WORKDIR=
  1003. As an example, assume a Source Directory
  1004. top-level folder named ``poky``, a default Build Directory at
  1005. ``poky/build``, and a ``qemux86-poky-linux`` machine target system.
  1006. Furthermore, suppose your recipe is named ``foo_1.3.0.bb``. In this
  1007. case, the work directory the build system uses to build the package
  1008. would be as follows:
  1009. ::
  1010. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1011. Inside this directory you can find sub-directories such as ``image``,
  1012. ``packages-split``, and ``temp``. After the build, you can examine these
  1013. to determine how well the build went.
  1014. .. note::
  1015. You can find log files for each task in the recipe's ``temp``
  1016. directory (e.g. ``poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp``).
  1017. Log files are named ``log.taskname`` (e.g. ``log.do_configure``,
  1018. ``log.do_fetch``, and ``log.do_compile``).
  1019. You can find more information about the build process in
  1020. ":doc:`/overview-manual/overview-manual-development-environment`"
  1021. chapter of the Yocto Project Overview and Concepts Manual.
  1022. Fetching Code
  1023. -------------
  1024. The first thing your recipe must do is specify how to fetch the source
  1025. files. Fetching is controlled mainly through the
  1026. :term:`SRC_URI` variable. Your recipe
  1027. must have a ``SRC_URI`` variable that points to where the source is
  1028. located. For a graphical representation of source locations, see the
  1029. ":ref:`overview-manual/overview-manual-concepts:sources`" section in
  1030. the Yocto Project Overview and Concepts Manual.
  1031. The :ref:`ref-tasks-fetch` task uses
  1032. the prefix of each entry in the ``SRC_URI`` variable value to determine
  1033. which :ref:`fetcher <bitbake:bitbake-user-manual/bitbake-user-manual-fetching:fetchers>` to use to get your
  1034. source files. It is the ``SRC_URI`` variable that triggers the fetcher.
  1035. The :ref:`ref-tasks-patch` task uses
  1036. the variable after source is fetched to apply patches. The OpenEmbedded
  1037. build system uses
  1038. :term:`FILESOVERRIDES` for
  1039. scanning directory locations for local files in ``SRC_URI``.
  1040. The ``SRC_URI`` variable in your recipe must define each unique location
  1041. for your source files. It is good practice to not hard-code version
  1042. numbers in a URL used in ``SRC_URI``. Rather than hard-code these
  1043. values, use ``${``\ :term:`PV`\ ``}``,
  1044. which causes the fetch process to use the version specified in the
  1045. recipe filename. Specifying the version in this manner means that
  1046. upgrading the recipe to a future version is as simple as renaming the
  1047. recipe to match the new version.
  1048. Here is a simple example from the
  1049. ``meta/recipes-devtools/strace/strace_5.5.bb`` recipe where the source
  1050. comes from a single tarball. Notice the use of the
  1051. :term:`PV` variable:
  1052. ::
  1053. SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
  1054. Files mentioned in ``SRC_URI`` whose names end in a typical archive
  1055. extension (e.g. ``.tar``, ``.tar.gz``, ``.tar.bz2``, ``.zip``, and so
  1056. forth), are automatically extracted during the
  1057. :ref:`ref-tasks-unpack` task. For
  1058. another example that specifies these types of files, see the
  1059. "`Autotooled Package <#new-recipe-autotooled-package>`__" section.
  1060. Another way of specifying source is from an SCM. For Git repositories,
  1061. you must specify :term:`SRCREV` and
  1062. you should specify :term:`PV` to include
  1063. the revision with :term:`SRCPV`. Here
  1064. is an example from the recipe
  1065. ``meta/recipes-kernel/blktrace/blktrace_git.bb``:
  1066. ::
  1067. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1068. PR = "r6"
  1069. PV = "1.0.5+git${SRCPV}"
  1070. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1071. file://ldflags.patch"
  1072. If your ``SRC_URI`` statement includes URLs pointing to individual files
  1073. fetched from a remote server other than a version control system,
  1074. BitBake attempts to verify the files against checksums defined in your
  1075. recipe to ensure they have not been tampered with or otherwise modified
  1076. since the recipe was written. Two checksums are used:
  1077. ``SRC_URI[md5sum]`` and ``SRC_URI[sha256sum]``.
  1078. If your ``SRC_URI`` variable points to more than a single URL (excluding
  1079. SCM URLs), you need to provide the ``md5`` and ``sha256`` checksums for
  1080. each URL. For these cases, you provide a name for each URL as part of
  1081. the ``SRC_URI`` and then reference that name in the subsequent checksum
  1082. statements. Here is an example combining lines from the files
  1083. ``git.inc`` and ``git_2.24.1.bb``:
  1084. ::
  1085. SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \
  1086. ${KERNELORG_MIRROR}/software/scm/git/git-manpages-${PV}.tar.gz;name=manpages"
  1087. SRC_URI[tarball.md5sum] = "166bde96adbbc11c8843d4f8f4f9811b"
  1088. SRC_URI[tarball.sha256sum] = "ad5334956301c86841eb1e5b1bb20884a6bad89a10a6762c958220c7cf64da02"
  1089. SRC_URI[manpages.md5sum] = "31c2272a8979022497ba3d4202df145d"
  1090. SRC_URI[manpages.sha256sum] = "9a7ae3a093bea39770eb96ca3e5b40bff7af0b9f6123f089d7821d0e5b8e1230"
  1091. Proper values for ``md5`` and ``sha256`` checksums might be available
  1092. with other signatures on the download page for the upstream source (e.g.
  1093. ``md5``, ``sha1``, ``sha256``, ``GPG``, and so forth). Because the
  1094. OpenEmbedded build system only deals with ``sha256sum`` and ``md5sum``,
  1095. you should verify all the signatures you find by hand.
  1096. If no ``SRC_URI`` checksums are specified when you attempt to build the
  1097. recipe, or you provide an incorrect checksum, the build will produce an
  1098. error for each missing or incorrect checksum. As part of the error
  1099. message, the build system provides the checksum string corresponding to
  1100. the fetched file. Once you have the correct checksums, you can copy and
  1101. paste them into your recipe and then run the build again to continue.
  1102. .. note::
  1103. As mentioned, if the upstream source provides signatures for
  1104. verifying the downloaded source code, you should verify those
  1105. manually before setting the checksum values in the recipe and
  1106. continuing with the build.
  1107. This final example is a bit more complicated and is from the
  1108. ``meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb`` recipe. The
  1109. example's ``SRC_URI`` statement identifies multiple files as the source
  1110. files for the recipe: a tarball, a patch file, a desktop file, and an
  1111. icon.
  1112. ::
  1113. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1114. file://xwc.patch \
  1115. file://rxvt.desktop \
  1116. file://rxvt.png"
  1117. When you specify local files using the ``file://`` URI protocol, the
  1118. build system fetches files from the local machine. The path is relative
  1119. to the :term:`FILESPATH` variable
  1120. and searches specific directories in a certain order:
  1121. ``${``\ :term:`BP`\ ``}``,
  1122. ``${``\ :term:`BPN`\ ``}``, and
  1123. ``files``. The directories are assumed to be subdirectories of the
  1124. directory in which the recipe or append file resides. For another
  1125. example that specifies these types of files, see the "`Single .c File
  1126. Package (Hello
  1127. World!) <#new-recipe-single-c-file-package-hello-world>`__" section.
  1128. The previous example also specifies a patch file. Patch files are files
  1129. whose names usually end in ``.patch`` or ``.diff`` but can end with
  1130. compressed suffixes such as ``diff.gz`` and ``patch.bz2``, for example.
  1131. The build system automatically applies patches as described in the
  1132. "`Patching Code <#new-recipe-patching-code>`__" section.
  1133. Unpacking Code
  1134. --------------
  1135. During the build, the
  1136. :ref:`ref-tasks-unpack` task unpacks
  1137. the source with ``${``\ :term:`S`\ ``}``
  1138. pointing to where it is unpacked.
  1139. If you are fetching your source files from an upstream source archived
  1140. tarball and the tarball's internal structure matches the common
  1141. convention of a top-level subdirectory named
  1142. ``${``\ :term:`BPN`\ ``}-${``\ :term:`PV`\ ``}``,
  1143. then you do not need to set ``S``. However, if ``SRC_URI`` specifies to
  1144. fetch source from an archive that does not use this convention, or from
  1145. an SCM like Git or Subversion, your recipe needs to define ``S``.
  1146. If processing your recipe using BitBake successfully unpacks the source
  1147. files, you need to be sure that the directory pointed to by ``${S}``
  1148. matches the structure of the source.
  1149. Patching Code
  1150. -------------
  1151. Sometimes it is necessary to patch code after it has been fetched. Any
  1152. files mentioned in ``SRC_URI`` whose names end in ``.patch`` or
  1153. ``.diff`` or compressed versions of these suffixes (e.g. ``diff.gz`` are
  1154. treated as patches. The
  1155. :ref:`ref-tasks-patch` task
  1156. automatically applies these patches.
  1157. The build system should be able to apply patches with the "-p1" option
  1158. (i.e. one directory level in the path will be stripped off). If your
  1159. patch needs to have more directory levels stripped off, specify the
  1160. number of levels using the "striplevel" option in the ``SRC_URI`` entry
  1161. for the patch. Alternatively, if your patch needs to be applied in a
  1162. specific subdirectory that is not specified in the patch file, use the
  1163. "patchdir" option in the entry.
  1164. As with all local files referenced in
  1165. :term:`SRC_URI` using ``file://``,
  1166. you should place patch files in a directory next to the recipe either
  1167. named the same as the base name of the recipe
  1168. (:term:`BP` and
  1169. :term:`BPN`) or "files".
  1170. Licensing
  1171. ---------
  1172. Your recipe needs to have both the
  1173. :term:`LICENSE` and
  1174. :term:`LIC_FILES_CHKSUM`
  1175. variables:
  1176. - ``LICENSE``: This variable specifies the license for the software.
  1177. If you do not know the license under which the software you are
  1178. building is distributed, you should go to the source code and look
  1179. for that information. Typical files containing this information
  1180. include ``COPYING``, ``LICENSE``, and ``README`` files. You could
  1181. also find the information near the top of a source file. For example,
  1182. given a piece of software licensed under the GNU General Public
  1183. License version 2, you would set ``LICENSE`` as follows:
  1184. ::
  1185. LICENSE = "GPLv2"
  1186. The licenses you specify within ``LICENSE`` can have any name as long
  1187. as you do not use spaces, since spaces are used as separators between
  1188. license names. For standard licenses, use the names of the files in
  1189. ``meta/files/common-licenses/`` or the ``SPDXLICENSEMAP`` flag names
  1190. defined in ``meta/conf/licenses.conf``.
  1191. - ``LIC_FILES_CHKSUM``: The OpenEmbedded build system uses this
  1192. variable to make sure the license text has not changed. If it has,
  1193. the build produces an error and it affords you the chance to figure
  1194. it out and correct the problem.
  1195. You need to specify all applicable licensing files for the software.
  1196. At the end of the configuration step, the build process will compare
  1197. the checksums of the files to be sure the text has not changed. Any
  1198. differences result in an error with the message containing the
  1199. current checksum. For more explanation and examples of how to set the
  1200. ``LIC_FILES_CHKSUM`` variable, see the
  1201. ":ref:`dev-manual/common-tasks:tracking license changes`" section.
  1202. To determine the correct checksum string, you can list the
  1203. appropriate files in the ``LIC_FILES_CHKSUM`` variable with incorrect
  1204. md5 strings, attempt to build the software, and then note the
  1205. resulting error messages that will report the correct md5 strings.
  1206. See the "`Fetching Code <#new-recipe-fetching-code>`__" section for
  1207. additional information.
  1208. Here is an example that assumes the software has a ``COPYING`` file:
  1209. ::
  1210. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  1211. When you try to build the
  1212. software, the build system will produce an error and give you the
  1213. correct string that you can substitute into the recipe file for a
  1214. subsequent build.
  1215. Dependencies
  1216. ------------
  1217. Most software packages have a short list of other packages that they
  1218. require, which are called dependencies. These dependencies fall into two
  1219. main categories: build-time dependencies, which are required when the
  1220. software is built; and runtime dependencies, which are required to be
  1221. installed on the target in order for the software to run.
  1222. Within a recipe, you specify build-time dependencies using the
  1223. :term:`DEPENDS` variable. Although
  1224. nuances exist, items specified in ``DEPENDS`` should be names of other
  1225. recipes. It is important that you specify all build-time dependencies
  1226. explicitly.
  1227. Another consideration is that configure scripts might automatically
  1228. check for optional dependencies and enable corresponding functionality
  1229. if those dependencies are found. If you wish to make a recipe that is
  1230. more generally useful (e.g. publish the recipe in a layer for others to
  1231. use), instead of hard-disabling the functionality, you can use the
  1232. :term:`PACKAGECONFIG` variable to allow functionality and the
  1233. corresponding dependencies to be enabled and disabled easily by other
  1234. users of the recipe.
  1235. Similar to build-time dependencies, you specify runtime dependencies
  1236. through a variable -
  1237. :term:`RDEPENDS`, which is
  1238. package-specific. All variables that are package-specific need to have
  1239. the name of the package added to the end as an override. Since the main
  1240. package for a recipe has the same name as the recipe, and the recipe's
  1241. name can be found through the
  1242. ``${``\ :term:`PN`\ ``}`` variable, then
  1243. you specify the dependencies for the main package by setting
  1244. ``RDEPENDS_${PN}``. If the package were named ``${PN}-tools``, then you
  1245. would set ``RDEPENDS_${PN}-tools``, and so forth.
  1246. Some runtime dependencies will be set automatically at packaging time.
  1247. These dependencies include any shared library dependencies (i.e. if a
  1248. package "example" contains "libexample" and another package "mypackage"
  1249. contains a binary that links to "libexample" then the OpenEmbedded build
  1250. system will automatically add a runtime dependency to "mypackage" on
  1251. "example"). See the
  1252. ":ref:`overview-manual/overview-manual-concepts:automatically added runtime dependencies`"
  1253. section in the Yocto Project Overview and Concepts Manual for further
  1254. details.
  1255. Configuring the Recipe
  1256. ----------------------
  1257. Most software provides some means of setting build-time configuration
  1258. options before compilation. Typically, setting these options is
  1259. accomplished by running a configure script with options, or by modifying
  1260. a build configuration file.
  1261. .. note::
  1262. As of Yocto Project Release 1.7, some of the core recipes that
  1263. package binary configuration scripts now disable the scripts due to
  1264. the scripts previously requiring error-prone path substitution. The
  1265. OpenEmbedded build system uses ``pkg-config`` now, which is much more
  1266. robust. You can find a list of the ``*-config`` scripts that are disabled
  1267. in the ":ref:`migration-1.7-binary-configuration-scripts-disabled`" section
  1268. in the Yocto Project Reference Manual.
  1269. A major part of build-time configuration is about checking for
  1270. build-time dependencies and possibly enabling optional functionality as
  1271. a result. You need to specify any build-time dependencies for the
  1272. software you are building in your recipe's
  1273. :term:`DEPENDS` value, in terms of
  1274. other recipes that satisfy those dependencies. You can often find
  1275. build-time or runtime dependencies described in the software's
  1276. documentation.
  1277. The following list provides configuration items of note based on how
  1278. your software is built:
  1279. - *Autotools:* If your source files have a ``configure.ac`` file, then
  1280. your software is built using Autotools. If this is the case, you just
  1281. need to worry about modifying the configuration.
  1282. When using Autotools, your recipe needs to inherit the
  1283. :ref:`autotools <ref-classes-autotools>` class
  1284. and your recipe does not have to contain a
  1285. :ref:`ref-tasks-configure` task.
  1286. However, you might still want to make some adjustments. For example,
  1287. you can set
  1288. :term:`EXTRA_OECONF` or
  1289. :term:`PACKAGECONFIG_CONFARGS`
  1290. to pass any needed configure options that are specific to the recipe.
  1291. - *CMake:* If your source files have a ``CMakeLists.txt`` file, then
  1292. your software is built using CMake. If this is the case, you just
  1293. need to worry about modifying the configuration.
  1294. When you use CMake, your recipe needs to inherit the
  1295. :ref:`cmake <ref-classes-cmake>` class and your
  1296. recipe does not have to contain a
  1297. :ref:`ref-tasks-configure` task.
  1298. You can make some adjustments by setting
  1299. :term:`EXTRA_OECMAKE` to
  1300. pass any needed configure options that are specific to the recipe.
  1301. .. note::
  1302. If you need to install one or more custom CMake toolchain files
  1303. that are supplied by the application you are building, install the
  1304. files to ``${D}${datadir}/cmake/Modules`` during ``do_install``.
  1305. - *Other:* If your source files do not have a ``configure.ac`` or
  1306. ``CMakeLists.txt`` file, then your software is built using some
  1307. method other than Autotools or CMake. If this is the case, you
  1308. normally need to provide a
  1309. :ref:`ref-tasks-configure` task
  1310. in your recipe unless, of course, there is nothing to configure.
  1311. Even if your software is not being built by Autotools or CMake, you
  1312. still might not need to deal with any configuration issues. You need
  1313. to determine if configuration is even a required step. You might need
  1314. to modify a Makefile or some configuration file used for the build to
  1315. specify necessary build options. Or, perhaps you might need to run a
  1316. provided, custom configure script with the appropriate options.
  1317. For the case involving a custom configure script, you would run
  1318. ``./configure --help`` and look for the options you need to set.
  1319. Once configuration succeeds, it is always good practice to look at the
  1320. ``log.do_configure`` file to ensure that the appropriate options have
  1321. been enabled and no additional build-time dependencies need to be added
  1322. to ``DEPENDS``. For example, if the configure script reports that it
  1323. found something not mentioned in ``DEPENDS``, or that it did not find
  1324. something that it needed for some desired optional functionality, then
  1325. you would need to add those to ``DEPENDS``. Looking at the log might
  1326. also reveal items being checked for, enabled, or both that you do not
  1327. want, or items not being found that are in ``DEPENDS``, in which case
  1328. you would need to look at passing extra options to the configure script
  1329. as needed. For reference information on configure options specific to
  1330. the software you are building, you can consult the output of the
  1331. ``./configure --help`` command within ``${S}`` or consult the software's
  1332. upstream documentation.
  1333. Using Headers to Interface with Devices
  1334. ---------------------------------------
  1335. If your recipe builds an application that needs to communicate with some
  1336. device or needs an API into a custom kernel, you will need to provide
  1337. appropriate header files. Under no circumstances should you ever modify
  1338. the existing
  1339. ``meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc`` file.
  1340. These headers are used to build ``libc`` and must not be compromised
  1341. with custom or machine-specific header information. If you customize
  1342. ``libc`` through modified headers all other applications that use
  1343. ``libc`` thus become affected.
  1344. .. note::
  1345. Never copy and customize the ``libc`` header file (i.e.
  1346. ``meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc``).
  1347. The correct way to interface to a device or custom kernel is to use a
  1348. separate package that provides the additional headers for the driver or
  1349. other unique interfaces. When doing so, your application also becomes
  1350. responsible for creating a dependency on that specific provider.
  1351. Consider the following:
  1352. - Never modify ``linux-libc-headers.inc``. Consider that file to be
  1353. part of the ``libc`` system, and not something you use to access the
  1354. kernel directly. You should access ``libc`` through specific ``libc``
  1355. calls.
  1356. - Applications that must talk directly to devices should either provide
  1357. necessary headers themselves, or establish a dependency on a special
  1358. headers package that is specific to that driver.
  1359. For example, suppose you want to modify an existing header that adds I/O
  1360. control or network support. If the modifications are used by a small
  1361. number programs, providing a unique version of a header is easy and has
  1362. little impact. When doing so, bear in mind the guidelines in the
  1363. previous list.
  1364. .. note::
  1365. If for some reason your changes need to modify the behavior of the ``libc``,
  1366. and subsequently all other applications on the system, use a ``.bbappend``
  1367. to modify the ``linux-kernel-headers.inc`` file. However, take care to not
  1368. make the changes machine specific.
  1369. Consider a case where your kernel is older and you need an older
  1370. ``libc`` ABI. The headers installed by your recipe should still be a
  1371. standard mainline kernel, not your own custom one.
  1372. When you use custom kernel headers you need to get them from
  1373. :term:`STAGING_KERNEL_DIR`,
  1374. which is the directory with kernel headers that are required to build
  1375. out-of-tree modules. Your recipe will also need the following:
  1376. ::
  1377. do_configure[depends] += "virtual/kernel:do_shared_workdir"
  1378. Compilation
  1379. -----------
  1380. During a build, the ``do_compile`` task happens after source is fetched,
  1381. unpacked, and configured. If the recipe passes through ``do_compile``
  1382. successfully, nothing needs to be done.
  1383. However, if the compile step fails, you need to diagnose the failure.
  1384. Here are some common issues that cause failures.
  1385. .. note::
  1386. For cases where improper paths are detected for configuration files
  1387. or for when libraries/headers cannot be found, be sure you are using
  1388. the more robust ``pkg-config``. See the note in section
  1389. ":ref:`dev-manual/common-tasks:Configuring the Recipe`" for additional information.
  1390. - *Parallel build failures:* These failures manifest themselves as
  1391. intermittent errors, or errors reporting that a file or directory
  1392. that should be created by some other part of the build process could
  1393. not be found. This type of failure can occur even if, upon
  1394. inspection, the file or directory does exist after the build has
  1395. failed, because that part of the build process happened in the wrong
  1396. order.
  1397. To fix the problem, you need to either satisfy the missing dependency
  1398. in the Makefile or whatever script produced the Makefile, or (as a
  1399. workaround) set :term:`PARALLEL_MAKE` to an empty string:
  1400. ::
  1401. PARALLEL_MAKE = ""
  1402. For information on parallel Makefile issues, see the "`Debugging
  1403. Parallel Make Races <#debugging-parallel-make-races>`__" section.
  1404. - *Improper host path usage:* This failure applies to recipes building
  1405. for the target or ``nativesdk`` only. The failure occurs when the
  1406. compilation process uses improper headers, libraries, or other files
  1407. from the host system when cross-compiling for the target.
  1408. To fix the problem, examine the ``log.do_compile`` file to identify
  1409. the host paths being used (e.g. ``/usr/include``, ``/usr/lib``, and
  1410. so forth) and then either add configure options, apply a patch, or do
  1411. both.
  1412. - *Failure to find required libraries/headers:* If a build-time
  1413. dependency is missing because it has not been declared in
  1414. :term:`DEPENDS`, or because the
  1415. dependency exists but the path used by the build process to find the
  1416. file is incorrect and the configure step did not detect it, the
  1417. compilation process could fail. For either of these failures, the
  1418. compilation process notes that files could not be found. In these
  1419. cases, you need to go back and add additional options to the
  1420. configure script as well as possibly add additional build-time
  1421. dependencies to ``DEPENDS``.
  1422. Occasionally, it is necessary to apply a patch to the source to
  1423. ensure the correct paths are used. If you need to specify paths to
  1424. find files staged into the sysroot from other recipes, use the
  1425. variables that the OpenEmbedded build system provides (e.g.
  1426. ``STAGING_BINDIR``, ``STAGING_INCDIR``, ``STAGING_DATADIR``, and so
  1427. forth).
  1428. Installing
  1429. ----------
  1430. During ``do_install``, the task copies the built files along with their
  1431. hierarchy to locations that would mirror their locations on the target
  1432. device. The installation process copies files from the
  1433. ``${``\ :term:`S`\ ``}``,
  1434. ``${``\ :term:`B`\ ``}``, and
  1435. ``${``\ :term:`WORKDIR`\ ``}``
  1436. directories to the ``${``\ :term:`D`\ ``}``
  1437. directory to create the structure as it should appear on the target
  1438. system.
  1439. How your software is built affects what you must do to be sure your
  1440. software is installed correctly. The following list describes what you
  1441. must do for installation depending on the type of build system used by
  1442. the software being built:
  1443. - *Autotools and CMake:* If the software your recipe is building uses
  1444. Autotools or CMake, the OpenEmbedded build system understands how to
  1445. install the software. Consequently, you do not have to have a
  1446. ``do_install`` task as part of your recipe. You just need to make
  1447. sure the install portion of the build completes with no issues.
  1448. However, if you wish to install additional files not already being
  1449. installed by ``make install``, you should do this using a
  1450. ``do_install_append`` function using the install command as described
  1451. in the "Manual" bulleted item later in this list.
  1452. - *Other (using* ``make install``\ *)*: You need to define a ``do_install``
  1453. function in your recipe. The function should call
  1454. ``oe_runmake install`` and will likely need to pass in the
  1455. destination directory as well. How you pass that path is dependent on
  1456. how the ``Makefile`` being run is written (e.g. ``DESTDIR=${D}``,
  1457. ``PREFIX=${D}``, ``INSTALLROOT=${D}``, and so forth).
  1458. For an example recipe using ``make install``, see the
  1459. "`Makefile-Based Package <#new-recipe-makefile-based-package>`__"
  1460. section.
  1461. - *Manual:* You need to define a ``do_install`` function in your
  1462. recipe. The function must first use ``install -d`` to create the
  1463. directories under
  1464. ``${``\ :term:`D`\ ``}``. Once the
  1465. directories exist, your function can use ``install`` to manually
  1466. install the built software into the directories.
  1467. You can find more information on ``install`` at
  1468. https://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html.
  1469. For the scenarios that do not use Autotools or CMake, you need to track
  1470. the installation and diagnose and fix any issues until everything
  1471. installs correctly. You need to look in the default location of
  1472. ``${D}``, which is ``${WORKDIR}/image``, to be sure your files have been
  1473. installed correctly.
  1474. .. note::
  1475. - During the installation process, you might need to modify some of
  1476. the installed files to suit the target layout. For example, you
  1477. might need to replace hard-coded paths in an initscript with
  1478. values of variables provided by the build system, such as
  1479. replacing ``/usr/bin/`` with ``${bindir}``. If you do perform such
  1480. modifications during ``do_install``, be sure to modify the
  1481. destination file after copying rather than before copying.
  1482. Modifying after copying ensures that the build system can
  1483. re-execute ``do_install`` if needed.
  1484. - ``oe_runmake install``, which can be run directly or can be run
  1485. indirectly by the
  1486. :ref:`autotools <ref-classes-autotools>` and
  1487. :ref:`cmake <ref-classes-cmake>` classes,
  1488. runs ``make install`` in parallel. Sometimes, a Makefile can have
  1489. missing dependencies between targets that can result in race
  1490. conditions. If you experience intermittent failures during
  1491. ``do_install``, you might be able to work around them by disabling
  1492. parallel Makefile installs by adding the following to the recipe:
  1493. ::
  1494. PARALLEL_MAKEINST = ""
  1495. See :term:`PARALLEL_MAKEINST` for additional information.
  1496. - If you need to install one or more custom CMake toolchain files
  1497. that are supplied by the application you are building, install the
  1498. files to ``${D}${datadir}/cmake/Modules`` during
  1499. :ref:`ref-tasks-install`.
  1500. Enabling System Services
  1501. ------------------------
  1502. If you want to install a service, which is a process that usually starts
  1503. on boot and runs in the background, then you must include some
  1504. additional definitions in your recipe.
  1505. If you are adding services and the service initialization script or the
  1506. service file itself is not installed, you must provide for that
  1507. installation in your recipe using a ``do_install_append`` function. If
  1508. your recipe already has a ``do_install`` function, update the function
  1509. near its end rather than adding an additional ``do_install_append``
  1510. function.
  1511. When you create the installation for your services, you need to
  1512. accomplish what is normally done by ``make install``. In other words,
  1513. make sure your installation arranges the output similar to how it is
  1514. arranged on the target system.
  1515. The OpenEmbedded build system provides support for starting services two
  1516. different ways:
  1517. - *SysVinit:* SysVinit is a system and service manager that manages the
  1518. init system used to control the very basic functions of your system.
  1519. The init program is the first program started by the Linux kernel
  1520. when the system boots. Init then controls the startup, running and
  1521. shutdown of all other programs.
  1522. To enable a service using SysVinit, your recipe needs to inherit the
  1523. :ref:`update-rc.d <ref-classes-update-rc.d>`
  1524. class. The class helps facilitate safely installing the package on
  1525. the target.
  1526. You will need to set the
  1527. :term:`INITSCRIPT_PACKAGES`,
  1528. :term:`INITSCRIPT_NAME`,
  1529. and
  1530. :term:`INITSCRIPT_PARAMS`
  1531. variables within your recipe.
  1532. - *systemd:* System Management Daemon (systemd) was designed to replace
  1533. SysVinit and to provide enhanced management of services. For more
  1534. information on systemd, see the systemd homepage at
  1535. https://freedesktop.org/wiki/Software/systemd/.
  1536. To enable a service using systemd, your recipe needs to inherit the
  1537. :ref:`systemd <ref-classes-systemd>` class. See
  1538. the ``systemd.bbclass`` file located in your :term:`Source Directory`
  1539. section for
  1540. more information.
  1541. Packaging
  1542. ---------
  1543. Successful packaging is a combination of automated processes performed
  1544. by the OpenEmbedded build system and some specific steps you need to
  1545. take. The following list describes the process:
  1546. - *Splitting Files*: The ``do_package`` task splits the files produced
  1547. by the recipe into logical components. Even software that produces a
  1548. single binary might still have debug symbols, documentation, and
  1549. other logical components that should be split out. The ``do_package``
  1550. task ensures that files are split up and packaged correctly.
  1551. - *Running QA Checks*: The
  1552. :ref:`insane <ref-classes-insane>` class adds a
  1553. step to the package generation process so that output quality
  1554. assurance checks are generated by the OpenEmbedded build system. This
  1555. step performs a range of checks to be sure the build's output is free
  1556. of common problems that show up during runtime. For information on
  1557. these checks, see the
  1558. :ref:`insane <ref-classes-insane>` class and
  1559. the ":ref:`ref-manual/ref-qa-checks:qa error and warning messages`"
  1560. chapter in the Yocto Project Reference Manual.
  1561. - *Hand-Checking Your Packages*: After you build your software, you
  1562. need to be sure your packages are correct. Examine the
  1563. ``${``\ :term:`WORKDIR`\ ``}/packages-split``
  1564. directory and make sure files are where you expect them to be. If you
  1565. discover problems, you can set
  1566. :term:`PACKAGES`,
  1567. :term:`FILES`,
  1568. ``do_install(_append)``, and so forth as needed.
  1569. - *Splitting an Application into Multiple Packages*: If you need to
  1570. split an application into several packages, see the "`Splitting an
  1571. Application into Multiple
  1572. Packages <#splitting-an-application-into-multiple-packages>`__"
  1573. section for an example.
  1574. - *Installing a Post-Installation Script*: For an example showing how
  1575. to install a post-installation script, see the "`Post-Installation
  1576. Scripts <#new-recipe-post-installation-scripts>`__" section.
  1577. - *Marking Package Architecture*: Depending on what your recipe is
  1578. building and how it is configured, it might be important to mark the
  1579. packages produced as being specific to a particular machine, or to
  1580. mark them as not being specific to a particular machine or
  1581. architecture at all.
  1582. By default, packages apply to any machine with the same architecture
  1583. as the target machine. When a recipe produces packages that are
  1584. machine-specific (e.g. the
  1585. :term:`MACHINE` value is passed
  1586. into the configure script or a patch is applied only for a particular
  1587. machine), you should mark them as such by adding the following to the
  1588. recipe:
  1589. ::
  1590. PACKAGE_ARCH = "${MACHINE_ARCH}"
  1591. On the other hand, if the recipe produces packages that do not
  1592. contain anything specific to the target machine or architecture at
  1593. all (e.g. recipes that simply package script files or configuration
  1594. files), you should use the
  1595. :ref:`allarch <ref-classes-allarch>` class to
  1596. do this for you by adding this to your recipe:
  1597. ::
  1598. inherit allarch
  1599. Ensuring that the package architecture is correct is not critical
  1600. while you are doing the first few builds of your recipe. However, it
  1601. is important in order to ensure that your recipe rebuilds (or does
  1602. not rebuild) appropriately in response to changes in configuration,
  1603. and to ensure that you get the appropriate packages installed on the
  1604. target machine, particularly if you run separate builds for more than
  1605. one target machine.
  1606. Sharing Files Between Recipes
  1607. -----------------------------
  1608. Recipes often need to use files provided by other recipes on the build
  1609. host. For example, an application linking to a common library needs
  1610. access to the library itself and its associated headers. The way this
  1611. access is accomplished is by populating a sysroot with files. Each
  1612. recipe has two sysroots in its work directory, one for target files
  1613. (``recipe-sysroot``) and one for files that are native to the build host
  1614. (``recipe-sysroot-native``).
  1615. .. note::
  1616. You could find the term "staging" used within the Yocto project
  1617. regarding files populating sysroots (e.g. the :term:`STAGING_DIR`
  1618. variable).
  1619. Recipes should never populate the sysroot directly (i.e. write files
  1620. into sysroot). Instead, files should be installed into standard
  1621. locations during the
  1622. :ref:`ref-tasks-install` task within
  1623. the ``${``\ :term:`D`\ ``}`` directory. The
  1624. reason for this limitation is that almost all files that populate the
  1625. sysroot are cataloged in manifests in order to ensure the files can be
  1626. removed later when a recipe is either modified or removed. Thus, the
  1627. sysroot is able to remain free from stale files.
  1628. A subset of the files installed by the
  1629. :ref:`ref-tasks-install` task are
  1630. used by the
  1631. :ref:`ref-tasks-populate_sysroot`
  1632. task as defined by the the
  1633. :term:`SYSROOT_DIRS` variable to
  1634. automatically populate the sysroot. It is possible to modify the list of
  1635. directories that populate the sysroot. The following example shows how
  1636. you could add the ``/opt`` directory to the list of directories within a
  1637. recipe:
  1638. ::
  1639. SYSROOT_DIRS += "/opt"
  1640. For a more complete description of the
  1641. :ref:`ref-tasks-populate_sysroot`
  1642. task and its associated functions, see the
  1643. :ref:`staging <ref-classes-staging>` class.
  1644. Using Virtual Providers
  1645. -----------------------
  1646. Prior to a build, if you know that several different recipes provide the
  1647. same functionality, you can use a virtual provider (i.e. ``virtual/*``)
  1648. as a placeholder for the actual provider. The actual provider is
  1649. determined at build-time.
  1650. A common scenario where a virtual provider is used would be for the
  1651. kernel recipe. Suppose you have three kernel recipes whose
  1652. :term:`PN` values map to ``kernel-big``,
  1653. ``kernel-mid``, and ``kernel-small``. Furthermore, each of these recipes
  1654. in some way uses a :term:`PROVIDES`
  1655. statement that essentially identifies itself as being able to provide
  1656. ``virtual/kernel``. Here is one way through the
  1657. :ref:`kernel <ref-classes-kernel>` class:
  1658. ::
  1659. PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }"
  1660. Any recipe that inherits the ``kernel`` class is
  1661. going to utilize a ``PROVIDES`` statement that identifies that recipe as
  1662. being able to provide the ``virtual/kernel`` item.
  1663. Now comes the time to actually build an image and you need a kernel
  1664. recipe, but which one? You can configure your build to call out the
  1665. kernel recipe you want by using the :term:`PREFERRED_PROVIDER` variable. As
  1666. an example, consider the :yocto_git:`x86-base.inc
  1667. </poky/tree/meta/conf/machine/include/x86-base.inc>` include file, which is a
  1668. machine (i.e. :term:`MACHINE`) configuration file. This include file is the
  1669. reason all x86-based machines use the ``linux-yocto`` kernel. Here are the
  1670. relevant lines from the include file:
  1671. ::
  1672. PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto"
  1673. PREFERRED_VERSION_linux-yocto ??= "4.15%"
  1674. When you use a virtual provider, you do not have to "hard code" a recipe
  1675. name as a build dependency. You can use the
  1676. :term:`DEPENDS` variable to state the
  1677. build is dependent on ``virtual/kernel`` for example:
  1678. ::
  1679. DEPENDS = "virtual/kernel"
  1680. During the build, the OpenEmbedded build system picks
  1681. the correct recipe needed for the ``virtual/kernel`` dependency based on
  1682. the ``PREFERRED_PROVIDER`` variable. If you want to use the small kernel
  1683. mentioned at the beginning of this section, configure your build as
  1684. follows:
  1685. ::
  1686. PREFERRED_PROVIDER_virtual/kernel ??= "kernel-small"
  1687. .. note::
  1688. Any recipe that ``PROVIDES`` a ``virtual/*`` item that is ultimately not
  1689. selected through ``PREFERRED_PROVIDER`` does not get built. Preventing these
  1690. recipes from building is usually the desired behavior since this mechanism's
  1691. purpose is to select between mutually exclusive alternative providers.
  1692. The following lists specific examples of virtual providers:
  1693. - ``virtual/kernel``: Provides the name of the kernel recipe to use
  1694. when building a kernel image.
  1695. - ``virtual/bootloader``: Provides the name of the bootloader to use
  1696. when building an image.
  1697. - ``virtual/libgbm``: Provides ``gbm.pc``.
  1698. - ``virtual/egl``: Provides ``egl.pc`` and possibly ``wayland-egl.pc``.
  1699. - ``virtual/libgl``: Provides ``gl.pc`` (i.e. libGL).
  1700. - ``virtual/libgles1``: Provides ``glesv1_cm.pc`` (i.e. libGLESv1_CM).
  1701. - ``virtual/libgles2``: Provides ``glesv2.pc`` (i.e. libGLESv2).
  1702. .. note::
  1703. Virtual providers only apply to build time dependencies specified with
  1704. :term:`PROVIDES` and :term:`DEPENDS`. They do not apply to runtime
  1705. dependencies specified with :term:`RPROVIDES` and :term:`RDEPENDS`.
  1706. Properly Versioning Pre-Release Recipes
  1707. ---------------------------------------
  1708. Sometimes the name of a recipe can lead to versioning problems when the
  1709. recipe is upgraded to a final release. For example, consider the
  1710. ``irssi_0.8.16-rc1.bb`` recipe file in the list of example recipes in
  1711. the "`Storing and Naming the
  1712. Recipe <#new-recipe-storing-and-naming-the-recipe>`__" section. This
  1713. recipe is at a release candidate stage (i.e. "rc1"). When the recipe is
  1714. released, the recipe filename becomes ``irssi_0.8.16.bb``. The version
  1715. change from ``0.8.16-rc1`` to ``0.8.16`` is seen as a decrease by the
  1716. build system and package managers, so the resulting packages will not
  1717. correctly trigger an upgrade.
  1718. In order to ensure the versions compare properly, the recommended
  1719. convention is to set :term:`PV` within the
  1720. recipe to "previous_version+current_version". You can use an additional
  1721. variable so that you can use the current version elsewhere. Here is an
  1722. example:
  1723. ::
  1724. REALPV = "0.8.16-rc1"
  1725. PV = "0.8.15+${REALPV}"
  1726. Post-Installation Scripts
  1727. -------------------------
  1728. Post-installation scripts run immediately after installing a package on
  1729. the target or during image creation when a package is included in an
  1730. image. To add a post-installation script to a package, add a
  1731. ``pkg_postinst_``\ `PACKAGENAME`\ ``()`` function to the recipe file
  1732. (``.bb``) and replace `PACKAGENAME` with the name of the package you want
  1733. to attach to the ``postinst`` script. To apply the post-installation
  1734. script to the main package for the recipe, which is usually what is
  1735. required, specify
  1736. ``${``\ :term:`PN`\ ``}`` in place of
  1737. PACKAGENAME.
  1738. A post-installation function has the following structure:
  1739. ::
  1740. pkg_postinst_PACKAGENAME() {
  1741. # Commands to carry out
  1742. }
  1743. The script defined in the post-installation function is called when the
  1744. root filesystem is created. If the script succeeds, the package is
  1745. marked as installed.
  1746. .. note::
  1747. Any RPM post-installation script that runs on the target should
  1748. return a 0 exit code. RPM does not allow non-zero exit codes for
  1749. these scripts, and the RPM package manager will cause the package to
  1750. fail installation on the target.
  1751. Sometimes it is necessary for the execution of a post-installation
  1752. script to be delayed until the first boot. For example, the script might
  1753. need to be executed on the device itself. To delay script execution
  1754. until boot time, you must explicitly mark post installs to defer to the
  1755. target. You can use ``pkg_postinst_ontarget()`` or call
  1756. ``postinst_intercept delay_to_first_boot`` from ``pkg_postinst()``. Any
  1757. failure of a ``pkg_postinst()`` script (including exit 1) triggers an
  1758. error during the
  1759. :ref:`ref-tasks-rootfs` task.
  1760. If you have recipes that use ``pkg_postinst`` function and they require
  1761. the use of non-standard native tools that have dependencies during
  1762. rootfs construction, you need to use the
  1763. :term:`PACKAGE_WRITE_DEPS`
  1764. variable in your recipe to list these tools. If you do not use this
  1765. variable, the tools might be missing and execution of the
  1766. post-installation script is deferred until first boot. Deferring the
  1767. script to first boot is undesirable and for read-only rootfs impossible.
  1768. .. note::
  1769. Equivalent support for pre-install, pre-uninstall, and post-uninstall
  1770. scripts exist by way of ``pkg_preinst``, ``pkg_prerm``, and ``pkg_postrm``,
  1771. respectively. These scrips work in exactly the same way as does
  1772. ``pkg_postinst`` with the exception that they run at different times. Also,
  1773. because of when they run, they are not applicable to being run at image
  1774. creation time like ``pkg_postinst``.
  1775. Testing
  1776. -------
  1777. The final step for completing your recipe is to be sure that the
  1778. software you built runs correctly. To accomplish runtime testing, add
  1779. the build's output packages to your image and test them on the target.
  1780. For information on how to customize your image by adding specific
  1781. packages, see the "`Customizing
  1782. Images <#usingpoky-extend-customimage>`__" section.
  1783. Examples
  1784. --------
  1785. To help summarize how to write a recipe, this section provides some
  1786. examples given various scenarios:
  1787. - Recipes that use local files
  1788. - Using an Autotooled package
  1789. - Using a Makefile-based package
  1790. - Splitting an application into multiple packages
  1791. - Adding binaries to an image
  1792. Single .c File Package (Hello World!)
  1793. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1794. Building an application from a single file that is stored locally (e.g.
  1795. under ``files``) requires a recipe that has the file listed in the
  1796. ``SRC_URI`` variable. Additionally, you need to manually write the
  1797. ``do_compile`` and ``do_install`` tasks. The ``S`` variable defines the
  1798. directory containing the source code, which is set to
  1799. :term:`WORKDIR` in this case - the
  1800. directory BitBake uses for the build.
  1801. ::
  1802. SUMMARY = "Simple helloworld application"
  1803. SECTION = "examples"
  1804. LICENSE = "MIT"
  1805. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  1806. SRC_URI = "file://helloworld.c"
  1807. S = "${WORKDIR}"
  1808. do_compile() {
  1809. ${CC} helloworld.c -o helloworld
  1810. }
  1811. do_install() {
  1812. install -d ${D}${bindir}
  1813. install -m 0755 helloworld ${D}${bindir}
  1814. }
  1815. By default, the ``helloworld``, ``helloworld-dbg``, and
  1816. ``helloworld-dev`` packages are built. For information on how to
  1817. customize the packaging process, see the "`Splitting an Application into
  1818. Multiple Packages <#splitting-an-application-into-multiple-packages>`__"
  1819. section.
  1820. Autotooled Package
  1821. ~~~~~~~~~~~~~~~~~~
  1822. Applications that use Autotools such as ``autoconf`` and ``automake``
  1823. require a recipe that has a source archive listed in ``SRC_URI`` and
  1824. also inherit the
  1825. :ref:`autotools <ref-classes-autotools>` class,
  1826. which contains the definitions of all the steps needed to build an
  1827. Autotool-based application. The result of the build is automatically
  1828. packaged. And, if the application uses NLS for localization, packages
  1829. with local information are generated (one package per language).
  1830. Following is one example: (``hello_2.3.bb``)
  1831. ::
  1832. SUMMARY = "GNU Helloworld application"
  1833. SECTION = "examples"
  1834. LICENSE = "GPLv2+"
  1835. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  1836. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  1837. inherit autotools gettext
  1838. The variable ``LIC_FILES_CHKSUM`` is used to track source license
  1839. changes as described in the
  1840. ":ref:`dev-manual/common-tasks:tracking license changes`" section in
  1841. the Yocto Project Overview and Concepts Manual. You can quickly create
  1842. Autotool-based recipes in a manner similar to the previous example.
  1843. Makefile-Based Package
  1844. ~~~~~~~~~~~~~~~~~~~~~~
  1845. Applications that use GNU ``make`` also require a recipe that has the
  1846. source archive listed in ``SRC_URI``. You do not need to add a
  1847. ``do_compile`` step since by default BitBake starts the ``make`` command
  1848. to compile the application. If you need additional ``make`` options, you
  1849. should store them in the
  1850. :term:`EXTRA_OEMAKE` or
  1851. :term:`PACKAGECONFIG_CONFARGS`
  1852. variables. BitBake passes these options into the GNU ``make``
  1853. invocation. Note that a ``do_install`` task is still required.
  1854. Otherwise, BitBake runs an empty ``do_install`` task by default.
  1855. Some applications might require extra parameters to be passed to the
  1856. compiler. For example, the application might need an additional header
  1857. path. You can accomplish this by adding to the ``CFLAGS`` variable. The
  1858. following example shows this:
  1859. ::
  1860. CFLAGS_prepend = "-I ${S}/include "
  1861. In the following example, ``mtd-utils`` is a makefile-based package:
  1862. ::
  1863. SUMMARY = "Tools for managing memory technology devices"
  1864. SECTION = "base"
  1865. DEPENDS = "zlib lzo e2fsprogs util-linux"
  1866. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  1867. LICENSE = "GPLv2+"
  1868. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  1869. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  1870. # Use the latest version at 26 Oct, 2013
  1871. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  1872. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  1873. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  1874. "
  1875. PV = "1.5.1+git${SRCPV}"
  1876. S = "${WORKDIR}/git"
  1877. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  1878. do_install () {
  1879. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  1880. }
  1881. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  1882. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  1883. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  1884. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  1885. PARALLEL_MAKE = ""
  1886. BBCLASSEXTEND = "native"
  1887. Splitting an Application into Multiple Packages
  1888. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1889. You can use the variables ``PACKAGES`` and ``FILES`` to split an
  1890. application into multiple packages.
  1891. Following is an example that uses the ``libxpm`` recipe. By default,
  1892. this recipe generates a single package that contains the library along
  1893. with a few binaries. You can modify the recipe to split the binaries
  1894. into separate packages:
  1895. ::
  1896. require xorg-lib-common.inc
  1897. SUMMARY = "Xpm: X Pixmap extension library"
  1898. LICENSE = "BSD"
  1899. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  1900. DEPENDS += "libxext libsm libxt"
  1901. PE = "1"
  1902. XORG_PN = "libXpm"
  1903. PACKAGES =+ "sxpm cxpm"
  1904. FILES_cxpm = "${bindir}/cxpm"
  1905. FILES_sxpm = "${bindir}/sxpm"
  1906. In the previous example, we want to ship the ``sxpm`` and ``cxpm``
  1907. binaries in separate packages. Since ``bindir`` would be packaged into
  1908. the main ``PN`` package by default, we prepend the ``PACKAGES`` variable
  1909. so additional package names are added to the start of list. This results
  1910. in the extra ``FILES_*`` variables then containing information that
  1911. define which files and directories go into which packages. Files
  1912. included by earlier packages are skipped by latter packages. Thus, the
  1913. main ``PN`` package does not include the above listed files.
  1914. Packaging Externally Produced Binaries
  1915. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1916. Sometimes, you need to add pre-compiled binaries to an image. For
  1917. example, suppose that binaries for proprietary code exist, which are
  1918. created by a particular division of a company. Your part of the company
  1919. needs to use those binaries as part of an image that you are building
  1920. using the OpenEmbedded build system. Since you only have the binaries
  1921. and not the source code, you cannot use a typical recipe that expects to
  1922. fetch the source specified in
  1923. :term:`SRC_URI` and then compile it.
  1924. One method is to package the binaries and then install them as part of
  1925. the image. Generally, it is not a good idea to package binaries since,
  1926. among other things, it can hinder the ability to reproduce builds and
  1927. could lead to compatibility problems with ABI in the future. However,
  1928. sometimes you have no choice.
  1929. The easiest solution is to create a recipe that uses the
  1930. :ref:`bin_package <ref-classes-bin-package>` class
  1931. and to be sure that you are using default locations for build artifacts.
  1932. In most cases, the ``bin_package`` class handles "skipping" the
  1933. configure and compile steps as well as sets things up to grab packages
  1934. from the appropriate area. In particular, this class sets ``noexec`` on
  1935. both the :ref:`ref-tasks-configure`
  1936. and :ref:`ref-tasks-compile` tasks,
  1937. sets ``FILES_${PN}`` to "/" so that it picks up all files, and sets up a
  1938. :ref:`ref-tasks-install` task, which
  1939. effectively copies all files from ``${S}`` to ``${D}``. The
  1940. ``bin_package`` class works well when the files extracted into ``${S}``
  1941. are already laid out in the way they should be laid out on the target.
  1942. For more information on these variables, see the
  1943. :term:`FILES`,
  1944. :term:`PN`,
  1945. :term:`S`, and
  1946. :term:`D` variables in the Yocto Project
  1947. Reference Manual's variable glossary.
  1948. .. note::
  1949. - Using :term:`DEPENDS` is a good
  1950. idea even for components distributed in binary form, and is often
  1951. necessary for shared libraries. For a shared library, listing the
  1952. library dependencies in ``DEPENDS`` makes sure that the libraries
  1953. are available in the staging sysroot when other recipes link
  1954. against the library, which might be necessary for successful
  1955. linking.
  1956. - Using ``DEPENDS`` also allows runtime dependencies between
  1957. packages to be added automatically. See the
  1958. ":ref:`overview-manual/overview-manual-concepts:automatically added runtime dependencies`"
  1959. section in the Yocto Project Overview and Concepts Manual for more
  1960. information.
  1961. If you cannot use the ``bin_package`` class, you need to be sure you are
  1962. doing the following:
  1963. - Create a recipe where the
  1964. :ref:`ref-tasks-configure` and
  1965. :ref:`ref-tasks-compile` tasks do
  1966. nothing: It is usually sufficient to just not define these tasks in
  1967. the recipe, because the default implementations do nothing unless a
  1968. Makefile is found in
  1969. ``${``\ :term:`S`\ ``}``.
  1970. If ``${S}`` might contain a Makefile, or if you inherit some class
  1971. that replaces ``do_configure`` and ``do_compile`` with custom
  1972. versions, then you can use the
  1973. ``[``\ :ref:`noexec <bitbake-user-manual/bitbake-user-manual-metadata:variable flags>`\ ``]``
  1974. flag to turn the tasks into no-ops, as follows:
  1975. ::
  1976. do_configure[noexec] = "1"
  1977. do_compile[noexec] = "1"
  1978. Unlike
  1979. :ref:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata:deleting a task`,
  1980. using the flag preserves the dependency chain from the
  1981. :ref:`ref-tasks-fetch`,
  1982. :ref:`ref-tasks-unpack`, and
  1983. :ref:`ref-tasks-patch` tasks to the
  1984. :ref:`ref-tasks-install` task.
  1985. - Make sure your ``do_install`` task installs the binaries
  1986. appropriately.
  1987. - Ensure that you set up :term:`FILES`
  1988. (usually
  1989. ``FILES_${``\ :term:`PN`\ ``}``) to
  1990. point to the files you have installed, which of course depends on
  1991. where you have installed them and whether those files are in
  1992. different locations than the defaults.
  1993. .. note::
  1994. If image prelinking is enabled (e.g. "image-prelink" is in :term:`USER_CLASSES`
  1995. which it is by default), prelink will change the binaries in the generated images
  1996. and this often catches people out. Remove that class to ensure binaries are
  1997. preserved exactly if that is necessary.
  1998. Following Recipe Style Guidelines
  1999. ---------------------------------
  2000. When writing recipes, it is good to conform to existing style
  2001. guidelines. The :oe_home:`OpenEmbedded Styleguide </wiki/Styleguide>` wiki page
  2002. provides rough guidelines for preferred recipe style.
  2003. It is common for existing recipes to deviate a bit from this style.
  2004. However, aiming for at least a consistent style is a good idea. Some
  2005. practices, such as omitting spaces around ``=`` operators in assignments
  2006. or ordering recipe components in an erratic way, are widely seen as poor
  2007. style.
  2008. Recipe Syntax
  2009. -------------
  2010. Understanding recipe file syntax is important for writing recipes. The
  2011. following list overviews the basic items that make up a BitBake recipe
  2012. file. For more complete BitBake syntax descriptions, see the
  2013. ":doc:`bitbake-user-manual/bitbake-user-manual-metadata`"
  2014. chapter of the BitBake User Manual.
  2015. - *Variable Assignments and Manipulations:* Variable assignments allow
  2016. a value to be assigned to a variable. The assignment can be static
  2017. text or might include the contents of other variables. In addition to
  2018. the assignment, appending and prepending operations are also
  2019. supported.
  2020. The following example shows some of the ways you can use variables in
  2021. recipes:
  2022. ::
  2023. S = "${WORKDIR}/postfix-${PV}"
  2024. CFLAGS += "-DNO_ASM"
  2025. SRC_URI_append = " file://fixup.patch"
  2026. - *Functions:* Functions provide a series of actions to be performed.
  2027. You usually use functions to override the default implementation of a
  2028. task function or to complement a default function (i.e. append or
  2029. prepend to an existing function). Standard functions use ``sh`` shell
  2030. syntax, although access to OpenEmbedded variables and internal
  2031. methods are also available.
  2032. The following is an example function from the ``sed`` recipe:
  2033. ::
  2034. do_install () {
  2035. autotools_do_install
  2036. install -d ${D}${base_bindir}
  2037. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  2038. rmdir ${D}${bindir}/
  2039. }
  2040. It is
  2041. also possible to implement new functions that are called between
  2042. existing tasks as long as the new functions are not replacing or
  2043. complementing the default functions. You can implement functions in
  2044. Python instead of shell. Both of these options are not seen in the
  2045. majority of recipes.
  2046. - *Keywords:* BitBake recipes use only a few keywords. You use keywords
  2047. to include common functions (``inherit``), load parts of a recipe
  2048. from other files (``include`` and ``require``) and export variables
  2049. to the environment (``export``).
  2050. The following example shows the use of some of these keywords:
  2051. ::
  2052. export POSTCONF = "${STAGING_BINDIR}/postconf"
  2053. inherit autoconf
  2054. require otherfile.inc
  2055. - *Comments (#):* Any lines that begin with the hash character (``#``)
  2056. are treated as comment lines and are ignored:
  2057. ::
  2058. # This is a comment
  2059. This next list summarizes the most important and most commonly used
  2060. parts of the recipe syntax. For more information on these parts of the
  2061. syntax, you can reference the
  2062. :doc:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata` chapter
  2063. in the BitBake User Manual.
  2064. - *Line Continuation (\\):* Use the backward slash (``\``) character to
  2065. split a statement over multiple lines. Place the slash character at
  2066. the end of the line that is to be continued on the next line:
  2067. ::
  2068. VAR = "A really long \
  2069. line"
  2070. .. note::
  2071. You cannot have any characters including spaces or tabs after the
  2072. slash character.
  2073. - *Using Variables (${VARNAME}):* Use the ``${VARNAME}`` syntax to
  2074. access the contents of a variable:
  2075. ::
  2076. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  2077. .. note::
  2078. It is important to understand that the value of a variable
  2079. expressed in this form does not get substituted automatically. The
  2080. expansion of these expressions happens on-demand later (e.g.
  2081. usually when a function that makes reference to the variable
  2082. executes). This behavior ensures that the values are most
  2083. appropriate for the context in which they are finally used. On the
  2084. rare occasion that you do need the variable expression to be
  2085. expanded immediately, you can use the
  2086. :=
  2087. operator instead of
  2088. =
  2089. when you make the assignment, but this is not generally needed.
  2090. - *Quote All Assignments ("value"):* Use double quotes around values in
  2091. all variable assignments (e.g. ``"value"``). Following is an example:
  2092. ::
  2093. VAR1 = "${OTHERVAR}"
  2094. VAR2 = "The version is ${PV}"
  2095. - *Conditional Assignment (?=):* Conditional assignment is used to
  2096. assign a value to a variable, but only when the variable is currently
  2097. unset. Use the question mark followed by the equal sign (``?=``) to
  2098. make a "soft" assignment used for conditional assignment. Typically,
  2099. "soft" assignments are used in the ``local.conf`` file for variables
  2100. that are allowed to come through from the external environment.
  2101. Here is an example where ``VAR1`` is set to "New value" if it is
  2102. currently empty. However, if ``VAR1`` has already been set, it
  2103. remains unchanged:
  2104. ::
  2105. VAR1 ?= "New value"
  2106. In this next example, ``VAR1`` is left with the value "Original value":
  2107. ::
  2108. VAR1 = "Original value"
  2109. VAR1 ?= "New value"
  2110. - *Appending (+=):* Use the plus character followed by the equals sign
  2111. (``+=``) to append values to existing variables.
  2112. .. note::
  2113. This operator adds a space between the existing content of the
  2114. variable and the new content.
  2115. Here is an example:
  2116. ::
  2117. SRC_URI += "file://fix-makefile.patch"
  2118. - *Prepending (=+):* Use the equals sign followed by the plus character
  2119. (``=+``) to prepend values to existing variables.
  2120. .. note::
  2121. This operator adds a space between the new content and the
  2122. existing content of the variable.
  2123. Here is an example:
  2124. ::
  2125. VAR =+ "Starts"
  2126. - *Appending (_append):* Use the ``_append`` operator to append values
  2127. to existing variables. This operator does not add any additional
  2128. space. Also, the operator is applied after all the ``+=``, and ``=+``
  2129. operators have been applied and after all ``=`` assignments have
  2130. occurred.
  2131. The following example shows the space being explicitly added to the
  2132. start to ensure the appended value is not merged with the existing
  2133. value:
  2134. ::
  2135. SRC_URI_append = " file://fix-makefile.patch"
  2136. You can also use
  2137. the ``_append`` operator with overrides, which results in the actions
  2138. only being performed for the specified target or machine:
  2139. ::
  2140. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  2141. - *Prepending (_prepend):* Use the ``_prepend`` operator to prepend
  2142. values to existing variables. This operator does not add any
  2143. additional space. Also, the operator is applied after all the ``+=``,
  2144. and ``=+`` operators have been applied and after all ``=``
  2145. assignments have occurred.
  2146. The following example shows the space being explicitly added to the
  2147. end to ensure the prepended value is not merged with the existing
  2148. value:
  2149. ::
  2150. CFLAGS_prepend = "-I${S}/myincludes "
  2151. You can also use the
  2152. ``_prepend`` operator with overrides, which results in the actions
  2153. only being performed for the specified target or machine:
  2154. ::
  2155. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  2156. - *Overrides:* You can use overrides to set a value conditionally,
  2157. typically based on how the recipe is being built. For example, to set
  2158. the :term:`KBRANCH` variable's
  2159. value to "standard/base" for any target
  2160. :term:`MACHINE`, except for
  2161. qemuarm where it should be set to "standard/arm-versatile-926ejs",
  2162. you would do the following:
  2163. ::
  2164. KBRANCH = "standard/base"
  2165. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  2166. Overrides are also used to separate
  2167. alternate values of a variable in other situations. For example, when
  2168. setting variables such as
  2169. :term:`FILES` and
  2170. :term:`RDEPENDS` that are
  2171. specific to individual packages produced by a recipe, you should
  2172. always use an override that specifies the name of the package.
  2173. - *Indentation:* Use spaces for indentation rather than tabs. For
  2174. shell functions, both currently work. However, it is a policy
  2175. decision of the Yocto Project to use tabs in shell functions. Realize
  2176. that some layers have a policy to use spaces for all indentation.
  2177. - *Using Python for Complex Operations:* For more advanced processing,
  2178. it is possible to use Python code during variable assignments (e.g.
  2179. search and replacement on a variable).
  2180. You indicate Python code using the ``${@python_code}`` syntax for the
  2181. variable assignment:
  2182. ::
  2183. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  2184. - *Shell Function Syntax:* Write shell functions as if you were writing
  2185. a shell script when you describe a list of actions to take. You
  2186. should ensure that your script works with a generic ``sh`` and that
  2187. it does not require any ``bash`` or other shell-specific
  2188. functionality. The same considerations apply to various system
  2189. utilities (e.g. ``sed``, ``grep``, ``awk``, and so forth) that you
  2190. might wish to use. If in doubt, you should check with multiple
  2191. implementations - including those from BusyBox.
  2192. Adding a New Machine
  2193. ====================
  2194. Adding a new machine to the Yocto Project is a straightforward process.
  2195. This section describes how to add machines that are similar to those
  2196. that the Yocto Project already supports.
  2197. .. note::
  2198. Although well within the capabilities of the Yocto Project, adding a
  2199. totally new architecture might require changes to ``gcc``/``glibc``
  2200. and to the site information, which is beyond the scope of this
  2201. manual.
  2202. For a complete example that shows how to add a new machine, see the
  2203. ":ref:`bsp-guide/bsp:creating a new bsp layer using the \`\`bitbake-layers\`\` script`"
  2204. section in the Yocto Project Board Support Package (BSP) Developer's
  2205. Guide.
  2206. Adding the Machine Configuration File
  2207. -------------------------------------
  2208. To add a new machine, you need to add a new machine configuration file
  2209. to the layer's ``conf/machine`` directory. This configuration file
  2210. provides details about the device you are adding.
  2211. The OpenEmbedded build system uses the root name of the machine
  2212. configuration file to reference the new machine. For example, given a
  2213. machine configuration file named ``crownbay.conf``, the build system
  2214. recognizes the machine as "crownbay".
  2215. The most important variables you must set in your machine configuration
  2216. file or include from a lower-level configuration file are as follows:
  2217. - ``TARGET_ARCH`` (e.g. "arm")
  2218. - ``PREFERRED_PROVIDER_virtual/kernel``
  2219. - ``MACHINE_FEATURES`` (e.g. "apm screen wifi")
  2220. You might also need these variables:
  2221. - ``SERIAL_CONSOLES`` (e.g. "115200;ttyS0 115200;ttyS1")
  2222. - ``KERNEL_IMAGETYPE`` (e.g. "zImage")
  2223. - ``IMAGE_FSTYPES`` (e.g. "tar.gz jffs2")
  2224. You can find full details on these variables in the reference section.
  2225. You can leverage existing machine ``.conf`` files from
  2226. ``meta-yocto-bsp/conf/machine/``.
  2227. Adding a Kernel for the Machine
  2228. -------------------------------
  2229. The OpenEmbedded build system needs to be able to build a kernel for the
  2230. machine. You need to either create a new kernel recipe for this machine,
  2231. or extend an existing kernel recipe. You can find several kernel recipe
  2232. examples in the Source Directory at ``meta/recipes-kernel/linux`` that
  2233. you can use as references.
  2234. If you are creating a new kernel recipe, normal recipe-writing rules
  2235. apply for setting up a ``SRC_URI``. Thus, you need to specify any
  2236. necessary patches and set ``S`` to point at the source code. You need to
  2237. create a ``do_configure`` task that configures the unpacked kernel with
  2238. a ``defconfig`` file. You can do this by using a ``make defconfig``
  2239. command or, more commonly, by copying in a suitable ``defconfig`` file
  2240. and then running ``make oldconfig``. By making use of ``inherit kernel``
  2241. and potentially some of the ``linux-*.inc`` files, most other
  2242. functionality is centralized and the defaults of the class normally work
  2243. well.
  2244. If you are extending an existing kernel recipe, it is usually a matter
  2245. of adding a suitable ``defconfig`` file. The file needs to be added into
  2246. a location similar to ``defconfig`` files used for other machines in a
  2247. given kernel recipe. A possible way to do this is by listing the file in
  2248. the ``SRC_URI`` and adding the machine to the expression in
  2249. ``COMPATIBLE_MACHINE``:
  2250. ::
  2251. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  2252. For more information on ``defconfig`` files, see the
  2253. ":ref:`kernel-dev/common:changing the configuration`"
  2254. section in the Yocto Project Linux Kernel Development Manual.
  2255. Adding a Formfactor Configuration File
  2256. --------------------------------------
  2257. A formfactor configuration file provides information about the target
  2258. hardware for which the image is being built and information that the
  2259. build system cannot obtain from other sources such as the kernel. Some
  2260. examples of information contained in a formfactor configuration file
  2261. include framebuffer orientation, whether or not the system has a
  2262. keyboard, the positioning of the keyboard in relation to the screen, and
  2263. the screen resolution.
  2264. The build system uses reasonable defaults in most cases. However, if
  2265. customization is necessary, you need to create a ``machconfig`` file in
  2266. the ``meta/recipes-bsp/formfactor/files`` directory. This directory
  2267. contains directories for specific machines such as ``qemuarm`` and
  2268. ``qemux86``. For information about the settings available and the
  2269. defaults, see the ``meta/recipes-bsp/formfactor/files/config`` file
  2270. found in the same area.
  2271. Following is an example for "qemuarm" machine:
  2272. ::
  2273. HAVE_TOUCHSCREEN=1
  2274. HAVE_KEYBOARD=1
  2275. DISPLAY_CAN_ROTATE=0
  2276. DISPLAY_ORIENTATION=0
  2277. #DISPLAY_WIDTH_PIXELS=640
  2278. #DISPLAY_HEIGHT_PIXELS=480
  2279. #DISPLAY_BPP=16
  2280. DISPLAY_DPI=150
  2281. DISPLAY_SUBPIXEL_ORDER=vrgb
  2282. Upgrading Recipes
  2283. =================
  2284. Over time, upstream developers publish new versions for software built
  2285. by layer recipes. It is recommended to keep recipes up-to-date with
  2286. upstream version releases.
  2287. While several methods exist that allow you upgrade a recipe, you might
  2288. consider checking on the upgrade status of a recipe first. You can do so
  2289. using the ``devtool check-upgrade-status`` command. See the
  2290. ":ref:`devtool-checking-on-the-upgrade-status-of-a-recipe`"
  2291. section in the Yocto Project Reference Manual for more information.
  2292. The remainder of this section describes three ways you can upgrade a
  2293. recipe. You can use the Automated Upgrade Helper (AUH) to set up
  2294. automatic version upgrades. Alternatively, you can use
  2295. ``devtool upgrade`` to set up semi-automatic version upgrades. Finally,
  2296. you can manually upgrade a recipe by editing the recipe itself.
  2297. Using the Auto Upgrade Helper (AUH)
  2298. -----------------------------------
  2299. The AUH utility works in conjunction with the OpenEmbedded build system
  2300. in order to automatically generate upgrades for recipes based on new
  2301. versions being published upstream. Use AUH when you want to create a
  2302. service that performs the upgrades automatically and optionally sends
  2303. you an email with the results.
  2304. AUH allows you to update several recipes with a single use. You can also
  2305. optionally perform build and integration tests using images with the
  2306. results saved to your hard drive and emails of results optionally sent
  2307. to recipe maintainers. Finally, AUH creates Git commits with appropriate
  2308. commit messages in the layer's tree for the changes made to recipes.
  2309. .. note::
  2310. Conditions do exist when you should not use AUH to upgrade recipes
  2311. and you should instead use either ``devtool upgrade`` or upgrade your
  2312. recipes manually:
  2313. - When AUH cannot complete the upgrade sequence. This situation
  2314. usually results because custom patches carried by the recipe
  2315. cannot be automatically rebased to the new version. In this case,
  2316. ``devtool upgrade`` allows you to manually resolve conflicts.
  2317. - When for any reason you want fuller control over the upgrade
  2318. process. For example, when you want special arrangements for
  2319. testing.
  2320. The following steps describe how to set up the AUH utility:
  2321. 1. *Be Sure the Development Host is Set Up:* You need to be sure that
  2322. your development host is set up to use the Yocto Project. For
  2323. information on how to set up your host, see the
  2324. ":ref:`dev-manual/start:Preparing the Build Host`" section.
  2325. 2. *Make Sure Git is Configured:* The AUH utility requires Git to be
  2326. configured because AUH uses Git to save upgrades. Thus, you must have
  2327. Git user and email configured. The following command shows your
  2328. configurations:
  2329. ::
  2330. $ git config --list
  2331. If you do not have the user and
  2332. email configured, you can use the following commands to do so:
  2333. ::
  2334. $ git config --global user.name some_name
  2335. $ git config --global user.email username@domain.com
  2336. 3. *Clone the AUH Repository:* To use AUH, you must clone the repository
  2337. onto your development host. The following command uses Git to create
  2338. a local copy of the repository on your system:
  2339. ::
  2340. $ git clone git://git.yoctoproject.org/auto-upgrade-helper
  2341. Cloning into 'auto-upgrade-helper'... remote: Counting objects: 768, done.
  2342. remote: Compressing objects: 100% (300/300), done.
  2343. remote: Total 768 (delta 499), reused 703 (delta 434)
  2344. Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done.
  2345. Resolving deltas: 100% (499/499), done.
  2346. Checking connectivity... done.
  2347. AUH is not part of the :term:`OpenEmbedded-Core (OE-Core)` or
  2348. :term:`Poky` repositories.
  2349. 4. *Create a Dedicated Build Directory:* Run the
  2350. :ref:`structure-core-script`
  2351. script to create a fresh build directory that you use exclusively for
  2352. running the AUH utility:
  2353. ::
  2354. $ cd ~/poky
  2355. $ source oe-init-build-env your_AUH_build_directory
  2356. Re-using an existing build directory and its configurations is not
  2357. recommended as existing settings could cause AUH to fail or behave
  2358. undesirably.
  2359. 5. *Make Configurations in Your Local Configuration File:* Several
  2360. settings need to exist in the ``local.conf`` file in the build
  2361. directory you just created for AUH. Make these following
  2362. configurations:
  2363. - If you want to enable :ref:`Build
  2364. History <dev-manual/common-tasks:maintaining build output quality>`,
  2365. which is optional, you need the following lines in the
  2366. ``conf/local.conf`` file:
  2367. ::
  2368. INHERIT =+ "buildhistory"
  2369. BUILDHISTORY_COMMIT = "1"
  2370. With this configuration and a successful
  2371. upgrade, a build history "diff" file appears in the
  2372. ``upgrade-helper/work/recipe/buildhistory-diff.txt`` file found in
  2373. your build directory.
  2374. - If you want to enable testing through the
  2375. :ref:`testimage <ref-classes-testimage*>`
  2376. class, which is optional, you need to have the following set in
  2377. your ``conf/local.conf`` file:
  2378. ::
  2379. INHERIT += "testimage"
  2380. .. note::
  2381. If your distro does not enable by default ptest, which Poky
  2382. does, you need the following in your ``local.conf`` file:
  2383. ::
  2384. DISTRO_FEATURES_append = " ptest"
  2385. 6. *Optionally Start a vncserver:* If you are running in a server
  2386. without an X11 session, you need to start a vncserver:
  2387. ::
  2388. $ vncserver :1
  2389. $ export DISPLAY=:1
  2390. 7. *Create and Edit an AUH Configuration File:* You need to have the
  2391. ``upgrade-helper/upgrade-helper.conf`` configuration file in your
  2392. build directory. You can find a sample configuration file in the
  2393. :yocto_git:`AUH source repository </auto-upgrade-helper/tree/>`.
  2394. Read through the sample file and make configurations as needed. For
  2395. example, if you enabled build history in your ``local.conf`` as
  2396. described earlier, you must enable it in ``upgrade-helper.conf``.
  2397. Also, if you are using the default ``maintainers.inc`` file supplied
  2398. with Poky and located in ``meta-yocto`` and you do not set a
  2399. "maintainers_whitelist" or "global_maintainer_override" in the
  2400. ``upgrade-helper.conf`` configuration, and you specify "-e all" on
  2401. the AUH command-line, the utility automatically sends out emails to
  2402. all the default maintainers. Please avoid this.
  2403. This next set of examples describes how to use the AUH:
  2404. - *Upgrading a Specific Recipe:* To upgrade a specific recipe, use the
  2405. following form:
  2406. ::
  2407. $ upgrade-helper.py recipe_name
  2408. For example, this command upgrades the ``xmodmap`` recipe:
  2409. ::
  2410. $ upgrade-helper.py xmodmap
  2411. - *Upgrading a Specific Recipe to a Particular Version:* To upgrade a
  2412. specific recipe to a particular version, use the following form:
  2413. ::
  2414. $ upgrade-helper.py recipe_name -t version
  2415. For example, this command upgrades the ``xmodmap`` recipe to version 1.2.3:
  2416. ::
  2417. $ upgrade-helper.py xmodmap -t 1.2.3
  2418. - *Upgrading all Recipes to the Latest Versions and Suppressing Email
  2419. Notifications:* To upgrade all recipes to their most recent versions
  2420. and suppress the email notifications, use the following command:
  2421. ::
  2422. $ upgrade-helper.py all
  2423. - *Upgrading all Recipes to the Latest Versions and Send Email
  2424. Notifications:* To upgrade all recipes to their most recent versions
  2425. and send email messages to maintainers for each attempted recipe as
  2426. well as a status email, use the following command:
  2427. ::
  2428. $ upgrade-helper.py -e all
  2429. Once you have run the AUH utility, you can find the results in the AUH
  2430. build directory:
  2431. ::
  2432. ${BUILDDIR}/upgrade-helper/timestamp
  2433. The AUH utility
  2434. also creates recipe update commits from successful upgrade attempts in
  2435. the layer tree.
  2436. You can easily set up to run the AUH utility on a regular basis by using
  2437. a cron job. See the
  2438. :yocto_git:`weeklyjob.sh </auto-upgrade-helper/tree/weeklyjob.sh>`
  2439. file distributed with the utility for an example.
  2440. Using ``devtool upgrade``
  2441. -------------------------
  2442. As mentioned earlier, an alternative method for upgrading recipes to
  2443. newer versions is to use
  2444. :doc:`devtool upgrade </ref-manual/ref-devtool-reference>`.
  2445. You can read about ``devtool upgrade`` in general in the
  2446. ":ref:`sdk-manual/sdk-extensible:use \`\`devtool upgrade\`\` to create a version of the recipe that supports a newer version of the software`"
  2447. section in the Yocto Project Application Development and the Extensible
  2448. Software Development Kit (eSDK) Manual.
  2449. To see all the command-line options available with ``devtool upgrade``,
  2450. use the following help command:
  2451. ::
  2452. $ devtool upgrade -h
  2453. If you want to find out what version a recipe is currently at upstream
  2454. without any attempt to upgrade your local version of the recipe, you can
  2455. use the following command:
  2456. ::
  2457. $ devtool latest-version recipe_name
  2458. As mentioned in the previous section describing AUH, ``devtool upgrade``
  2459. works in a less-automated manner than AUH. Specifically,
  2460. ``devtool upgrade`` only works on a single recipe that you name on the
  2461. command line, cannot perform build and integration testing using images,
  2462. and does not automatically generate commits for changes in the source
  2463. tree. Despite all these "limitations", ``devtool upgrade`` updates the
  2464. recipe file to the new upstream version and attempts to rebase custom
  2465. patches contained by the recipe as needed.
  2466. .. note::
  2467. AUH uses much of ``devtool upgrade`` behind the scenes making AUH somewhat
  2468. of a "wrapper" application for ``devtool upgrade``.
  2469. A typical scenario involves having used Git to clone an upstream
  2470. repository that you use during build operations. Because you have built the
  2471. recipe in the past, the layer is likely added to your
  2472. configuration already. If for some reason, the layer is not added, you
  2473. could add it easily using the
  2474. ":ref:`bitbake-layers <bsp-guide/bsp:creating a new bsp layer using the \`\`bitbake-layers\`\` script>`"
  2475. script. For example, suppose you use the ``nano.bb`` recipe from the
  2476. ``meta-oe`` layer in the ``meta-openembedded`` repository. For this
  2477. example, assume that the layer has been cloned into following area:
  2478. ::
  2479. /home/scottrif/meta-openembedded
  2480. The following command from your
  2481. :term:`Build Directory` adds the layer to
  2482. your build configuration (i.e. ``${BUILDDIR}/conf/bblayers.conf``):
  2483. ::
  2484. $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe
  2485. NOTE: Starting bitbake server...
  2486. Parsing recipes: 100% |##########################################| Time: 0:00:55
  2487. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  2488. Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00
  2489. Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00
  2490. Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00
  2491. Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00
  2492. For this example, assume that the ``nano.bb`` recipe that
  2493. is upstream has a 2.9.3 version number. However, the version in the
  2494. local repository is 2.7.4. The following command from your build
  2495. directory automatically upgrades the recipe for you:
  2496. .. note::
  2497. Using the ``-V`` option is not necessary. Omitting the version number causes
  2498. ``devtool upgrade`` to upgrade the recipe to the most recent version.
  2499. ::
  2500. $ devtool upgrade nano -V 2.9.3
  2501. NOTE: Starting bitbake server...
  2502. NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace
  2503. Parsing recipes: 100% |##########################################| Time: 0:00:46
  2504. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  2505. NOTE: Extracting current version source...
  2506. NOTE: Resolving any missing task queue dependencies
  2507. .
  2508. .
  2509. .
  2510. NOTE: Executing SetScene Tasks
  2511. NOTE: Executing RunQueue Tasks
  2512. NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded.
  2513. Adding changed files: 100% |#####################################| Time: 0:00:00
  2514. NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano
  2515. NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb
  2516. Continuing with this example, you can use ``devtool build`` to build the
  2517. newly upgraded recipe:
  2518. ::
  2519. $ devtool build nano
  2520. NOTE: Starting bitbake server...
  2521. Loading cache: 100% |################################################################################################| Time: 0:00:01
  2522. Loaded 2040 entries from dependency cache.
  2523. Parsing recipes: 100% |##############################################################################################| Time: 0:00:00
  2524. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  2525. NOTE: Resolving any missing task queue dependencies
  2526. .
  2527. .
  2528. .
  2529. NOTE: Executing SetScene Tasks
  2530. NOTE: Executing RunQueue Tasks
  2531. NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano
  2532. NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded.
  2533. Within the ``devtool upgrade`` workflow, opportunity
  2534. exists to deploy and test your rebuilt software. For this example,
  2535. however, running ``devtool finish`` cleans up the workspace once the
  2536. source in your workspace is clean. This usually means using Git to stage
  2537. and submit commits for the changes generated by the upgrade process.
  2538. Once the tree is clean, you can clean things up in this example with the
  2539. following command from the ``${BUILDDIR}/workspace/sources/nano``
  2540. directory:
  2541. ::
  2542. $ devtool finish nano meta-oe
  2543. NOTE: Starting bitbake server...
  2544. Loading cache: 100% |################################################################################################| Time: 0:00:00
  2545. Loaded 2040 entries from dependency cache.
  2546. Parsing recipes: 100% |##############################################################################################| Time: 0:00:01
  2547. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  2548. NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch
  2549. NOTE: Updating recipe nano_2.9.3.bb
  2550. NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb
  2551. NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano
  2552. NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually
  2553. Using the ``devtool finish`` command cleans up the workspace and creates a patch
  2554. file based on your commits. The tool puts all patch files back into the
  2555. source directory in a sub-directory named ``nano`` in this case.
  2556. Manually Upgrading a Recipe
  2557. ---------------------------
  2558. If for some reason you choose not to upgrade recipes using
  2559. :ref:`dev-manual/common-tasks:Using the Auto Upgrade Helper (AUH)` or
  2560. by :ref:`dev-manual/common-tasks:Using \`\`devtool upgrade\`\``,
  2561. you can manually edit the recipe files to upgrade the versions.
  2562. .. note::
  2563. Manually updating multiple recipes scales poorly and involves many
  2564. steps. The recommendation to upgrade recipe versions is through AUH
  2565. or ``devtool upgrade``, both of which automate some steps and provide
  2566. guidance for others needed for the manual process.
  2567. To manually upgrade recipe versions, follow these general steps:
  2568. 1. *Change the Version:* Rename the recipe such that the version (i.e.
  2569. the :term:`PV` part of the recipe name)
  2570. changes appropriately. If the version is not part of the recipe name,
  2571. change the value as it is set for ``PV`` within the recipe itself.
  2572. 2. *Update* ``SRCREV`` *if Needed*: If the source code your recipe builds
  2573. is fetched from Git or some other version control system, update
  2574. :term:`SRCREV` to point to the
  2575. commit hash that matches the new version.
  2576. 3. *Build the Software:* Try to build the recipe using BitBake. Typical
  2577. build failures include the following:
  2578. - License statements were updated for the new version. For this
  2579. case, you need to review any changes to the license and update the
  2580. values of :term:`LICENSE` and
  2581. :term:`LIC_FILES_CHKSUM`
  2582. as needed.
  2583. .. note::
  2584. License changes are often inconsequential. For example, the
  2585. license text's copyright year might have changed.
  2586. - Custom patches carried by the older version of the recipe might
  2587. fail to apply to the new version. For these cases, you need to
  2588. review the failures. Patches might not be necessary for the new
  2589. version of the software if the upgraded version has fixed those
  2590. issues. If a patch is necessary and failing, you need to rebase it
  2591. into the new version.
  2592. 4. *Optionally Attempt to Build for Several Architectures:* Once you
  2593. successfully build the new software for a given architecture, you
  2594. could test the build for other architectures by changing the
  2595. :term:`MACHINE` variable and
  2596. rebuilding the software. This optional step is especially important
  2597. if the recipe is to be released publicly.
  2598. 5. *Check the Upstream Change Log or Release Notes:* Checking both these
  2599. reveals if new features exist that could break
  2600. backwards-compatibility. If so, you need to take steps to mitigate or
  2601. eliminate that situation.
  2602. 6. *Optionally Create a Bootable Image and Test:* If you want, you can
  2603. test the new software by booting it onto actual hardware.
  2604. 7. *Create a Commit with the Change in the Layer Repository:* After all
  2605. builds work and any testing is successful, you can create commits for
  2606. any changes in the layer holding your upgraded recipe.
  2607. Finding Temporary Source Code
  2608. =============================
  2609. You might find it helpful during development to modify the temporary
  2610. source code used by recipes to build packages. For example, suppose you
  2611. are developing a patch and you need to experiment a bit to figure out
  2612. your solution. After you have initially built the package, you can
  2613. iteratively tweak the source code, which is located in the
  2614. :term:`Build Directory`, and then you can
  2615. force a re-compile and quickly test your altered code. Once you settle
  2616. on a solution, you can then preserve your changes in the form of
  2617. patches.
  2618. During a build, the unpacked temporary source code used by recipes to
  2619. build packages is available in the Build Directory as defined by the
  2620. :term:`S` variable. Below is the default
  2621. value for the ``S`` variable as defined in the
  2622. ``meta/conf/bitbake.conf`` configuration file in the
  2623. :term:`Source Directory`:
  2624. ::
  2625. S = "${WORKDIR}/${BP}"
  2626. You should be aware that many recipes override the
  2627. ``S`` variable. For example, recipes that fetch their source from Git
  2628. usually set ``S`` to ``${WORKDIR}/git``.
  2629. .. note::
  2630. The :term:`BP` represents the base recipe name, which consists of the name
  2631. and version:
  2632. ::
  2633. BP = "${BPN}-${PV}"
  2634. The path to the work directory for the recipe
  2635. (:term:`WORKDIR`) is defined as
  2636. follows:
  2637. ::
  2638. ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
  2639. The actual directory depends on several things:
  2640. - :term:`TMPDIR`: The top-level build
  2641. output directory.
  2642. - :term:`MULTIMACH_TARGET_SYS`:
  2643. The target system identifier.
  2644. - :term:`PN`: The recipe name.
  2645. - :term:`EXTENDPE`: The epoch - (if
  2646. :term:`PE` is not specified, which is
  2647. usually the case for most recipes, then ``EXTENDPE`` is blank).
  2648. - :term:`PV`: The recipe version.
  2649. - :term:`PR`: The recipe revision.
  2650. As an example, assume a Source Directory top-level folder named
  2651. ``poky``, a default Build Directory at ``poky/build``, and a
  2652. ``qemux86-poky-linux`` machine target system. Furthermore, suppose your
  2653. recipe is named ``foo_1.3.0.bb``. In this case, the work directory the
  2654. build system uses to build the package would be as follows:
  2655. ::
  2656. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  2657. Using Quilt in Your Workflow
  2658. ============================
  2659. `Quilt <https://savannah.nongnu.org/projects/quilt>`__ is a powerful tool
  2660. that allows you to capture source code changes without having a clean
  2661. source tree. This section outlines the typical workflow you can use to
  2662. modify source code, test changes, and then preserve the changes in the
  2663. form of a patch all using Quilt.
  2664. .. note::
  2665. With regard to preserving changes to source files, if you clean a
  2666. recipe or have ``rm_work`` enabled, the
  2667. :ref:`devtool workflow <sdk-manual/sdk-extensible:using \`\`devtool\`\` in your sdk workflow>`
  2668. as described in the Yocto Project Application Development and the
  2669. Extensible Software Development Kit (eSDK) manual is a safer
  2670. development flow than the flow that uses Quilt.
  2671. Follow these general steps:
  2672. 1. *Find the Source Code:* Temporary source code used by the
  2673. OpenEmbedded build system is kept in the
  2674. :term:`Build Directory`. See the
  2675. "`Finding Temporary Source
  2676. Code <#finding-the-temporary-source-code>`__" section to learn how to
  2677. locate the directory that has the temporary source code for a
  2678. particular package.
  2679. 2. *Change Your Working Directory:* You need to be in the directory that
  2680. has the temporary source code. That directory is defined by the
  2681. :term:`S` variable.
  2682. 3. *Create a New Patch:* Before modifying source code, you need to
  2683. create a new patch. To create a new patch file, use ``quilt new`` as
  2684. below:
  2685. ::
  2686. $ quilt new my_changes.patch
  2687. 4. *Notify Quilt and Add Files:* After creating the patch, you need to
  2688. notify Quilt about the files you plan to edit. You notify Quilt by
  2689. adding the files to the patch you just created:
  2690. ::
  2691. $ quilt add file1.c file2.c file3.c
  2692. 5. *Edit the Files:* Make your changes in the source code to the files
  2693. you added to the patch.
  2694. 6. *Test Your Changes:* Once you have modified the source code, the
  2695. easiest way to test your changes is by calling the ``do_compile``
  2696. task as shown in the following example:
  2697. ::
  2698. $ bitbake -c compile -f package
  2699. The ``-f`` or ``--force`` option forces the specified task to
  2700. execute. If you find problems with your code, you can just keep
  2701. editing and re-testing iteratively until things work as expected.
  2702. .. note::
  2703. All the modifications you make to the temporary source code disappear
  2704. once you run the ``do_clean`` or ``do_cleanall`` tasks using BitBake
  2705. (i.e. ``bitbake -c clean package`` and ``bitbake -c cleanall package``).
  2706. Modifications will also disappear if you use the ``rm_work`` feature as
  2707. described in the
  2708. ":ref:`dev-manual/common-tasks:conserving disk space during builds`"
  2709. section.
  2710. 7. *Generate the Patch:* Once your changes work as expected, you need to
  2711. use Quilt to generate the final patch that contains all your
  2712. modifications.
  2713. ::
  2714. $ quilt refresh
  2715. At this point, the
  2716. ``my_changes.patch`` file has all your edits made to the ``file1.c``,
  2717. ``file2.c``, and ``file3.c`` files.
  2718. You can find the resulting patch file in the ``patches/``
  2719. subdirectory of the source (``S``) directory.
  2720. 8. *Copy the Patch File:* For simplicity, copy the patch file into a
  2721. directory named ``files``, which you can create in the same directory
  2722. that holds the recipe (``.bb``) file or the append (``.bbappend``)
  2723. file. Placing the patch here guarantees that the OpenEmbedded build
  2724. system will find the patch. Next, add the patch into the ``SRC_URI``
  2725. of the recipe. Here is an example:
  2726. ::
  2727. SRC_URI += "file://my_changes.patch"
  2728. Using a Development Shell
  2729. =========================
  2730. When debugging certain commands or even when just editing packages,
  2731. ``devshell`` can be a useful tool. When you invoke ``devshell``, all
  2732. tasks up to and including
  2733. :ref:`ref-tasks-patch` are run for the
  2734. specified target. Then, a new terminal is opened and you are placed in
  2735. ``${``\ :term:`S`\ ``}``, the source
  2736. directory. In the new terminal, all the OpenEmbedded build-related
  2737. environment variables are still defined so you can use commands such as
  2738. ``configure`` and ``make``. The commands execute just as if the
  2739. OpenEmbedded build system were executing them. Consequently, working
  2740. this way can be helpful when debugging a build or preparing software to
  2741. be used with the OpenEmbedded build system.
  2742. Following is an example that uses ``devshell`` on a target named
  2743. ``matchbox-desktop``:
  2744. ::
  2745. $ bitbake matchbox-desktop -c devshell
  2746. This command spawns a terminal with a shell prompt within the
  2747. OpenEmbedded build environment. The
  2748. :term:`OE_TERMINAL` variable
  2749. controls what type of shell is opened.
  2750. For spawned terminals, the following occurs:
  2751. - The ``PATH`` variable includes the cross-toolchain.
  2752. - The ``pkgconfig`` variables find the correct ``.pc`` files.
  2753. - The ``configure`` command finds the Yocto Project site files as well
  2754. as any other necessary files.
  2755. Within this environment, you can run configure or compile commands as if
  2756. they were being run by the OpenEmbedded build system itself. As noted
  2757. earlier, the working directory also automatically changes to the Source
  2758. Directory (:term:`S`).
  2759. To manually run a specific task using ``devshell``, run the
  2760. corresponding ``run.*`` script in the
  2761. ``${``\ :term:`WORKDIR`\ ``}/temp``
  2762. directory (e.g., ``run.do_configure.``\ `pid`). If a task's script does
  2763. not exist, which would be the case if the task was skipped by way of the
  2764. sstate cache, you can create the task by first running it outside of the
  2765. ``devshell``:
  2766. ::
  2767. $ bitbake -c task
  2768. .. note::
  2769. - Execution of a task's ``run.*`` script and BitBake's execution of
  2770. a task are identical. In other words, running the script re-runs
  2771. the task just as it would be run using the ``bitbake -c`` command.
  2772. - Any ``run.*`` file that does not have a ``.pid`` extension is a
  2773. symbolic link (symlink) to the most recent version of that file.
  2774. Remember, that the ``devshell`` is a mechanism that allows you to get
  2775. into the BitBake task execution environment. And as such, all commands
  2776. must be called just as BitBake would call them. That means you need to
  2777. provide the appropriate options for cross-compilation and so forth as
  2778. applicable.
  2779. When you are finished using ``devshell``, exit the shell or close the
  2780. terminal window.
  2781. .. note::
  2782. - It is worth remembering that when using ``devshell`` you need to
  2783. use the full compiler name such as ``arm-poky-linux-gnueabi-gcc``
  2784. instead of just using ``gcc``. The same applies to other
  2785. applications such as ``binutils``, ``libtool`` and so forth.
  2786. BitBake sets up environment variables such as ``CC`` to assist
  2787. applications, such as ``make`` to find the correct tools.
  2788. - It is also worth noting that ``devshell`` still works over X11
  2789. forwarding and similar situations.
  2790. Using a Development Python Shell
  2791. ================================
  2792. Similar to working within a development shell as described in the
  2793. previous section, you can also spawn and work within an interactive
  2794. Python development shell. When debugging certain commands or even when
  2795. just editing packages, ``devpyshell`` can be a useful tool. When you
  2796. invoke ``devpyshell``, all tasks up to and including
  2797. :ref:`ref-tasks-patch` are run for the
  2798. specified target. Then a new terminal is opened. Additionally, key
  2799. Python objects and code are available in the same way they are to
  2800. BitBake tasks, in particular, the data store 'd'. So, commands such as
  2801. the following are useful when exploring the data store and running
  2802. functions:
  2803. ::
  2804. pydevshell> d.getVar("STAGING_DIR")
  2805. '/media/build1/poky/build/tmp/sysroots'
  2806. pydevshell> d.getVar("STAGING_DIR")
  2807. '${TMPDIR}/sysroots'
  2808. pydevshell> d.setVar("FOO", "bar")
  2809. pydevshell> d.getVar("FOO")
  2810. 'bar'
  2811. pydevshell> d.delVar("FOO")
  2812. pydevshell> d.getVar("FOO")
  2813. pydevshell> bb.build.exec_func("do_unpack", d)
  2814. pydevshell>
  2815. The commands execute just as if the OpenEmbedded build
  2816. system were executing them. Consequently, working this way can be
  2817. helpful when debugging a build or preparing software to be used with the
  2818. OpenEmbedded build system.
  2819. Following is an example that uses ``devpyshell`` on a target named
  2820. ``matchbox-desktop``:
  2821. ::
  2822. $ bitbake matchbox-desktop -c devpyshell
  2823. This command spawns a terminal and places you in an interactive Python
  2824. interpreter within the OpenEmbedded build environment. The
  2825. :term:`OE_TERMINAL` variable
  2826. controls what type of shell is opened.
  2827. When you are finished using ``devpyshell``, you can exit the shell
  2828. either by using Ctrl+d or closing the terminal window.
  2829. Building
  2830. ========
  2831. This section describes various build procedures. For example, the steps
  2832. needed for a simple build, a target that uses multiple configurations,
  2833. building an image for more than one machine, and so forth.
  2834. Building a Simple Image
  2835. -----------------------
  2836. In the development environment, you need to build an image whenever you
  2837. change hardware support, add or change system libraries, or add or
  2838. change services that have dependencies. Several methods exist that allow
  2839. you to build an image within the Yocto Project. This section presents
  2840. the basic steps you need to build a simple image using BitBake from a
  2841. build host running Linux.
  2842. .. note::
  2843. - For information on how to build an image using
  2844. :term:`Toaster`, see the
  2845. :doc:`/toaster-manual/index`.
  2846. - For information on how to use ``devtool`` to build images, see the
  2847. ":ref:`sdk-manual/sdk-extensible:using \`\`devtool\`\` in your sdk workflow`"
  2848. section in the Yocto Project Application Development and the
  2849. Extensible Software Development Kit (eSDK) manual.
  2850. - For a quick example on how to build an image using the
  2851. OpenEmbedded build system, see the
  2852. :doc:`/brief-yoctoprojectqs/index` document.
  2853. The build process creates an entire Linux distribution from source and
  2854. places it in your :term:`Build Directory` under
  2855. ``tmp/deploy/images``. For detailed information on the build process
  2856. using BitBake, see the ":ref:`overview-manual/overview-manual-concepts:images`" section in the
  2857. Yocto Project Overview and Concepts Manual.
  2858. The following figure and list overviews the build process:
  2859. .. image:: figures/bitbake-build-flow.png
  2860. :align: center
  2861. 1. *Set up Your Host Development System to Support Development Using the
  2862. Yocto Project*: See the ":doc:`start`" section for options on how to get a
  2863. build host ready to use the Yocto Project.
  2864. 2. *Initialize the Build Environment:* Initialize the build environment
  2865. by sourcing the build environment script (i.e.
  2866. :ref:`structure-core-script`):
  2867. ::
  2868. $ source oe-init-build-env [build_dir]
  2869. When you use the initialization script, the OpenEmbedded build system
  2870. uses ``build`` as the default :term:`Build Directory` in your current work
  2871. directory. You can use a `build_dir` argument with the script to
  2872. specify a different build directory.
  2873. .. note::
  2874. A common practice is to use a different Build Directory for
  2875. different targets. For example, ``~/build/x86`` for a ``qemux86``
  2876. target, and ``~/build/arm`` for a ``qemuarm`` target.
  2877. 3. *Make Sure Your* ``local.conf`` *File is Correct*: Ensure the
  2878. ``conf/local.conf`` configuration file, which is found in the Build
  2879. Directory, is set up how you want it. This file defines many aspects
  2880. of the build environment including the target machine architecture
  2881. through the ``MACHINE`` variable, the packaging format used during
  2882. the build
  2883. (:term:`PACKAGE_CLASSES`),
  2884. and a centralized tarball download directory through the
  2885. :term:`DL_DIR` variable.
  2886. 4. *Build the Image:* Build the image using the ``bitbake`` command:
  2887. ::
  2888. $ bitbake target
  2889. .. note::
  2890. For information on BitBake, see the :doc:`bitbake:index`.
  2891. The target is the name of the recipe you want to build. Common
  2892. targets are the images in ``meta/recipes-core/images``,
  2893. ``meta/recipes-sato/images``, and so forth all found in the
  2894. :term:`Source Directory`. Or, the target
  2895. can be the name of a recipe for a specific piece of software such as
  2896. BusyBox. For more details about the images the OpenEmbedded build
  2897. system supports, see the
  2898. ":ref:`ref-manual/ref-images:Images`" chapter in the Yocto
  2899. Project Reference Manual.
  2900. As an example, the following command builds the
  2901. ``core-image-minimal`` image:
  2902. ::
  2903. $ bitbake core-image-minimal
  2904. Once an
  2905. image has been built, it often needs to be installed. The images and
  2906. kernels built by the OpenEmbedded build system are placed in the
  2907. Build Directory in ``tmp/deploy/images``. For information on how to
  2908. run pre-built images such as ``qemux86`` and ``qemuarm``, see the
  2909. :doc:`/sdk-manual/index` manual. For
  2910. information about how to install these images, see the documentation
  2911. for your particular board or machine.
  2912. Building Images for Multiple Targets Using Multiple Configurations
  2913. ------------------------------------------------------------------
  2914. You can use a single ``bitbake`` command to build multiple images or
  2915. packages for different targets where each image or package requires a
  2916. different configuration (multiple configuration builds). The builds, in
  2917. this scenario, are sometimes referred to as "multiconfigs", and this
  2918. section uses that term throughout.
  2919. This section describes how to set up for multiple configuration builds
  2920. and how to account for cross-build dependencies between the
  2921. multiconfigs.
  2922. Setting Up and Running a Multiple Configuration Build
  2923. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2924. To accomplish a multiple configuration build, you must define each
  2925. target's configuration separately using a parallel configuration file in
  2926. the :term:`Build Directory`, and you
  2927. must follow a required file hierarchy. Additionally, you must enable the
  2928. multiple configuration builds in your ``local.conf`` file.
  2929. Follow these steps to set up and execute multiple configuration builds:
  2930. - *Create Separate Configuration Files*: You need to create a single
  2931. configuration file for each build target (each multiconfig).
  2932. Minimally, each configuration file must define the machine and the
  2933. temporary directory BitBake uses for the build. Suggested practice
  2934. dictates that you do not overlap the temporary directories used
  2935. during the builds. However, it is possible that you can share the
  2936. temporary directory
  2937. (:term:`TMPDIR`). For example,
  2938. consider a scenario with two different multiconfigs for the same
  2939. :term:`MACHINE`: "qemux86" built
  2940. for two distributions such as "poky" and "poky-lsb". In this case,
  2941. you might want to use the same ``TMPDIR``.
  2942. Here is an example showing the minimal statements needed in a
  2943. configuration file for a "qemux86" target whose temporary build
  2944. directory is ``tmpmultix86``:
  2945. ::
  2946. MACHINE = "qemux86"
  2947. TMPDIR = "${TOPDIR}/tmpmultix86"
  2948. The location for these multiconfig configuration files is specific.
  2949. They must reside in the current build directory in a sub-directory of
  2950. ``conf`` named ``multiconfig``. Following is an example that defines
  2951. two configuration files for the "x86" and "arm" multiconfigs:
  2952. .. image:: figures/multiconfig_files.png
  2953. :align: center
  2954. The reason for this required file hierarchy is because the ``BBPATH``
  2955. variable is not constructed until the layers are parsed.
  2956. Consequently, using the configuration file as a pre-configuration
  2957. file is not possible unless it is located in the current working
  2958. directory.
  2959. - *Add the BitBake Multi-configuration Variable to the Local
  2960. Configuration File*: Use the
  2961. :term:`BBMULTICONFIG`
  2962. variable in your ``conf/local.conf`` configuration file to specify
  2963. each multiconfig. Continuing with the example from the previous
  2964. figure, the ``BBMULTICONFIG`` variable needs to enable two
  2965. multiconfigs: "x86" and "arm" by specifying each configuration file:
  2966. ::
  2967. BBMULTICONFIG = "x86 arm"
  2968. .. note::
  2969. A "default" configuration already exists by definition. This
  2970. configuration is named: "" (i.e. empty string) and is defined by
  2971. the variables coming from your ``local.conf``
  2972. file. Consequently, the previous example actually adds two
  2973. additional configurations to your build: "arm" and "x86" along
  2974. with "".
  2975. - *Launch BitBake*: Use the following BitBake command form to launch
  2976. the multiple configuration build:
  2977. ::
  2978. $ bitbake [mc:multiconfigname:]target [[[mc:multiconfigname:]target] ... ]
  2979. For the example in this section, the following command applies:
  2980. ::
  2981. $ bitbake mc:x86:core-image-minimal mc:arm:core-image-sato mc::core-image-base
  2982. The previous BitBake command builds a ``core-image-minimal`` image
  2983. that is configured through the ``x86.conf`` configuration file, a
  2984. ``core-image-sato`` image that is configured through the ``arm.conf``
  2985. configuration file and a ``core-image-base`` that is configured
  2986. through your ``local.conf`` configuration file.
  2987. .. note::
  2988. Support for multiple configuration builds in the Yocto Project &DISTRO;
  2989. (&DISTRO_NAME;) Release does not include Shared State (sstate)
  2990. optimizations. Consequently, if a build uses the same object twice
  2991. in, for example, two different ``TMPDIR``
  2992. directories, the build either loads from an existing sstate cache for
  2993. that build at the start or builds the object fresh.
  2994. Enabling Multiple Configuration Build Dependencies
  2995. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2996. Sometimes dependencies can exist between targets (multiconfigs) in a
  2997. multiple configuration build. For example, suppose that in order to
  2998. build a ``core-image-sato`` image for an "x86" multiconfig, the root
  2999. filesystem of an "arm" multiconfig must exist. This dependency is
  3000. essentially that the
  3001. :ref:`ref-tasks-image` task in the
  3002. ``core-image-sato`` recipe depends on the completion of the
  3003. :ref:`ref-tasks-rootfs` task of the
  3004. ``core-image-minimal`` recipe.
  3005. To enable dependencies in a multiple configuration build, you must
  3006. declare the dependencies in the recipe using the following statement
  3007. form:
  3008. ::
  3009. task_or_package[mcdepends] = "mc:from_multiconfig:to_multiconfig:recipe_name:task_on_which_to_depend"
  3010. To better show how to use this statement, consider the example scenario
  3011. from the first paragraph of this section. The following statement needs
  3012. to be added to the recipe that builds the ``core-image-sato`` image:
  3013. ::
  3014. do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_rootfs"
  3015. In this example, the `from_multiconfig` is "x86". The `to_multiconfig` is "arm". The
  3016. task on which the ``do_image`` task in the recipe depends is the
  3017. ``do_rootfs`` task from the ``core-image-minimal`` recipe associated
  3018. with the "arm" multiconfig.
  3019. Once you set up this dependency, you can build the "x86" multiconfig
  3020. using a BitBake command as follows:
  3021. ::
  3022. $ bitbake mc:x86:core-image-sato
  3023. This command executes all the tasks needed to create the
  3024. ``core-image-sato`` image for the "x86" multiconfig. Because of the
  3025. dependency, BitBake also executes through the ``do_rootfs`` task for the
  3026. "arm" multiconfig build.
  3027. Having a recipe depend on the root filesystem of another build might not
  3028. seem that useful. Consider this change to the statement in the
  3029. ``core-image-sato`` recipe:
  3030. ::
  3031. do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_image"
  3032. In this case, BitBake must
  3033. create the ``core-image-minimal`` image for the "arm" build since the
  3034. "x86" build depends on it.
  3035. Because "x86" and "arm" are enabled for multiple configuration builds
  3036. and have separate configuration files, BitBake places the artifacts for
  3037. each build in the respective temporary build directories (i.e.
  3038. :term:`TMPDIR`).
  3039. Building an Initial RAM Filesystem (initramfs) Image
  3040. ----------------------------------------------------
  3041. An initial RAM filesystem (initramfs) image provides a temporary root
  3042. filesystem used for early system initialization (e.g. loading of modules
  3043. needed to locate and mount the "real" root filesystem).
  3044. .. note::
  3045. The initramfs image is the successor of initial RAM disk (initrd). It
  3046. is a "copy in and out" (cpio) archive of the initial filesystem that
  3047. gets loaded into memory during the Linux startup process. Because
  3048. Linux uses the contents of the archive during initialization, the
  3049. initramfs image needs to contain all of the device drivers and tools
  3050. needed to mount the final root filesystem.
  3051. Follow these steps to create an initramfs image:
  3052. 1. *Create the initramfs Image Recipe:* You can reference the
  3053. ``core-image-minimal-initramfs.bb`` recipe found in the
  3054. ``meta/recipes-core`` directory of the :term:`Source Directory`
  3055. as an example
  3056. from which to work.
  3057. 2. *Decide if You Need to Bundle the initramfs Image Into the Kernel
  3058. Image:* If you want the initramfs image that is built to be bundled
  3059. in with the kernel image, set the
  3060. :term:`INITRAMFS_IMAGE_BUNDLE`
  3061. variable to "1" in your ``local.conf`` configuration file and set the
  3062. :term:`INITRAMFS_IMAGE`
  3063. variable in the recipe that builds the kernel image.
  3064. .. note::
  3065. It is recommended that you do bundle the initramfs image with the
  3066. kernel image to avoid circular dependencies between the kernel
  3067. recipe and the initramfs recipe should the initramfs image include
  3068. kernel modules.
  3069. Setting the ``INITRAMFS_IMAGE_BUNDLE`` flag causes the initramfs
  3070. image to be unpacked into the ``${B}/usr/`` directory. The unpacked
  3071. initramfs image is then passed to the kernel's ``Makefile`` using the
  3072. :term:`CONFIG_INITRAMFS_SOURCE`
  3073. variable, allowing the initramfs image to be built into the kernel
  3074. normally.
  3075. .. note::
  3076. If you choose to not bundle the initramfs image with the kernel
  3077. image, you are essentially using an
  3078. `Initial RAM Disk (initrd) <https://en.wikipedia.org/wiki/Initrd>`__.
  3079. Creating an initrd is handled primarily through the :term:`INITRD_IMAGE`,
  3080. ``INITRD_LIVE``, and ``INITRD_IMAGE_LIVE`` variables. For more
  3081. information, see the :ref:`ref-classes-image-live` file.
  3082. 3. *Optionally Add Items to the initramfs Image Through the initramfs
  3083. Image Recipe:* If you add items to the initramfs image by way of its
  3084. recipe, you should use
  3085. :term:`PACKAGE_INSTALL`
  3086. rather than
  3087. :term:`IMAGE_INSTALL`.
  3088. ``PACKAGE_INSTALL`` gives more direct control of what is added to the
  3089. image as compared to the defaults you might not necessarily want that
  3090. are set by the :ref:`image <ref-classes-image>`
  3091. or :ref:`core-image <ref-classes-core-image>`
  3092. classes.
  3093. 4. *Build the Kernel Image and the initramfs Image:* Build your kernel
  3094. image using BitBake. Because the initramfs image recipe is a
  3095. dependency of the kernel image, the initramfs image is built as well
  3096. and bundled with the kernel image if you used the
  3097. :term:`INITRAMFS_IMAGE_BUNDLE`
  3098. variable described earlier.
  3099. Building a Tiny System
  3100. ----------------------
  3101. Very small distributions have some significant advantages such as
  3102. requiring less on-die or in-package memory (cheaper), better performance
  3103. through efficient cache usage, lower power requirements due to less
  3104. memory, faster boot times, and reduced development overhead. Some
  3105. real-world examples where a very small distribution gives you distinct
  3106. advantages are digital cameras, medical devices, and small headless
  3107. systems.
  3108. This section presents information that shows you how you can trim your
  3109. distribution to even smaller sizes than the ``poky-tiny`` distribution,
  3110. which is around 5 Mbytes, that can be built out-of-the-box using the
  3111. Yocto Project.
  3112. Tiny System Overview
  3113. ~~~~~~~~~~~~~~~~~~~~
  3114. The following list presents the overall steps you need to consider and
  3115. perform to create distributions with smaller root filesystems, achieve
  3116. faster boot times, maintain your critical functionality, and avoid
  3117. initial RAM disks:
  3118. - `Determine your goals and guiding
  3119. principles. <#goals-and-guiding-principles>`__
  3120. - `Understand what contributes to your image
  3121. size. <#understand-what-gives-your-image-size>`__
  3122. - `Reduce the size of the root
  3123. filesystem. <#trim-the-root-filesystem>`__
  3124. - `Reduce the size of the kernel. <#trim-the-kernel>`__
  3125. - `Eliminate packaging
  3126. requirements. <#remove-package-management-requirements>`__
  3127. - `Look for other ways to minimize
  3128. size. <#look-for-other-ways-to-minimize-size>`__
  3129. - `Iterate on the process. <#iterate-on-the-process>`__
  3130. Goals and Guiding Principles
  3131. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3132. Before you can reach your destination, you need to know where you are
  3133. going. Here is an example list that you can use as a guide when creating
  3134. very small distributions:
  3135. - Determine how much space you need (e.g. a kernel that is 1 Mbyte or
  3136. less and a root filesystem that is 3 Mbytes or less).
  3137. - Find the areas that are currently taking 90% of the space and
  3138. concentrate on reducing those areas.
  3139. - Do not create any difficult "hacks" to achieve your goals.
  3140. - Leverage the device-specific options.
  3141. - Work in a separate layer so that you keep changes isolated. For
  3142. information on how to create layers, see the "`Understanding and
  3143. Creating Layers <#understanding-and-creating-layers>`__" section.
  3144. Understand What Contributes to Your Image Size
  3145. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3146. It is easiest to have something to start with when creating your own
  3147. distribution. You can use the Yocto Project out-of-the-box to create the
  3148. ``poky-tiny`` distribution. Ultimately, you will want to make changes in
  3149. your own distribution that are likely modeled after ``poky-tiny``.
  3150. .. note::
  3151. To use ``poky-tiny`` in your build, set the ``DISTRO`` variable in your
  3152. ``local.conf`` file to "poky-tiny" as described in the
  3153. ":ref:`dev-manual/common-tasks:creating your own distribution`"
  3154. section.
  3155. Understanding some memory concepts will help you reduce the system size.
  3156. Memory consists of static, dynamic, and temporary memory. Static memory
  3157. is the TEXT (code), DATA (initialized data in the code), and BSS
  3158. (uninitialized data) sections. Dynamic memory represents memory that is
  3159. allocated at runtime: stacks, hash tables, and so forth. Temporary
  3160. memory is recovered after the boot process. This memory consists of
  3161. memory used for decompressing the kernel and for the ``__init__``
  3162. functions.
  3163. To help you see where you currently are with kernel and root filesystem
  3164. sizes, you can use two tools found in the :term:`Source Directory`
  3165. in the
  3166. ``scripts/tiny/`` directory:
  3167. - ``ksize.py``: Reports component sizes for the kernel build objects.
  3168. - ``dirsize.py``: Reports component sizes for the root filesystem.
  3169. This next tool and command help you organize configuration fragments and
  3170. view file dependencies in a human-readable form:
  3171. - ``merge_config.sh``: Helps you manage configuration files and
  3172. fragments within the kernel. With this tool, you can merge individual
  3173. configuration fragments together. The tool allows you to make
  3174. overrides and warns you of any missing configuration options. The
  3175. tool is ideal for allowing you to iterate on configurations, create
  3176. minimal configurations, and create configuration files for different
  3177. machines without having to duplicate your process.
  3178. The ``merge_config.sh`` script is part of the Linux Yocto kernel Git
  3179. repositories (i.e. ``linux-yocto-3.14``, ``linux-yocto-3.10``,
  3180. ``linux-yocto-3.8``, and so forth) in the ``scripts/kconfig``
  3181. directory.
  3182. For more information on configuration fragments, see the
  3183. ":ref:`kernel-dev/common:creating configuration fragments`"
  3184. section in the Yocto Project Linux Kernel Development Manual.
  3185. - ``bitbake -u taskexp -g bitbake_target``: Using the BitBake command
  3186. with these options brings up a Dependency Explorer from which you can
  3187. view file dependencies. Understanding these dependencies allows you
  3188. to make informed decisions when cutting out various pieces of the
  3189. kernel and root filesystem.
  3190. Trim the Root Filesystem
  3191. ~~~~~~~~~~~~~~~~~~~~~~~~
  3192. The root filesystem is made up of packages for booting, libraries, and
  3193. applications. To change things, you can configure how the packaging
  3194. happens, which changes the way you build them. You can also modify the
  3195. filesystem itself or select a different filesystem.
  3196. First, find out what is hogging your root filesystem by running the
  3197. ``dirsize.py`` script from your root directory:
  3198. ::
  3199. $ cd root-directory-of-image
  3200. $ dirsize.py 100000 > dirsize-100k.log
  3201. $ cat dirsize-100k.log
  3202. You can apply a filter to the script to ignore files
  3203. under a certain size. The previous example filters out any files below
  3204. 100 Kbytes. The sizes reported by the tool are uncompressed, and thus
  3205. will be smaller by a relatively constant factor in a compressed root
  3206. filesystem. When you examine your log file, you can focus on areas of
  3207. the root filesystem that take up large amounts of memory.
  3208. You need to be sure that what you eliminate does not cripple the
  3209. functionality you need. One way to see how packages relate to each other
  3210. is by using the Dependency Explorer UI with the BitBake command:
  3211. ::
  3212. $ cd image-directory
  3213. $ bitbake -u taskexp -g image
  3214. Use the interface to
  3215. select potential packages you wish to eliminate and see their dependency
  3216. relationships.
  3217. When deciding how to reduce the size, get rid of packages that result in
  3218. minimal impact on the feature set. For example, you might not need a VGA
  3219. display. Or, you might be able to get by with ``devtmpfs`` and ``mdev``
  3220. instead of ``udev``.
  3221. Use your ``local.conf`` file to make changes. For example, to eliminate
  3222. ``udev`` and ``glib``, set the following in the local configuration
  3223. file:
  3224. ::
  3225. VIRTUAL-RUNTIME_dev_manager = ""
  3226. Finally, you should consider exactly the type of root filesystem you
  3227. need to meet your needs while also reducing its size. For example,
  3228. consider ``cramfs``, ``squashfs``, ``ubifs``, ``ext2``, or an
  3229. ``initramfs`` using ``initramfs``. Be aware that ``ext3`` requires a 1
  3230. Mbyte journal. If you are okay with running read-only, you do not need
  3231. this journal.
  3232. .. note::
  3233. After each round of elimination, you need to rebuild your system and
  3234. then use the tools to see the effects of your reductions.
  3235. Trim the Kernel
  3236. ~~~~~~~~~~~~~~~
  3237. The kernel is built by including policies for hardware-independent
  3238. aspects. What subsystems do you enable? For what architecture are you
  3239. building? Which drivers do you build by default?
  3240. .. note::
  3241. You can modify the kernel source if you want to help with boot time.
  3242. Run the ``ksize.py`` script from the top-level Linux build directory to
  3243. get an idea of what is making up the kernel:
  3244. ::
  3245. $ cd top-level-linux-build-directory
  3246. $ ksize.py > ksize.log
  3247. $ cat ksize.log
  3248. When you examine the log, you will see how much space is taken up with
  3249. the built-in ``.o`` files for drivers, networking, core kernel files,
  3250. filesystem, sound, and so forth. The sizes reported by the tool are
  3251. uncompressed, and thus will be smaller by a relatively constant factor
  3252. in a compressed kernel image. Look to reduce the areas that are large
  3253. and taking up around the "90% rule."
  3254. To examine, or drill down, into any particular area, use the ``-d``
  3255. option with the script:
  3256. ::
  3257. $ ksize.py -d > ksize.log
  3258. Using this option
  3259. breaks out the individual file information for each area of the kernel
  3260. (e.g. drivers, networking, and so forth).
  3261. Use your log file to see what you can eliminate from the kernel based on
  3262. features you can let go. For example, if you are not going to need
  3263. sound, you do not need any drivers that support sound.
  3264. After figuring out what to eliminate, you need to reconfigure the kernel
  3265. to reflect those changes during the next build. You could run
  3266. ``menuconfig`` and make all your changes at once. However, that makes it
  3267. difficult to see the effects of your individual eliminations and also
  3268. makes it difficult to replicate the changes for perhaps another target
  3269. device. A better method is to start with no configurations using
  3270. ``allnoconfig``, create configuration fragments for individual changes,
  3271. and then manage the fragments into a single configuration file using
  3272. ``merge_config.sh``. The tool makes it easy for you to iterate using the
  3273. configuration change and build cycle.
  3274. Each time you make configuration changes, you need to rebuild the kernel
  3275. and check to see what impact your changes had on the overall size.
  3276. Remove Package Management Requirements
  3277. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3278. Packaging requirements add size to the image. One way to reduce the size
  3279. of the image is to remove all the packaging requirements from the image.
  3280. This reduction includes both removing the package manager and its unique
  3281. dependencies as well as removing the package management data itself.
  3282. To eliminate all the packaging requirements for an image, be sure that
  3283. "package-management" is not part of your
  3284. :term:`IMAGE_FEATURES`
  3285. statement for the image. When you remove this feature, you are removing
  3286. the package manager as well as its dependencies from the root
  3287. filesystem.
  3288. Look for Other Ways to Minimize Size
  3289. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3290. Depending on your particular circumstances, other areas that you can
  3291. trim likely exist. The key to finding these areas is through tools and
  3292. methods described here combined with experimentation and iteration. Here
  3293. are a couple of areas to experiment with:
  3294. - ``glibc``: In general, follow this process:
  3295. 1. Remove ``glibc`` features from
  3296. :term:`DISTRO_FEATURES`
  3297. that you think you do not need.
  3298. 2. Build your distribution.
  3299. 3. If the build fails due to missing symbols in a package, determine
  3300. if you can reconfigure the package to not need those features. For
  3301. example, change the configuration to not support wide character
  3302. support as is done for ``ncurses``. Or, if support for those
  3303. characters is needed, determine what ``glibc`` features provide
  3304. the support and restore the configuration.
  3305. 4. Rebuild and repeat the process.
  3306. - ``busybox``: For BusyBox, use a process similar as described for
  3307. ``glibc``. A difference is you will need to boot the resulting system
  3308. to see if you are able to do everything you expect from the running
  3309. system. You need to be sure to integrate configuration fragments into
  3310. Busybox because BusyBox handles its own core features and then allows
  3311. you to add configuration fragments on top.
  3312. Iterate on the Process
  3313. ~~~~~~~~~~~~~~~~~~~~~~
  3314. If you have not reached your goals on system size, you need to iterate
  3315. on the process. The process is the same. Use the tools and see just what
  3316. is taking up 90% of the root filesystem and the kernel. Decide what you
  3317. can eliminate without limiting your device beyond what you need.
  3318. Depending on your system, a good place to look might be Busybox, which
  3319. provides a stripped down version of Unix tools in a single, executable
  3320. file. You might be able to drop virtual terminal services or perhaps
  3321. ipv6.
  3322. Building Images for More than One Machine
  3323. -----------------------------------------
  3324. A common scenario developers face is creating images for several
  3325. different machines that use the same software environment. In this
  3326. situation, it is tempting to set the tunings and optimization flags for
  3327. each build specifically for the targeted hardware (i.e. "maxing out" the
  3328. tunings). Doing so can considerably add to build times and package feed
  3329. maintenance collectively for the machines. For example, selecting tunes
  3330. that are extremely specific to a CPU core used in a system might enable
  3331. some micro optimizations in GCC for that particular system but would
  3332. otherwise not gain you much of a performance difference across the other
  3333. systems as compared to using a more general tuning across all the builds
  3334. (e.g. setting :term:`DEFAULTTUNE`
  3335. specifically for each machine's build). Rather than "max out" each
  3336. build's tunings, you can take steps that cause the OpenEmbedded build
  3337. system to reuse software across the various machines where it makes
  3338. sense.
  3339. If build speed and package feed maintenance are considerations, you
  3340. should consider the points in this section that can help you optimize
  3341. your tunings to best consider build times and package feed maintenance.
  3342. - *Share the Build Directory:* If at all possible, share the
  3343. :term:`TMPDIR` across builds. The
  3344. Yocto Project supports switching between different
  3345. :term:`MACHINE` values in the same
  3346. ``TMPDIR``. This practice is well supported and regularly used by
  3347. developers when building for multiple machines. When you use the same
  3348. ``TMPDIR`` for multiple machine builds, the OpenEmbedded build system
  3349. can reuse the existing native and often cross-recipes for multiple
  3350. machines. Thus, build time decreases.
  3351. .. note::
  3352. If :term:`DISTRO` settings change or fundamental configuration settings
  3353. such as the filesystem layout, you need to work with a clean ``TMPDIR``.
  3354. Sharing ``TMPDIR`` under these circumstances might work but since it is
  3355. not guaranteed, you should use a clean ``TMPDIR``.
  3356. - *Enable the Appropriate Package Architecture:* By default, the
  3357. OpenEmbedded build system enables three levels of package
  3358. architectures: "all", "tune" or "package", and "machine". Any given
  3359. recipe usually selects one of these package architectures (types) for
  3360. its output. Depending for what a given recipe creates packages,
  3361. making sure you enable the appropriate package architecture can
  3362. directly impact the build time.
  3363. A recipe that just generates scripts can enable "all" architecture
  3364. because there are no binaries to build. To specifically enable "all"
  3365. architecture, be sure your recipe inherits the
  3366. :ref:`allarch <ref-classes-allarch>` class.
  3367. This class is useful for "all" architectures because it configures
  3368. many variables so packages can be used across multiple architectures.
  3369. If your recipe needs to generate packages that are machine-specific
  3370. or when one of the build or runtime dependencies is already
  3371. machine-architecture dependent, which makes your recipe also
  3372. machine-architecture dependent, make sure your recipe enables the
  3373. "machine" package architecture through the
  3374. :term:`MACHINE_ARCH`
  3375. variable:
  3376. ::
  3377. PACKAGE_ARCH = "${MACHINE_ARCH}"
  3378. When you do not
  3379. specifically enable a package architecture through the
  3380. :term:`PACKAGE_ARCH`, The
  3381. OpenEmbedded build system defaults to the
  3382. :term:`TUNE_PKGARCH` setting:
  3383. ::
  3384. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  3385. - *Choose a Generic Tuning File if Possible:* Some tunes are more
  3386. generic and can run on multiple targets (e.g. an ``armv5`` set of
  3387. packages could run on ``armv6`` and ``armv7`` processors in most
  3388. cases). Similarly, ``i486`` binaries could work on ``i586`` and
  3389. higher processors. You should realize, however, that advances on
  3390. newer processor versions would not be used.
  3391. If you select the same tune for several different machines, the
  3392. OpenEmbedded build system reuses software previously built, thus
  3393. speeding up the overall build time. Realize that even though a new
  3394. sysroot for each machine is generated, the software is not recompiled
  3395. and only one package feed exists.
  3396. - *Manage Granular Level Packaging:* Sometimes cases exist where
  3397. injecting another level of package architecture beyond the three
  3398. higher levels noted earlier can be useful. For example, consider how
  3399. NXP (formerly Freescale) allows for the easy reuse of binary packages
  3400. in their layer
  3401. :yocto_git:`meta-freescale </meta-freescale/>`.
  3402. In this example, the
  3403. :yocto_git:`fsl-dynamic-packagearch </meta-freescale/tree/classes/fsl-dynamic-packagearch.bbclass>`
  3404. class shares GPU packages for i.MX53 boards because all boards share
  3405. the AMD GPU. The i.MX6-based boards can do the same because all
  3406. boards share the Vivante GPU. This class inspects the BitBake
  3407. datastore to identify if the package provides or depends on one of
  3408. the sub-architecture values. If so, the class sets the
  3409. :term:`PACKAGE_ARCH` value
  3410. based on the ``MACHINE_SUBARCH`` value. If the package does not
  3411. provide or depend on one of the sub-architecture values but it
  3412. matches a value in the machine-specific filter, it sets
  3413. :term:`MACHINE_ARCH`. This
  3414. behavior reduces the number of packages built and saves build time by
  3415. reusing binaries.
  3416. - *Use Tools to Debug Issues:* Sometimes you can run into situations
  3417. where software is being rebuilt when you think it should not be. For
  3418. example, the OpenEmbedded build system might not be using shared
  3419. state between machines when you think it should be. These types of
  3420. situations are usually due to references to machine-specific
  3421. variables such as :term:`MACHINE`,
  3422. :term:`SERIAL_CONSOLES`,
  3423. :term:`XSERVER`,
  3424. :term:`MACHINE_FEATURES`,
  3425. and so forth in code that is supposed to only be tune-specific or
  3426. when the recipe depends
  3427. (:term:`DEPENDS`,
  3428. :term:`RDEPENDS`,
  3429. :term:`RRECOMMENDS`,
  3430. :term:`RSUGGESTS`, and so forth)
  3431. on some other recipe that already has
  3432. :term:`PACKAGE_ARCH` defined
  3433. as "${MACHINE_ARCH}".
  3434. .. note::
  3435. Patches to fix any issues identified are most welcome as these
  3436. issues occasionally do occur.
  3437. For such cases, you can use some tools to help you sort out the
  3438. situation:
  3439. - ``state-diff-machines.sh``*:* You can find this tool in the
  3440. ``scripts`` directory of the Source Repositories. See the comments
  3441. in the script for information on how to use the tool.
  3442. - *BitBake's "-S printdiff" Option:* Using this option causes
  3443. BitBake to try to establish the closest signature match it can
  3444. (e.g. in the shared state cache) and then run ``bitbake-diffsigs``
  3445. over the matches to determine the stamps and delta where these two
  3446. stamp trees diverge.
  3447. Building Software from an External Source
  3448. -----------------------------------------
  3449. By default, the OpenEmbedded build system uses the
  3450. :term:`Build Directory` when building source
  3451. code. The build process involves fetching the source files, unpacking
  3452. them, and then patching them if necessary before the build takes place.
  3453. Situations exist where you might want to build software from source
  3454. files that are external to and thus outside of the OpenEmbedded build
  3455. system. For example, suppose you have a project that includes a new BSP
  3456. with a heavily customized kernel. And, you want to minimize exposing the
  3457. build system to the development team so that they can focus on their
  3458. project and maintain everyone's workflow as much as possible. In this
  3459. case, you want a kernel source directory on the development machine
  3460. where the development occurs. You want the recipe's
  3461. :term:`SRC_URI` variable to point to
  3462. the external directory and use it as is, not copy it.
  3463. To build from software that comes from an external source, all you need
  3464. to do is inherit the
  3465. :ref:`externalsrc <ref-classes-externalsrc>` class
  3466. and then set the
  3467. :term:`EXTERNALSRC` variable to
  3468. point to your external source code. Here are the statements to put in
  3469. your ``local.conf`` file:
  3470. ::
  3471. INHERIT += "externalsrc"
  3472. EXTERNALSRC_pn-myrecipe = "path-to-your-source-tree"
  3473. This next example shows how to accomplish the same thing by setting
  3474. ``EXTERNALSRC`` in the recipe itself or in the recipe's append file:
  3475. ::
  3476. EXTERNALSRC = "path"
  3477. EXTERNALSRC_BUILD = "path"
  3478. .. note::
  3479. In order for these settings to take effect, you must globally or
  3480. locally inherit the :ref:`externalsrc <ref-classes-externalsrc>`
  3481. class.
  3482. By default, ``externalsrc.bbclass`` builds the source code in a
  3483. directory separate from the external source directory as specified by
  3484. :term:`EXTERNALSRC`. If you need
  3485. to have the source built in the same directory in which it resides, or
  3486. some other nominated directory, you can set
  3487. :term:`EXTERNALSRC_BUILD`
  3488. to point to that directory:
  3489. ::
  3490. EXTERNALSRC_BUILD_pn-myrecipe = "path-to-your-source-tree"
  3491. Replicating a Build Offline
  3492. ---------------------------
  3493. It can be useful to take a "snapshot" of upstream sources used in a
  3494. build and then use that "snapshot" later to replicate the build offline.
  3495. To do so, you need to first prepare and populate your downloads
  3496. directory your "snapshot" of files. Once your downloads directory is
  3497. ready, you can use it at any time and from any machine to replicate your
  3498. build.
  3499. Follow these steps to populate your Downloads directory:
  3500. 1. *Create a Clean Downloads Directory:* Start with an empty downloads
  3501. directory (:term:`DL_DIR`). You
  3502. start with an empty downloads directory by either removing the files
  3503. in the existing directory or by setting ``DL_DIR`` to point to either
  3504. an empty location or one that does not yet exist.
  3505. 2. *Generate Tarballs of the Source Git Repositories:* Edit your
  3506. ``local.conf`` configuration file as follows:
  3507. ::
  3508. DL_DIR = "/home/your-download-dir/"
  3509. BB_GENERATE_MIRROR_TARBALLS = "1"
  3510. During
  3511. the fetch process in the next step, BitBake gathers the source files
  3512. and creates tarballs in the directory pointed to by ``DL_DIR``. See
  3513. the
  3514. :term:`BB_GENERATE_MIRROR_TARBALLS`
  3515. variable for more information.
  3516. 3. *Populate Your Downloads Directory Without Building:* Use BitBake to
  3517. fetch your sources but inhibit the build:
  3518. ::
  3519. $ bitbake target --runonly=fetch
  3520. The downloads directory (i.e. ``${DL_DIR}``) now has
  3521. a "snapshot" of the source files in the form of tarballs, which can
  3522. be used for the build.
  3523. 4. *Optionally Remove Any Git or other SCM Subdirectories From the
  3524. Downloads Directory:* If you want, you can clean up your downloads
  3525. directory by removing any Git or other Source Control Management
  3526. (SCM) subdirectories such as ``${DL_DIR}/git2/*``. The tarballs
  3527. already contain these subdirectories.
  3528. Once your downloads directory has everything it needs regarding source
  3529. files, you can create your "own-mirror" and build your target.
  3530. Understand that you can use the files to build the target offline from
  3531. any machine and at any time.
  3532. Follow these steps to build your target using the files in the downloads
  3533. directory:
  3534. 1. *Using Local Files Only:* Inside your ``local.conf`` file, add the
  3535. :term:`SOURCE_MIRROR_URL`
  3536. variable, inherit the
  3537. :ref:`own-mirrors <ref-classes-own-mirrors>`
  3538. class, and use the
  3539. :term:`bitbake:BB_NO_NETWORK`
  3540. variable to your ``local.conf``.
  3541. ::
  3542. SOURCE_MIRROR_URL ?= "file:///home/your-download-dir/"
  3543. INHERIT += "own-mirrors"
  3544. BB_NO_NETWORK = "1"
  3545. The ``SOURCE_MIRROR_URL`` and ``own-mirror``
  3546. class set up the system to use the downloads directory as your "own
  3547. mirror". Using the ``BB_NO_NETWORK`` variable makes sure that
  3548. BitBake's fetching process in step 3 stays local, which means files
  3549. from your "own-mirror" are used.
  3550. 2. *Start With a Clean Build:* You can start with a clean build by
  3551. removing the
  3552. ``${``\ :term:`TMPDIR`\ ``}``
  3553. directory or using a new :term:`Build Directory`.
  3554. 3. *Build Your Target:* Use BitBake to build your target:
  3555. ::
  3556. $ bitbake target
  3557. The build completes using the known local "snapshot" of source
  3558. files from your mirror. The resulting tarballs for your "snapshot" of
  3559. source files are in the downloads directory.
  3560. .. note::
  3561. The offline build does not work if recipes attempt to find the
  3562. latest version of software by setting
  3563. :term:`SRCREV` to
  3564. ``${``\ :term:`AUTOREV`\ ``}``:
  3565. ::
  3566. SRCREV = "${AUTOREV}"
  3567. When a recipe sets ``SRCREV`` to
  3568. ``${AUTOREV}``, the build system accesses the network in an
  3569. attempt to determine the latest version of software from the SCM.
  3570. Typically, recipes that use ``AUTOREV`` are custom or modified
  3571. recipes. Recipes that reside in public repositories usually do not
  3572. use ``AUTOREV``.
  3573. If you do have recipes that use ``AUTOREV``, you can take steps to
  3574. still use the recipes in an offline build. Do the following:
  3575. 1. Use a configuration generated by enabling `build
  3576. history <#maintaining-build-output-quality>`__.
  3577. 2. Use the ``buildhistory-collect-srcrevs`` command to collect the
  3578. stored ``SRCREV`` values from the build's history. For more
  3579. information on collecting these values, see the "`Build History
  3580. Package Information <#build-history-package-information>`__"
  3581. section.
  3582. 3. Once you have the correct source revisions, you can modify
  3583. those recipes to to set ``SRCREV`` to specific versions of the
  3584. software.
  3585. Speeding Up a Build
  3586. ===================
  3587. Build time can be an issue. By default, the build system uses simple
  3588. controls to try and maximize build efficiency. In general, the default
  3589. settings for all the following variables result in the most efficient
  3590. build times when dealing with single socket systems (i.e. a single CPU).
  3591. If you have multiple CPUs, you might try increasing the default values
  3592. to gain more speed. See the descriptions in the glossary for each
  3593. variable for more information:
  3594. - :term:`BB_NUMBER_THREADS`:
  3595. The maximum number of threads BitBake simultaneously executes.
  3596. - :term:`bitbake:BB_NUMBER_PARSE_THREADS`:
  3597. The number of threads BitBake uses during parsing.
  3598. - :term:`PARALLEL_MAKE`: Extra
  3599. options passed to the ``make`` command during the
  3600. :ref:`ref-tasks-compile` task in
  3601. order to specify parallel compilation on the local build host.
  3602. - :term:`PARALLEL_MAKEINST`:
  3603. Extra options passed to the ``make`` command during the
  3604. :ref:`ref-tasks-install` task in
  3605. order to specify parallel installation on the local build host.
  3606. As mentioned, these variables all scale to the number of processor cores
  3607. available on the build system. For single socket systems, this
  3608. auto-scaling ensures that the build system fundamentally takes advantage
  3609. of potential parallel operations during the build based on the build
  3610. machine's capabilities.
  3611. Following are additional factors that can affect build speed:
  3612. - File system type: The file system type that the build is being
  3613. performed on can also influence performance. Using ``ext4`` is
  3614. recommended as compared to ``ext2`` and ``ext3`` due to ``ext4``
  3615. improved features such as extents.
  3616. - Disabling the updating of access time using ``noatime``: The
  3617. ``noatime`` mount option prevents the build system from updating file
  3618. and directory access times.
  3619. - Setting a longer commit: Using the "commit=" mount option increases
  3620. the interval in seconds between disk cache writes. Changing this
  3621. interval from the five second default to something longer increases
  3622. the risk of data loss but decreases the need to write to the disk,
  3623. thus increasing the build performance.
  3624. - Choosing the packaging backend: Of the available packaging backends,
  3625. IPK is the fastest. Additionally, selecting a singular packaging
  3626. backend also helps.
  3627. - Using ``tmpfs`` for :term:`TMPDIR`
  3628. as a temporary file system: While this can help speed up the build,
  3629. the benefits are limited due to the compiler using ``-pipe``. The
  3630. build system goes to some lengths to avoid ``sync()`` calls into the
  3631. file system on the principle that if there was a significant failure,
  3632. the :term:`Build Directory`
  3633. contents could easily be rebuilt.
  3634. - Inheriting the
  3635. :ref:`rm_work <ref-classes-rm-work>` class:
  3636. Inheriting this class has shown to speed up builds due to
  3637. significantly lower amounts of data stored in the data cache as well
  3638. as on disk. Inheriting this class also makes cleanup of
  3639. :term:`TMPDIR` faster, at the
  3640. expense of being easily able to dive into the source code. File
  3641. system maintainers have recommended that the fastest way to clean up
  3642. large numbers of files is to reformat partitions rather than delete
  3643. files due to the linear nature of partitions. This, of course,
  3644. assumes you structure the disk partitions and file systems in a way
  3645. that this is practical.
  3646. Aside from the previous list, you should keep some trade offs in mind
  3647. that can help you speed up the build:
  3648. - Remove items from
  3649. :term:`DISTRO_FEATURES`
  3650. that you might not need.
  3651. - Exclude debug symbols and other debug information: If you do not need
  3652. these symbols and other debug information, disabling the ``*-dbg``
  3653. package generation can speed up the build. You can disable this
  3654. generation by setting the
  3655. :term:`INHIBIT_PACKAGE_DEBUG_SPLIT`
  3656. variable to "1".
  3657. - Disable static library generation for recipes derived from
  3658. ``autoconf`` or ``libtool``: Following is an example showing how to
  3659. disable static libraries and still provide an override to handle
  3660. exceptions:
  3661. ::
  3662. STATICLIBCONF = "--disable-static"
  3663. STATICLIBCONF_sqlite3-native = ""
  3664. EXTRA_OECONF += "${STATICLIBCONF}"
  3665. .. note::
  3666. - Some recipes need static libraries in order to work correctly
  3667. (e.g. ``pseudo-native`` needs ``sqlite3-native``). Overrides,
  3668. as in the previous example, account for these kinds of
  3669. exceptions.
  3670. - Some packages have packaging code that assumes the presence of
  3671. the static libraries. If so, you might need to exclude them as
  3672. well.
  3673. Working With Libraries
  3674. ======================
  3675. Libraries are an integral part of your system. This section describes
  3676. some common practices you might find helpful when working with libraries
  3677. to build your system:
  3678. - `How to include static library
  3679. files <#including-static-library-files>`__
  3680. - `How to use the Multilib feature to combine multiple versions of
  3681. library files into a single
  3682. image <#combining-multiple-versions-library-files-into-one-image>`__
  3683. - `How to install multiple versions of the same library in parallel on
  3684. the same
  3685. system <#installing-multiple-versions-of-the-same-library>`__
  3686. Including Static Library Files
  3687. ------------------------------
  3688. If you are building a library and the library offers static linking, you
  3689. can control which static library files (``*.a`` files) get included in
  3690. the built library.
  3691. The :term:`PACKAGES` and
  3692. :term:`FILES_* <FILES>` variables in the
  3693. ``meta/conf/bitbake.conf`` configuration file define how files installed
  3694. by the ``do_install`` task are packaged. By default, the ``PACKAGES``
  3695. variable includes ``${PN}-staticdev``, which represents all static
  3696. library files.
  3697. .. note::
  3698. Some previously released versions of the Yocto Project defined the
  3699. static library files through ``${PN}-dev``.
  3700. Following is part of the BitBake configuration file, where you can see
  3701. how the static library files are defined:
  3702. ::
  3703. PACKAGE_BEFORE_PN ?= ""
  3704. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  3705. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  3706. FILES = ""
  3707. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  3708. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  3709. ${base_bindir}/* ${base_sbindir}/* \
  3710. ${base_libdir}/*${SOLIBS} \
  3711. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  3712. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  3713. ${datadir}/pixmaps ${datadir}/applications \
  3714. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  3715. ${libdir}/bonobo/servers"
  3716. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  3717. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  3718. ${datadir}/gnome/help"
  3719. SECTION_${PN}-doc = "doc"
  3720. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  3721. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  3722. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  3723. ${datadir}/aclocal ${base_libdir}/*.o \
  3724. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  3725. SECTION_${PN}-dev = "devel"
  3726. ALLOW_EMPTY_${PN}-dev = "1"
  3727. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  3728. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  3729. SECTION_${PN}-staticdev = "devel"
  3730. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  3731. Combining Multiple Versions of Library Files into One Image
  3732. -----------------------------------------------------------
  3733. The build system offers the ability to build libraries with different
  3734. target optimizations or architecture formats and combine these together
  3735. into one system image. You can link different binaries in the image
  3736. against the different libraries as needed for specific use cases. This
  3737. feature is called "Multilib".
  3738. An example would be where you have most of a system compiled in 32-bit
  3739. mode using 32-bit libraries, but you have something large, like a
  3740. database engine, that needs to be a 64-bit application and uses 64-bit
  3741. libraries. Multilib allows you to get the best of both 32-bit and 64-bit
  3742. libraries.
  3743. While the Multilib feature is most commonly used for 32 and 64-bit
  3744. differences, the approach the build system uses facilitates different
  3745. target optimizations. You could compile some binaries to use one set of
  3746. libraries and other binaries to use a different set of libraries. The
  3747. libraries could differ in architecture, compiler options, or other
  3748. optimizations.
  3749. Several examples exist in the ``meta-skeleton`` layer found in the
  3750. :term:`Source Directory`:
  3751. - ``conf/multilib-example.conf`` configuration file
  3752. - ``conf/multilib-example2.conf`` configuration file
  3753. - ``recipes-multilib/images/core-image-multilib-example.bb`` recipe
  3754. Preparing to Use Multilib
  3755. ~~~~~~~~~~~~~~~~~~~~~~~~~
  3756. User-specific requirements drive the Multilib feature. Consequently,
  3757. there is no one "out-of-the-box" configuration that likely exists to
  3758. meet your needs.
  3759. In order to enable Multilib, you first need to ensure your recipe is
  3760. extended to support multiple libraries. Many standard recipes are
  3761. already extended and support multiple libraries. You can check in the
  3762. ``meta/conf/multilib.conf`` configuration file in the
  3763. :term:`Source Directory` to see how this is
  3764. done using the
  3765. :term:`BBCLASSEXTEND` variable.
  3766. Eventually, all recipes will be covered and this list will not be
  3767. needed.
  3768. For the most part, the Multilib class extension works automatically to
  3769. extend the package name from ``${PN}`` to ``${MLPREFIX}${PN}``, where
  3770. ``MLPREFIX`` is the particular multilib (e.g. "lib32-" or "lib64-").
  3771. Standard variables such as
  3772. :term:`DEPENDS`,
  3773. :term:`RDEPENDS`,
  3774. :term:`RPROVIDES`,
  3775. :term:`RRECOMMENDS`,
  3776. :term:`PACKAGES`, and
  3777. :term:`PACKAGES_DYNAMIC` are
  3778. automatically extended by the system. If you are extending any manual
  3779. code in the recipe, you can use the ``${MLPREFIX}`` variable to ensure
  3780. those names are extended correctly. This automatic extension code
  3781. resides in ``multilib.bbclass``.
  3782. Using Multilib
  3783. ~~~~~~~~~~~~~~
  3784. After you have set up the recipes, you need to define the actual
  3785. combination of multiple libraries you want to build. You accomplish this
  3786. through your ``local.conf`` configuration file in the
  3787. :term:`Build Directory`. An example
  3788. configuration would be as follows:
  3789. ::
  3790. MACHINE = "qemux86-64"
  3791. require conf/multilib.conf
  3792. MULTILIBS = "multilib:lib32"
  3793. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  3794. IMAGE_INSTALL_append = "lib32-glib-2.0"
  3795. This example enables an additional library named
  3796. ``lib32`` alongside the normal target packages. When combining these
  3797. "lib32" alternatives, the example uses "x86" for tuning. For information
  3798. on this particular tuning, see
  3799. ``meta/conf/machine/include/ia32/arch-ia32.inc``.
  3800. The example then includes ``lib32-glib-2.0`` in all the images, which
  3801. illustrates one method of including a multiple library dependency. You
  3802. can use a normal image build to include this dependency, for example:
  3803. ::
  3804. $ bitbake core-image-sato
  3805. You can also build Multilib packages
  3806. specifically with a command like this:
  3807. ::
  3808. $ bitbake lib32-glib-2.0
  3809. Additional Implementation Details
  3810. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3811. Generic implementation details as well as details that are specific to
  3812. package management systems exist. Following are implementation details
  3813. that exist regardless of the package management system:
  3814. - The typical convention used for the class extension code as used by
  3815. Multilib assumes that all package names specified in
  3816. :term:`PACKAGES` that contain
  3817. ``${PN}`` have ``${PN}`` at the start of the name. When that
  3818. convention is not followed and ``${PN}`` appears at the middle or the
  3819. end of a name, problems occur.
  3820. - The :term:`TARGET_VENDOR`
  3821. value under Multilib will be extended to "-vendormlmultilib" (e.g.
  3822. "-pokymllib32" for a "lib32" Multilib with Poky). The reason for this
  3823. slightly unwieldy contraction is that any "-" characters in the
  3824. vendor string presently break Autoconf's ``config.sub``, and other
  3825. separators are problematic for different reasons.
  3826. For the RPM Package Management System, the following implementation
  3827. details exist:
  3828. - A unique architecture is defined for the Multilib packages, along
  3829. with creating a unique deploy folder under ``tmp/deploy/rpm`` in the
  3830. :term:`Build Directory`. For
  3831. example, consider ``lib32`` in a ``qemux86-64`` image. The possible
  3832. architectures in the system are "all", "qemux86_64",
  3833. "lib32_qemux86_64", and "lib32_x86".
  3834. - The ``${MLPREFIX}`` variable is stripped from ``${PN}`` during RPM
  3835. packaging. The naming for a normal RPM package and a Multilib RPM
  3836. package in a ``qemux86-64`` system resolves to something similar to
  3837. ``bash-4.1-r2.x86_64.rpm`` and ``bash-4.1.r2.lib32_x86.rpm``,
  3838. respectively.
  3839. - When installing a Multilib image, the RPM backend first installs the
  3840. base image and then installs the Multilib libraries.
  3841. - The build system relies on RPM to resolve the identical files in the
  3842. two (or more) Multilib packages.
  3843. For the IPK Package Management System, the following implementation
  3844. details exist:
  3845. - The ``${MLPREFIX}`` is not stripped from ``${PN}`` during IPK
  3846. packaging. The naming for a normal RPM package and a Multilib IPK
  3847. package in a ``qemux86-64`` system resolves to something like
  3848. ``bash_4.1-r2.x86_64.ipk`` and ``lib32-bash_4.1-rw_x86.ipk``,
  3849. respectively.
  3850. - The IPK deploy folder is not modified with ``${MLPREFIX}`` because
  3851. packages with and without the Multilib feature can exist in the same
  3852. folder due to the ``${PN}`` differences.
  3853. - IPK defines a sanity check for Multilib installation using certain
  3854. rules for file comparison, overridden, etc.
  3855. Installing Multiple Versions of the Same Library
  3856. ------------------------------------------------
  3857. Situations can exist where you need to install and use multiple versions
  3858. of the same library on the same system at the same time. These
  3859. situations almost always exist when a library API changes and you have
  3860. multiple pieces of software that depend on the separate versions of the
  3861. library. To accommodate these situations, you can install multiple
  3862. versions of the same library in parallel on the same system.
  3863. The process is straightforward as long as the libraries use proper
  3864. versioning. With properly versioned libraries, all you need to do to
  3865. individually specify the libraries is create separate, appropriately
  3866. named recipes where the :term:`PN` part of
  3867. the name includes a portion that differentiates each library version
  3868. (e.g. the major part of the version number). Thus, instead of having a
  3869. single recipe that loads one version of a library (e.g. ``clutter``),
  3870. you provide multiple recipes that result in different versions of the
  3871. libraries you want. As an example, the following two recipes would allow
  3872. the two separate versions of the ``clutter`` library to co-exist on the
  3873. same system:
  3874. .. code-block:: none
  3875. clutter-1.6_1.6.20.bb
  3876. clutter-1.8_1.8.4.bb
  3877. Additionally, if
  3878. you have other recipes that depend on a given library, you need to use
  3879. the :term:`DEPENDS` variable to
  3880. create the dependency. Continuing with the same example, if you want to
  3881. have a recipe depend on the 1.8 version of the ``clutter`` library, use
  3882. the following in your recipe:
  3883. ::
  3884. DEPENDS = "clutter-1.8"
  3885. Using x32 psABI
  3886. ===============
  3887. x32 processor-specific Application Binary Interface (`x32
  3888. psABI <https://software.intel.com/en-us/node/628948>`__) is a native
  3889. 32-bit processor-specific ABI for Intel 64 (x86-64) architectures. An
  3890. ABI defines the calling conventions between functions in a processing
  3891. environment. The interface determines what registers are used and what
  3892. the sizes are for various C data types.
  3893. Some processing environments prefer using 32-bit applications even when
  3894. running on Intel 64-bit platforms. Consider the i386 psABI, which is a
  3895. very old 32-bit ABI for Intel 64-bit platforms. The i386 psABI does not
  3896. provide efficient use and access of the Intel 64-bit processor
  3897. resources, leaving the system underutilized. Now consider the x86_64
  3898. psABI. This ABI is newer and uses 64-bits for data sizes and program
  3899. pointers. The extra bits increase the footprint size of the programs,
  3900. libraries, and also increases the memory and file system size
  3901. requirements. Executing under the x32 psABI enables user programs to
  3902. utilize CPU and system resources more efficiently while keeping the
  3903. memory footprint of the applications low. Extra bits are used for
  3904. registers but not for addressing mechanisms.
  3905. The Yocto Project supports the final specifications of x32 psABI as
  3906. follows:
  3907. - You can create packages and images in x32 psABI format on x86_64
  3908. architecture targets.
  3909. - You can successfully build recipes with the x32 toolchain.
  3910. - You can create and boot ``core-image-minimal`` and
  3911. ``core-image-sato`` images.
  3912. - RPM Package Manager (RPM) support exists for x32 binaries.
  3913. - Support for large images exists.
  3914. To use the x32 psABI, you need to edit your ``conf/local.conf``
  3915. configuration file as follows:
  3916. ::
  3917. MACHINE = "qemux86-64"
  3918. DEFAULTTUNE = "x86-64-x32"
  3919. baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE') \
  3920. or 'INVALID')) or 'lib'}"
  3921. Once you have set
  3922. up your configuration file, use BitBake to build an image that supports
  3923. the x32 psABI. Here is an example:
  3924. ::
  3925. $ bitbake core-image-sato
  3926. Enabling GObject Introspection Support
  3927. ======================================
  3928. `GObject
  3929. introspection <https://wiki.gnome.org/Projects/GObjectIntrospection>`__
  3930. is the standard mechanism for accessing GObject-based software from
  3931. runtime environments. GObject is a feature of the GLib library that
  3932. provides an object framework for the GNOME desktop and related software.
  3933. GObject Introspection adds information to GObject that allows objects
  3934. created within it to be represented across different programming
  3935. languages. If you want to construct GStreamer pipelines using Python, or
  3936. control UPnP infrastructure using Javascript and GUPnP, GObject
  3937. introspection is the only way to do it.
  3938. This section describes the Yocto Project support for generating and
  3939. packaging GObject introspection data. GObject introspection data is a
  3940. description of the API provided by libraries built on top of GLib
  3941. framework, and, in particular, that framework's GObject mechanism.
  3942. GObject Introspection Repository (GIR) files go to ``-dev`` packages,
  3943. ``typelib`` files go to main packages as they are packaged together with
  3944. libraries that are introspected.
  3945. The data is generated when building such a library, by linking the
  3946. library with a small executable binary that asks the library to describe
  3947. itself, and then executing the binary and processing its output.
  3948. Generating this data in a cross-compilation environment is difficult
  3949. because the library is produced for the target architecture, but its
  3950. code needs to be executed on the build host. This problem is solved with
  3951. the OpenEmbedded build system by running the code through QEMU, which
  3952. allows precisely that. Unfortunately, QEMU does not always work
  3953. perfectly as mentioned in the "`Known Issues <#known-issues>`__"
  3954. section.
  3955. Enabling the Generation of Introspection Data
  3956. ---------------------------------------------
  3957. Enabling the generation of introspection data (GIR files) in your
  3958. library package involves the following:
  3959. 1. Inherit the
  3960. :ref:`gobject-introspection <ref-classes-gobject-introspection>`
  3961. class.
  3962. 2. Make sure introspection is not disabled anywhere in the recipe or
  3963. from anything the recipe includes. Also, make sure that
  3964. "gobject-introspection-data" is not in
  3965. :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`
  3966. and that "qemu-usermode" is not in
  3967. :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`.
  3968. If either of these conditions exist, nothing will happen.
  3969. 3. Try to build the recipe. If you encounter build errors that look like
  3970. something is unable to find ``.so`` libraries, check where these
  3971. libraries are located in the source tree and add the following to the
  3972. recipe:
  3973. ::
  3974. GIR_EXTRA_LIBS_PATH = "${B}/something/.libs"
  3975. .. note::
  3976. See recipes in the ``oe-core`` repository that use that
  3977. ``GIR_EXTRA_LIBS_PATH`` variable as an example.
  3978. 4. Look for any other errors, which probably mean that introspection
  3979. support in a package is not entirely standard, and thus breaks down
  3980. in a cross-compilation environment. For such cases, custom-made fixes
  3981. are needed. A good place to ask and receive help in these cases is
  3982. the :ref:`Yocto Project mailing
  3983. lists <resources-mailinglist>`.
  3984. .. note::
  3985. Using a library that no longer builds against the latest Yocto
  3986. Project release and prints introspection related errors is a good
  3987. candidate for the previous procedure.
  3988. Disabling the Generation of Introspection Data
  3989. ----------------------------------------------
  3990. You might find that you do not want to generate introspection data. Or,
  3991. perhaps QEMU does not work on your build host and target architecture
  3992. combination. If so, you can use either of the following methods to
  3993. disable GIR file generations:
  3994. - Add the following to your distro configuration:
  3995. ::
  3996. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  3997. Adding this statement disables generating introspection data using
  3998. QEMU but will still enable building introspection tools and libraries
  3999. (i.e. building them does not require the use of QEMU).
  4000. - Add the following to your machine configuration:
  4001. ::
  4002. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  4003. Adding this statement disables the use of QEMU when building packages for your
  4004. machine. Currently, this feature is used only by introspection
  4005. recipes and has the same effect as the previously described option.
  4006. .. note::
  4007. Future releases of the Yocto Project might have other features
  4008. affected by this option.
  4009. If you disable introspection data, you can still obtain it through other
  4010. means such as copying the data from a suitable sysroot, or by generating
  4011. it on the target hardware. The OpenEmbedded build system does not
  4012. currently provide specific support for these techniques.
  4013. Testing that Introspection Works in an Image
  4014. --------------------------------------------
  4015. Use the following procedure to test if generating introspection data is
  4016. working in an image:
  4017. 1. Make sure that "gobject-introspection-data" is not in
  4018. :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`
  4019. and that "qemu-usermode" is not in
  4020. :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`.
  4021. 2. Build ``core-image-sato``.
  4022. 3. Launch a Terminal and then start Python in the terminal.
  4023. 4. Enter the following in the terminal:
  4024. ::
  4025. >>> from gi.repository import GLib
  4026. >>> GLib.get_host_name()
  4027. 5. For something a little more advanced, enter the following see:
  4028. https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
  4029. Known Issues
  4030. ------------
  4031. The following know issues exist for GObject Introspection Support:
  4032. - ``qemu-ppc64`` immediately crashes. Consequently, you cannot build
  4033. introspection data on that architecture.
  4034. - x32 is not supported by QEMU. Consequently, introspection data is
  4035. disabled.
  4036. - musl causes transient GLib binaries to crash on assertion failures.
  4037. Consequently, generating introspection data is disabled.
  4038. - Because QEMU is not able to run the binaries correctly, introspection
  4039. is disabled for some specific packages under specific architectures
  4040. (e.g. ``gcr``, ``libsecret``, and ``webkit``).
  4041. - QEMU usermode might not work properly when running 64-bit binaries
  4042. under 32-bit host machines. In particular, "qemumips64" is known to
  4043. not work under i686.
  4044. Optionally Using an External Toolchain
  4045. ======================================
  4046. You might want to use an external toolchain as part of your development.
  4047. If this is the case, the fundamental steps you need to accomplish are as
  4048. follows:
  4049. - Understand where the installed toolchain resides. For cases where you
  4050. need to build the external toolchain, you would need to take separate
  4051. steps to build and install the toolchain.
  4052. - Make sure you add the layer that contains the toolchain to your
  4053. ``bblayers.conf`` file through the
  4054. :term:`BBLAYERS` variable.
  4055. - Set the ``EXTERNAL_TOOLCHAIN`` variable in your ``local.conf`` file
  4056. to the location in which you installed the toolchain.
  4057. A good example of an external toolchain used with the Yocto Project is
  4058. Mentor Graphics Sourcery G++ Toolchain. You can see information on how
  4059. to use that particular layer in the ``README`` file at
  4060. https://github.com/MentorEmbedded/meta-sourcery/. You can find
  4061. further information by reading about the
  4062. :term:`TCMODE` variable in the Yocto
  4063. Project Reference Manual's variable glossary.
  4064. Creating Partitioned Images Using Wic
  4065. =====================================
  4066. Creating an image for a particular hardware target using the
  4067. OpenEmbedded build system does not necessarily mean you can boot that
  4068. image as is on your device. Physical devices accept and boot images in
  4069. various ways depending on the specifics of the device. Usually,
  4070. information about the hardware can tell you what image format the device
  4071. requires. Should your device require multiple partitions on an SD card,
  4072. flash, or an HDD, you can use the OpenEmbedded Image Creator, Wic, to
  4073. create the properly partitioned image.
  4074. The ``wic`` command generates partitioned images from existing
  4075. OpenEmbedded build artifacts. Image generation is driven by partitioning
  4076. commands contained in an Openembedded kickstart file (``.wks``)
  4077. specified either directly on the command line or as one of a selection
  4078. of canned kickstart files as shown with the ``wic list images`` command
  4079. in the "`Using an Existing Kickstart
  4080. File <#using-a-provided-kickstart-file>`__" section. When you apply the
  4081. command to a given set of build artifacts, the result is an image or set
  4082. of images that can be directly written onto media and used on a
  4083. particular system.
  4084. .. note::
  4085. For a kickstart file reference, see the
  4086. ":ref:`ref-manual/ref-kickstart:openembedded kickstart (\`\`.wks\`\`) reference`"
  4087. Chapter in the Yocto Project Reference Manual.
  4088. The ``wic`` command and the infrastructure it is based on is by
  4089. definition incomplete. The purpose of the command is to allow the
  4090. generation of customized images, and as such, was designed to be
  4091. completely extensible through a plugin interface. See the "`Using the
  4092. Wic PlugIn Interface <#wic-using-the-wic-plugin-interface>`__" section
  4093. for information on these plugins.
  4094. This section provides some background information on Wic, describes what
  4095. you need to have in place to run the tool, provides instruction on how
  4096. to use the Wic utility, provides information on using the Wic plugins
  4097. interface, and provides several examples that show how to use Wic.
  4098. Background
  4099. ----------
  4100. This section provides some background on the Wic utility. While none of
  4101. this information is required to use Wic, you might find it interesting.
  4102. - The name "Wic" is derived from OpenEmbedded Image Creator (oeic). The
  4103. "oe" diphthong in "oeic" was promoted to the letter "w", because
  4104. "oeic" is both difficult to remember and to pronounce.
  4105. - Wic is loosely based on the Meego Image Creator (``mic``) framework.
  4106. The Wic implementation has been heavily modified to make direct use
  4107. of OpenEmbedded build artifacts instead of package installation and
  4108. configuration, which are already incorporated within the OpenEmbedded
  4109. artifacts.
  4110. - Wic is a completely independent standalone utility that initially
  4111. provides easier-to-use and more flexible replacements for an existing
  4112. functionality in OE-Core's
  4113. :ref:`image-live <ref-classes-image-live>`
  4114. class. The difference between Wic and those examples is that with Wic
  4115. the functionality of those scripts is implemented by a
  4116. general-purpose partitioning language, which is based on Redhat
  4117. kickstart syntax.
  4118. Requirements
  4119. ------------
  4120. In order to use the Wic utility with the OpenEmbedded Build system, your
  4121. system needs to meet the following requirements:
  4122. - The Linux distribution on your development host must support the
  4123. Yocto Project. See the ":ref:`detailed-supported-distros`"
  4124. section in the Yocto Project Reference Manual for the list of
  4125. distributions that support the Yocto Project.
  4126. - The standard system utilities, such as ``cp``, must be installed on
  4127. your development host system.
  4128. - You must have sourced the build environment setup script (i.e.
  4129. :ref:`structure-core-script`) found in the
  4130. :term:`Build Directory`.
  4131. - You need to have the build artifacts already available, which
  4132. typically means that you must have already created an image using the
  4133. Openembedded build system (e.g. ``core-image-minimal``). While it
  4134. might seem redundant to generate an image in order to create an image
  4135. using Wic, the current version of Wic requires the artifacts in the
  4136. form generated by the OpenEmbedded build system.
  4137. - You must build several native tools, which are built to run on the
  4138. build system:
  4139. ::
  4140. $ bitbake parted-native dosfstools-native mtools-native
  4141. - Include "wic" as part of the
  4142. :term:`IMAGE_FSTYPES`
  4143. variable.
  4144. - Include the name of the :ref:`wic kickstart file <openembedded-kickstart-wks-reference>`
  4145. as part of the :term:`WKS_FILE` variable
  4146. Getting Help
  4147. ------------
  4148. You can get general help for the ``wic`` command by entering the ``wic``
  4149. command by itself or by entering the command with a help argument as
  4150. follows:
  4151. ::
  4152. $ wic -h
  4153. $ wic --help
  4154. $ wic help
  4155. Currently, Wic supports seven commands: ``cp``, ``create``, ``help``,
  4156. ``list``, ``ls``, ``rm``, and ``write``. You can get help for all these
  4157. commands except "help" by using the following form:
  4158. ::
  4159. $ wic help command
  4160. For example, the following command returns help for the ``write``
  4161. command:
  4162. ::
  4163. $ wic help write
  4164. Wic supports help for three topics: ``overview``, ``plugins``, and
  4165. ``kickstart``. You can get help for any topic using the following form:
  4166. ::
  4167. $ wic help topic
  4168. For example, the following returns overview help for Wic:
  4169. ::
  4170. $ wic help overview
  4171. One additional level of help exists for Wic. You can get help on
  4172. individual images through the ``list`` command. You can use the ``list``
  4173. command to return the available Wic images as follows:
  4174. ::
  4175. $ wic list images
  4176. genericx86 Create an EFI disk image for genericx86*
  4177. beaglebone-yocto Create SD card image for Beaglebone
  4178. edgerouter Create SD card image for Edgerouter
  4179. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  4180. directdisk-gpt Create a 'pcbios' direct disk image
  4181. mkefidisk Create an EFI disk image
  4182. directdisk Create a 'pcbios' direct disk image
  4183. systemd-bootdisk Create an EFI disk image with systemd-boot
  4184. mkhybridiso Create a hybrid ISO image
  4185. sdimage-bootpart Create SD card image with a boot partition
  4186. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  4187. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  4188. Once you know the list of available
  4189. Wic images, you can use ``help`` with the command to get help on a
  4190. particular image. For example, the following command returns help on the
  4191. "beaglebone-yocto" image:
  4192. ::
  4193. $ wic list beaglebone-yocto help
  4194. Creates a partitioned SD card image for Beaglebone.
  4195. Boot files are located in the first vfat partition.
  4196. Operational Modes
  4197. -----------------
  4198. You can use Wic in two different modes, depending on how much control
  4199. you need for specifying the Openembedded build artifacts that are used
  4200. for creating the image: Raw and Cooked:
  4201. - *Raw Mode:* You explicitly specify build artifacts through Wic
  4202. command-line arguments.
  4203. - *Cooked Mode:* The current
  4204. :term:`MACHINE` setting and image
  4205. name are used to automatically locate and provide the build
  4206. artifacts. You just supply a kickstart file and the name of the image
  4207. from which to use artifacts.
  4208. Regardless of the mode you use, you need to have the build artifacts
  4209. ready and available.
  4210. Raw Mode
  4211. ~~~~~~~~
  4212. Running Wic in raw mode allows you to specify all the partitions through
  4213. the ``wic`` command line. The primary use for raw mode is if you have
  4214. built your kernel outside of the Yocto Project
  4215. :term:`Build Directory`. In other words, you
  4216. can point to arbitrary kernel, root filesystem locations, and so forth.
  4217. Contrast this behavior with cooked mode where Wic looks in the Build
  4218. Directory (e.g. ``tmp/deploy/images/``\ machine).
  4219. The general form of the ``wic`` command in raw mode is:
  4220. ::
  4221. $ wic create wks_file options ...
  4222. Where:
  4223. wks_file:
  4224. An OpenEmbedded kickstart file. You can provide
  4225. your own custom file or use a file from a set of
  4226. existing files as described by further options.
  4227. optional arguments:
  4228. -h, --help show this help message and exit
  4229. -o OUTDIR, --outdir OUTDIR
  4230. name of directory to create image in
  4231. -e IMAGE_NAME, --image-name IMAGE_NAME
  4232. name of the image to use the artifacts from e.g. core-
  4233. image-sato
  4234. -r ROOTFS_DIR, --rootfs-dir ROOTFS_DIR
  4235. path to the /rootfs dir to use as the .wks rootfs
  4236. source
  4237. -b BOOTIMG_DIR, --bootimg-dir BOOTIMG_DIR
  4238. path to the dir containing the boot artifacts (e.g.
  4239. /EFI or /syslinux dirs) to use as the .wks bootimg
  4240. source
  4241. -k KERNEL_DIR, --kernel-dir KERNEL_DIR
  4242. path to the dir containing the kernel to use in the
  4243. .wks bootimg
  4244. -n NATIVE_SYSROOT, --native-sysroot NATIVE_SYSROOT
  4245. path to the native sysroot containing the tools to use
  4246. to build the image
  4247. -s, --skip-build-check
  4248. skip the build check
  4249. -f, --build-rootfs build rootfs
  4250. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  4251. compress image with specified compressor
  4252. -m, --bmap generate .bmap
  4253. --no-fstab-update Do not change fstab file.
  4254. -v VARS_DIR, --vars VARS_DIR
  4255. directory with <image>.env files that store bitbake
  4256. variables
  4257. -D, --debug output debug information
  4258. .. note::
  4259. You do not need root privileges to run Wic. In fact, you should not
  4260. run as root when using the utility.
  4261. Cooked Mode
  4262. ~~~~~~~~~~~
  4263. Running Wic in cooked mode leverages off artifacts in the Build
  4264. Directory. In other words, you do not have to specify kernel or root
  4265. filesystem locations as part of the command. All you need to provide is
  4266. a kickstart file and the name of the image from which to use artifacts
  4267. by using the "-e" option. Wic looks in the Build Directory (e.g.
  4268. ``tmp/deploy/images/``\ machine) for artifacts.
  4269. The general form of the ``wic`` command using Cooked Mode is as follows:
  4270. ::
  4271. $ wic create wks_file -e IMAGE_NAME
  4272. Where:
  4273. wks_file:
  4274. An OpenEmbedded kickstart file. You can provide
  4275. your own custom file or use a file from a set of
  4276. existing files provided with the Yocto Project
  4277. release.
  4278. required argument:
  4279. -e IMAGE_NAME, --image-name IMAGE_NAME
  4280. name of the image to use the artifacts from e.g. core-
  4281. image-sato
  4282. Using an Existing Kickstart File
  4283. --------------------------------
  4284. If you do not want to create your own kickstart file, you can use an
  4285. existing file provided by the Wic installation. As shipped, kickstart
  4286. files can be found in the :ref:`overview-manual/overview-manual-development-environment:yocto project source repositories` in the
  4287. following two locations:
  4288. ::
  4289. poky/meta-yocto-bsp/wic
  4290. poky/scripts/lib/wic/canned-wks
  4291. Use the following command to list the available kickstart files:
  4292. ::
  4293. $ wic list images
  4294. genericx86 Create an EFI disk image for genericx86*
  4295. beaglebone-yocto Create SD card image for Beaglebone
  4296. edgerouter Create SD card image for Edgerouter
  4297. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  4298. directdisk-gpt Create a 'pcbios' direct disk image
  4299. mkefidisk Create an EFI disk image
  4300. directdisk Create a 'pcbios' direct disk image
  4301. systemd-bootdisk Create an EFI disk image with systemd-boot
  4302. mkhybridiso Create a hybrid ISO image
  4303. sdimage-bootpart Create SD card image with a boot partition
  4304. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  4305. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  4306. When you use an existing file, you
  4307. do not have to use the ``.wks`` extension. Here is an example in Raw
  4308. Mode that uses the ``directdisk`` file:
  4309. ::
  4310. $ wic create directdisk -r rootfs_dir -b bootimg_dir \
  4311. -k kernel_dir -n native_sysroot
  4312. Here are the actual partition language commands used in the
  4313. ``genericx86.wks`` file to generate an image:
  4314. ::
  4315. # short-description: Create an EFI disk image for genericx86*
  4316. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  4317. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  4318. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  4319. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  4320. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  4321. Using the Wic Plugin Interface
  4322. ------------------------------
  4323. You can extend and specialize Wic functionality by using Wic plugins.
  4324. This section explains the Wic plugin interface.
  4325. .. note::
  4326. Wic plugins consist of "source" and "imager" plugins. Imager plugins
  4327. are beyond the scope of this section.
  4328. Source plugins provide a mechanism to customize partition content during
  4329. the Wic image generation process. You can use source plugins to map
  4330. values that you specify using ``--source`` commands in kickstart files
  4331. (i.e. ``*.wks``) to a plugin implementation used to populate a given
  4332. partition.
  4333. .. note::
  4334. If you use plugins that have build-time dependencies (e.g. native
  4335. tools, bootloaders, and so forth) when building a Wic image, you need
  4336. to specify those dependencies using the :term:`WKS_FILE_DEPENDS`
  4337. variable.
  4338. Source plugins are subclasses defined in plugin files. As shipped, the
  4339. Yocto Project provides several plugin files. You can see the source
  4340. plugin files that ship with the Yocto Project
  4341. :yocto_git:`here </poky/tree/scripts/lib/wic/plugins/source>`.
  4342. Each of these plugin files contains source plugins that are designed to
  4343. populate a specific Wic image partition.
  4344. Source plugins are subclasses of the ``SourcePlugin`` class, which is
  4345. defined in the ``poky/scripts/lib/wic/pluginbase.py`` file. For example,
  4346. the ``BootimgEFIPlugin`` source plugin found in the ``bootimg-efi.py``
  4347. file is a subclass of the ``SourcePlugin`` class, which is found in the
  4348. ``pluginbase.py`` file.
  4349. You can also implement source plugins in a layer outside of the Source
  4350. Repositories (external layer). To do so, be sure that your plugin files
  4351. are located in a directory whose path is
  4352. ``scripts/lib/wic/plugins/source/`` within your external layer. When the
  4353. plugin files are located there, the source plugins they contain are made
  4354. available to Wic.
  4355. When the Wic implementation needs to invoke a partition-specific
  4356. implementation, it looks for the plugin with the same name as the
  4357. ``--source`` parameter used in the kickstart file given to that
  4358. partition. For example, if the partition is set up using the following
  4359. command in a kickstart file:
  4360. ::
  4361. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  4362. The methods defined as class
  4363. members of the matching source plugin (i.e. ``bootimg-pcbios``) in the
  4364. ``bootimg-pcbios.py`` plugin file are used.
  4365. To be more concrete, here is the corresponding plugin definition from
  4366. the ``bootimg-pcbios.py`` file for the previous command along with an
  4367. example method called by the Wic implementation when it needs to prepare
  4368. a partition using an implementation-specific function:
  4369. ::
  4370. .
  4371. .
  4372. .
  4373. class BootimgPcbiosPlugin(SourcePlugin):
  4374. """
  4375. Create MBR boot partition and install syslinux on it.
  4376. """
  4377. name = 'bootimg-pcbios'
  4378. .
  4379. .
  4380. .
  4381. @classmethod
  4382. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  4383. oe_builddir, bootimg_dir, kernel_dir,
  4384. rootfs_dir, native_sysroot):
  4385. """
  4386. Called to do the actual content population for a partition i.e. it
  4387. 'prepares' the partition to be incorporated into the image.
  4388. In this case, prepare content for legacy bios boot partition.
  4389. """
  4390. .
  4391. .
  4392. .
  4393. If a
  4394. subclass (plugin) itself does not implement a particular function, Wic
  4395. locates and uses the default version in the superclass. It is for this
  4396. reason that all source plugins are derived from the ``SourcePlugin``
  4397. class.
  4398. The ``SourcePlugin`` class defined in the ``pluginbase.py`` file defines
  4399. a set of methods that source plugins can implement or override. Any
  4400. plugins (subclass of ``SourcePlugin``) that do not implement a
  4401. particular method inherit the implementation of the method from the
  4402. ``SourcePlugin`` class. For more information, see the ``SourcePlugin``
  4403. class in the ``pluginbase.py`` file for details:
  4404. The following list describes the methods implemented in the
  4405. ``SourcePlugin`` class:
  4406. - ``do_prepare_partition()``: Called to populate a partition with
  4407. actual content. In other words, the method prepares the final
  4408. partition image that is incorporated into the disk image.
  4409. - ``do_configure_partition()``: Called before
  4410. ``do_prepare_partition()`` to create custom configuration files for a
  4411. partition (e.g. syslinux or grub configuration files).
  4412. - ``do_install_disk()``: Called after all partitions have been
  4413. prepared and assembled into a disk image. This method provides a hook
  4414. to allow finalization of a disk image (e.g. writing an MBR).
  4415. - ``do_stage_partition()``: Special content-staging hook called
  4416. before ``do_prepare_partition()``. This method is normally empty.
  4417. Typically, a partition just uses the passed-in parameters (e.g. the
  4418. unmodified value of ``bootimg_dir``). However, in some cases, things
  4419. might need to be more tailored. As an example, certain files might
  4420. additionally need to be taken from ``bootimg_dir + /boot``. This hook
  4421. allows those files to be staged in a customized fashion.
  4422. .. note::
  4423. ``get_bitbake_var()`` allows you to access non-standard variables that
  4424. you might want to use for this behavior.
  4425. You can extend the source plugin mechanism. To add more hooks, create
  4426. more source plugin methods within ``SourcePlugin`` and the corresponding
  4427. derived subclasses. The code that calls the plugin methods uses the
  4428. ``plugin.get_source_plugin_methods()`` function to find the method or
  4429. methods needed by the call. Retrieval of those methods is accomplished
  4430. by filling up a dict with keys that contain the method names of
  4431. interest. On success, these will be filled in with the actual methods.
  4432. See the Wic implementation for examples and details.
  4433. Wic Examples
  4434. ------------
  4435. This section provides several examples that show how to use the Wic
  4436. utility. All the examples assume the list of requirements in the
  4437. "`Requirements <#wic-requirements>`__" section have been met. The
  4438. examples assume the previously generated image is
  4439. ``core-image-minimal``.
  4440. Generate an Image using an Existing Kickstart File
  4441. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4442. This example runs in Cooked Mode and uses the ``mkefidisk`` kickstart
  4443. file:
  4444. ::
  4445. $ wic create mkefidisk -e core-image-minimal
  4446. INFO: Building wic-tools...
  4447. .
  4448. .
  4449. .
  4450. INFO: The new image(s) can be found here:
  4451. ./mkefidisk-201804191017-sda.direct
  4452. The following build artifacts were used to create the image(s):
  4453. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  4454. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  4455. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  4456. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4457. INFO: The image(s) were created using OE kickstart file:
  4458. /home/stephano/build/master/openembedded-core/scripts/lib/wic/canned-wks/mkefidisk.wks
  4459. The previous example shows the easiest way to create an image by running
  4460. in cooked mode and supplying a kickstart file and the "-e" option to
  4461. point to the existing build artifacts. Your ``local.conf`` file needs to
  4462. have the :term:`MACHINE` variable set
  4463. to the machine you are using, which is "qemux86" in this example.
  4464. Once the image builds, the output provides image location, artifact use,
  4465. and kickstart file information.
  4466. .. note::
  4467. You should always verify the details provided in the output to make
  4468. sure that the image was indeed created exactly as expected.
  4469. Continuing with the example, you can now write the image from the Build
  4470. Directory onto a USB stick, or whatever media for which you built your
  4471. image, and boot from the media. You can write the image by using
  4472. ``bmaptool`` or ``dd``:
  4473. ::
  4474. $ oe-run-native bmaptool copy mkefidisk-201804191017-sda.direct /dev/sdX
  4475. or ::
  4476. $ sudo dd if=mkefidisk-201804191017-sda.direct of=/dev/sdX
  4477. .. note::
  4478. For more information on how to use the ``bmaptool``
  4479. to flash a device with an image, see the
  4480. ":ref:`dev-manual/common-tasks:flashing images using \`\`bmaptool\`\``"
  4481. section.
  4482. Using a Modified Kickstart File
  4483. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4484. Because partitioned image creation is driven by the kickstart file, it
  4485. is easy to affect image creation by changing the parameters in the file.
  4486. This next example demonstrates that through modification of the
  4487. ``directdisk-gpt`` kickstart file.
  4488. As mentioned earlier, you can use the command ``wic list images`` to
  4489. show the list of existing kickstart files. The directory in which the
  4490. ``directdisk-gpt.wks`` file resides is
  4491. ``scripts/lib/image/canned-wks/``, which is located in the
  4492. :term:`Source Directory` (e.g. ``poky``).
  4493. Because available files reside in this directory, you can create and add
  4494. your own custom files to the directory. Subsequent use of the
  4495. ``wic list images`` command would then include your kickstart files.
  4496. In this example, the existing ``directdisk-gpt`` file already does most
  4497. of what is needed. However, for the hardware in this example, the image
  4498. will need to boot from ``sdb`` instead of ``sda``, which is what the
  4499. ``directdisk-gpt`` kickstart file uses.
  4500. The example begins by making a copy of the ``directdisk-gpt.wks`` file
  4501. in the ``scripts/lib/image/canned-wks`` directory and then by changing
  4502. the lines that specify the target disk from which to boot.
  4503. ::
  4504. $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  4505. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  4506. Next, the example modifies the ``directdisksdb-gpt.wks`` file and
  4507. changes all instances of "``--ondisk sda``" to "``--ondisk sdb``". The
  4508. example changes the following two lines and leaves the remaining lines
  4509. untouched:
  4510. ::
  4511. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  4512. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  4513. Once the lines are changed, the
  4514. example generates the ``directdisksdb-gpt`` image. The command points
  4515. the process at the ``core-image-minimal`` artifacts for the Next Unit of
  4516. Computing (nuc) :term:`MACHINE` the
  4517. ``local.conf``.
  4518. ::
  4519. $ wic create directdisksdb-gpt -e core-image-minimal
  4520. INFO: Building wic-tools...
  4521. .
  4522. .
  4523. .
  4524. Initialising tasks: 100% |#######################################| Time: 0:00:01
  4525. NOTE: Executing SetScene Tasks
  4526. NOTE: Executing RunQueue Tasks
  4527. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  4528. INFO: Creating image(s)...
  4529. INFO: The new image(s) can be found here:
  4530. ./directdisksdb-gpt-201710090938-sdb.direct
  4531. The following build artifacts were used to create the image(s):
  4532. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  4533. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  4534. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  4535. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4536. INFO: The image(s) were created using OE kickstart file:
  4537. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  4538. Continuing with the example, you can now directly ``dd`` the image to a
  4539. USB stick, or whatever media for which you built your image, and boot
  4540. the resulting media:
  4541. ::
  4542. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  4543. 140966+0 records in
  4544. 140966+0 records out
  4545. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  4546. $ sudo eject /dev/sdb
  4547. Using a Modified Kickstart File and Running in Raw Mode
  4548. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4549. This next example manually specifies each build artifact (runs in Raw
  4550. Mode) and uses a modified kickstart file. The example also uses the
  4551. ``-o`` option to cause Wic to create the output somewhere other than the
  4552. default output directory, which is the current directory:
  4553. ::
  4554. $ wic create /home/stephano/my_yocto/test.wks -o /home/stephano/testwic \
  4555. --rootfs-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  4556. --bootimg-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  4557. --kernel-dir /home/stephano/build/master/build/tmp/deploy/images/qemux86 \
  4558. --native-sysroot /home/stephano/build/master/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4559. INFO: Creating image(s)...
  4560. INFO: The new image(s) can be found here:
  4561. /home/stephano/testwic/test-201710091445-sdb.direct
  4562. The following build artifacts were used to create the image(s):
  4563. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  4564. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  4565. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  4566. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  4567. INFO: The image(s) were created using OE kickstart file:
  4568. /home/stephano/my_yocto/test.wks
  4569. For this example,
  4570. :term:`MACHINE` did not have to be
  4571. specified in the ``local.conf`` file since the artifact is manually
  4572. specified.
  4573. Using Wic to Manipulate an Image
  4574. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4575. Wic image manipulation allows you to shorten turnaround time during
  4576. image development. For example, you can use Wic to delete the kernel
  4577. partition of a Wic image and then insert a newly built kernel. This
  4578. saves you time from having to rebuild the entire image each time you
  4579. modify the kernel.
  4580. .. note::
  4581. In order to use Wic to manipulate a Wic image as in this example,
  4582. your development machine must have the ``mtools`` package installed.
  4583. The following example examines the contents of the Wic image, deletes
  4584. the existing kernel, and then inserts a new kernel:
  4585. 1. *List the Partitions:* Use the ``wic ls`` command to list all the
  4586. partitions in the Wic image:
  4587. ::
  4588. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  4589. Num Start End Size Fstype
  4590. 1 1048576 25041919 23993344 fat16
  4591. 2 25165824 72157183 46991360 ext4
  4592. The previous output shows two partitions in the
  4593. ``core-image-minimal-qemux86.wic`` image.
  4594. 2. *Examine a Particular Partition:* Use the ``wic ls`` command again
  4595. but in a different form to examine a particular partition.
  4596. .. note::
  4597. You can get command usage on any Wic command using the following
  4598. form:
  4599. ::
  4600. $ wic help command
  4601. For example, the following command shows you the various ways to
  4602. use the
  4603. wic ls
  4604. command:
  4605. ::
  4606. $ wic help ls
  4607. The following command shows what is in Partition one:
  4608. ::
  4609. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  4610. Volume in drive : is boot
  4611. Volume Serial Number is E894-1809
  4612. Directory for ::/
  4613. libcom32 c32 186500 2017-10-09 16:06
  4614. libutil c32 24148 2017-10-09 16:06
  4615. syslinux cfg 220 2017-10-09 16:06
  4616. vesamenu c32 27104 2017-10-09 16:06
  4617. vmlinuz 6904608 2017-10-09 16:06
  4618. 5 files 7 142 580 bytes
  4619. 16 582 656 bytes free
  4620. The previous output shows five files, with the
  4621. ``vmlinuz`` being the kernel.
  4622. .. note::
  4623. If you see the following error, you need to update or create a
  4624. ``~/.mtoolsrc`` file and be sure to have the line "mtools_skip_check=1"
  4625. in the file. Then, run the Wic command again:
  4626. ::
  4627. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  4628. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  4629. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  4630. 3. *Remove the Old Kernel:* Use the ``wic rm`` command to remove the
  4631. ``vmlinuz`` file (kernel):
  4632. ::
  4633. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  4634. 4. *Add In the New Kernel:* Use the ``wic cp`` command to add the
  4635. updated kernel to the Wic image. Depending on how you built your
  4636. kernel, it could be in different places. If you used ``devtool`` and
  4637. an SDK to build your kernel, it resides in the ``tmp/work`` directory
  4638. of the extensible SDK. If you used ``make`` to build the kernel, the
  4639. kernel will be in the ``workspace/sources`` area.
  4640. The following example assumes ``devtool`` was used to build the
  4641. kernel:
  4642. ::
  4643. 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 \
  4644. ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  4645. Once the new kernel is added back into the image, you can use the
  4646. ``dd`` command or :ref:`bmaptool
  4647. <dev-manual/common-tasks:flashing images using \`\`bmaptool\`\`>`
  4648. to flash your wic image onto an SD card or USB stick and test your
  4649. target.
  4650. .. note::
  4651. Using ``bmaptool`` is generally 10 to 20 times faster than using ``dd``.
  4652. Flashing Images Using ``bmaptool``
  4653. ==================================
  4654. A fast and easy way to flash an image to a bootable device is to use
  4655. Bmaptool, which is integrated into the OpenEmbedded build system.
  4656. Bmaptool is a generic tool that creates a file's block map (bmap) and
  4657. then uses that map to copy the file. As compared to traditional tools
  4658. such as dd or cp, Bmaptool can copy (or flash) large files like raw
  4659. system image files much faster.
  4660. .. note::
  4661. - If you are using Ubuntu or Debian distributions, you can install
  4662. the ``bmap-tools`` package using the following command and then
  4663. use the tool without specifying ``PATH`` even from the root
  4664. account:
  4665. ::
  4666. $ sudo apt-get install bmap-tools
  4667. - If you are unable to install the ``bmap-tools`` package, you will
  4668. need to build Bmaptool before using it. Use the following command:
  4669. ::
  4670. $ bitbake bmap-tools-native
  4671. Following, is an example that shows how to flash a Wic image. Realize
  4672. that while this example uses a Wic image, you can use Bmaptool to flash
  4673. any type of image. Use these steps to flash an image using Bmaptool:
  4674. 1. *Update your local.conf File:* You need to have the following set
  4675. in your ``local.conf`` file before building your image:
  4676. ::
  4677. IMAGE_FSTYPES += "wic wic.bmap"
  4678. 2. *Get Your Image:* Either have your image ready (pre-built with the
  4679. :term:`IMAGE_FSTYPES`
  4680. setting previously mentioned) or take the step to build the image:
  4681. ::
  4682. $ bitbake image
  4683. 3. *Flash the Device:* Flash the device with the image by using Bmaptool
  4684. depending on your particular setup. The following commands assume the
  4685. image resides in the Build Directory's ``deploy/images/`` area:
  4686. - If you have write access to the media, use this command form:
  4687. ::
  4688. $ oe-run-native bmap-tools-native bmaptool copy build-directory/tmp/deploy/images/machine/image.wic /dev/sdX
  4689. - If you do not have write access to the media, set your permissions
  4690. first and then use the same command form:
  4691. ::
  4692. $ sudo chmod 666 /dev/sdX
  4693. $ oe-run-native bmap-tools-native bmaptool copy build-directory/tmp/deploy/images/machine/image.wic /dev/sdX
  4694. For help on the ``bmaptool`` command, use the following command:
  4695. ::
  4696. $ bmaptool --help
  4697. Making Images More Secure
  4698. =========================
  4699. Security is of increasing concern for embedded devices. Consider the
  4700. issues and problems discussed in just this sampling of work found across
  4701. the Internet:
  4702. - *"*\ `Security Risks of Embedded
  4703. Systems <https://www.schneier.com/blog/archives/2014/01/security_risks_9.html>`__\ *"*
  4704. by Bruce Schneier
  4705. - *"*\ `Internet Census
  4706. 2012 <http://census2012.sourceforge.net/paper.html>`__\ *"* by Carna
  4707. Botnet
  4708. - *"*\ `Security Issues for Embedded
  4709. Devices <http://elinux.org/images/6/6f/Security-issues.pdf>`__\ *"*
  4710. by Jake Edge
  4711. When securing your image is of concern, there are steps, tools, and
  4712. variables that you can consider to help you reach the security goals you
  4713. need for your particular device. Not all situations are identical when
  4714. it comes to making an image secure. Consequently, this section provides
  4715. some guidance and suggestions for consideration when you want to make
  4716. your image more secure.
  4717. .. note::
  4718. Because the security requirements and risks are different for every
  4719. type of device, this section cannot provide a complete reference on
  4720. securing your custom OS. It is strongly recommended that you also
  4721. consult other sources of information on embedded Linux system
  4722. hardening and on security.
  4723. General Considerations
  4724. ----------------------
  4725. General considerations exist that help you create more secure images.
  4726. You should consider the following suggestions to help make your device
  4727. more secure:
  4728. - Scan additional code you are adding to the system (e.g. application
  4729. code) by using static analysis tools. Look for buffer overflows and
  4730. other potential security problems.
  4731. - Pay particular attention to the security for any web-based
  4732. administration interface.
  4733. Web interfaces typically need to perform administrative functions and
  4734. tend to need to run with elevated privileges. Thus, the consequences
  4735. resulting from the interface's security becoming compromised can be
  4736. serious. Look for common web vulnerabilities such as
  4737. cross-site-scripting (XSS), unvalidated inputs, and so forth.
  4738. As with system passwords, the default credentials for accessing a
  4739. web-based interface should not be the same across all devices. This
  4740. is particularly true if the interface is enabled by default as it can
  4741. be assumed that many end-users will not change the credentials.
  4742. - Ensure you can update the software on the device to mitigate
  4743. vulnerabilities discovered in the future. This consideration
  4744. especially applies when your device is network-enabled.
  4745. - Ensure you remove or disable debugging functionality before producing
  4746. the final image. For information on how to do this, see the
  4747. "`Considerations Specific to the OpenEmbedded Build
  4748. System <#considerations-specific-to-the-openembedded-build-system>`__"
  4749. section.
  4750. - Ensure you have no network services listening that are not needed.
  4751. - Remove any software from the image that is not needed.
  4752. - Enable hardware support for secure boot functionality when your
  4753. device supports this functionality.
  4754. Security Flags
  4755. --------------
  4756. The Yocto Project has security flags that you can enable that help make
  4757. your build output more secure. The security flags are in the
  4758. ``meta/conf/distro/include/security_flags.inc`` file in your
  4759. :term:`Source Directory` (e.g. ``poky``).
  4760. .. note::
  4761. Depending on the recipe, certain security flags are enabled and
  4762. disabled by default.
  4763. Use the following line in your ``local.conf`` file or in your custom
  4764. distribution configuration file to enable the security compiler and
  4765. linker flags for your build:
  4766. ::
  4767. require conf/distro/include/security_flags.inc
  4768. Considerations Specific to the OpenEmbedded Build System
  4769. --------------------------------------------------------
  4770. You can take some steps that are specific to the OpenEmbedded build
  4771. system to make your images more secure:
  4772. - Ensure "debug-tweaks" is not one of your selected
  4773. :term:`IMAGE_FEATURES`.
  4774. When creating a new project, the default is to provide you with an
  4775. initial ``local.conf`` file that enables this feature using the
  4776. :term:`EXTRA_IMAGE_FEATURES`
  4777. variable with the line:
  4778. ::
  4779. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  4780. To disable that feature, simply comment out that line in your
  4781. ``local.conf`` file, or make sure ``IMAGE_FEATURES`` does not contain
  4782. "debug-tweaks" before producing your final image. Among other things,
  4783. leaving this in place sets the root password as blank, which makes
  4784. logging in for debugging or inspection easy during development but
  4785. also means anyone can easily log in during production.
  4786. - It is possible to set a root password for the image and also to set
  4787. passwords for any extra users you might add (e.g. administrative or
  4788. service type users). When you set up passwords for multiple images or
  4789. users, you should not duplicate passwords.
  4790. To set up passwords, use the
  4791. :ref:`extrausers <ref-classes-extrausers>`
  4792. class, which is the preferred method. For an example on how to set up
  4793. both root and user passwords, see the
  4794. ":ref:`extrausers.bbclass <ref-classes-extrausers>`"
  4795. section.
  4796. .. note::
  4797. When adding extra user accounts or setting a root password, be
  4798. cautious about setting the same password on every device. If you
  4799. do this, and the password you have set is exposed, then every
  4800. device is now potentially compromised. If you need this access but
  4801. want to ensure security, consider setting a different, random
  4802. password for each device. Typically, you do this as a separate
  4803. step after you deploy the image onto the device.
  4804. - Consider enabling a Mandatory Access Control (MAC) framework such as
  4805. SMACK or SELinux and tuning it appropriately for your device's usage.
  4806. You can find more information in the
  4807. :yocto_git:`meta-selinux </meta-selinux/>` layer.
  4808. Tools for Hardening Your Image
  4809. ------------------------------
  4810. The Yocto Project provides tools for making your image more secure. You
  4811. can find these tools in the ``meta-security`` layer of the
  4812. :yocto_git:`Yocto Project Source Repositories <>`.
  4813. Creating Your Own Distribution
  4814. ==============================
  4815. When you build an image using the Yocto Project and do not alter any
  4816. distribution :term:`Metadata`, you are
  4817. creating a Poky distribution. If you wish to gain more control over
  4818. package alternative selections, compile-time options, and other
  4819. low-level configurations, you can create your own distribution.
  4820. To create your own distribution, the basic steps consist of creating
  4821. your own distribution layer, creating your own distribution
  4822. configuration file, and then adding any needed code and Metadata to the
  4823. layer. The following steps provide some more detail:
  4824. - *Create a layer for your new distro:* Create your distribution layer
  4825. so that you can keep your Metadata and code for the distribution
  4826. separate. It is strongly recommended that you create and use your own
  4827. layer for configuration and code. Using your own layer as compared to
  4828. just placing configurations in a ``local.conf`` configuration file
  4829. makes it easier to reproduce the same build configuration when using
  4830. multiple build machines. See the
  4831. ":ref:`dev-manual/common-tasks:creating a general layer using the \`\`bitbake-layers\`\` script`"
  4832. section for information on how to quickly set up a layer.
  4833. - *Create the distribution configuration file:* The distribution
  4834. configuration file needs to be created in the ``conf/distro``
  4835. directory of your layer. You need to name it using your distribution
  4836. name (e.g. ``mydistro.conf``).
  4837. .. note::
  4838. The :term:`DISTRO` variable in your ``local.conf`` file determines the
  4839. name of your distribution.
  4840. You can split out parts of your configuration file into include files
  4841. and then "require" them from within your distribution configuration
  4842. file. Be sure to place the include files in the
  4843. ``conf/distro/include`` directory of your layer. A common example
  4844. usage of include files would be to separate out the selection of
  4845. desired version and revisions for individual recipes.
  4846. Your configuration file needs to set the following required
  4847. variables:
  4848. - :term:`DISTRO_NAME`
  4849. - :term:`DISTRO_VERSION`
  4850. These following variables are optional and you typically set them
  4851. from the distribution configuration file:
  4852. - :term:`DISTRO_FEATURES`
  4853. - :term:`DISTRO_EXTRA_RDEPENDS`
  4854. - :term:`DISTRO_EXTRA_RRECOMMENDS`
  4855. - :term:`TCLIBC`
  4856. .. tip::
  4857. If you want to base your distribution configuration file on the
  4858. very basic configuration from OE-Core, you can use
  4859. ``conf/distro/defaultsetup.conf`` as a reference and just include
  4860. variables that differ as compared to ``defaultsetup.conf``.
  4861. Alternatively, you can create a distribution configuration file
  4862. from scratch using the ``defaultsetup.conf`` file or configuration files
  4863. from other distributions such as Poky or Angstrom as references.
  4864. - *Provide miscellaneous variables:* Be sure to define any other
  4865. variables for which you want to create a default or enforce as part
  4866. of the distribution configuration. You can include nearly any
  4867. variable from the ``local.conf`` file. The variables you use are not
  4868. limited to the list in the previous bulleted item.
  4869. - *Point to Your distribution configuration file:* In your
  4870. ``local.conf`` file in the :term:`Build Directory`,
  4871. set your
  4872. :term:`DISTRO` variable to point to
  4873. your distribution's configuration file. For example, if your
  4874. distribution's configuration file is named ``mydistro.conf``, then
  4875. you point to it as follows:
  4876. ::
  4877. DISTRO = "mydistro"
  4878. - *Add more to the layer if necessary:* Use your layer to hold other
  4879. information needed for the distribution:
  4880. - Add recipes for installing distro-specific configuration files
  4881. that are not already installed by another recipe. If you have
  4882. distro-specific configuration files that are included by an
  4883. existing recipe, you should add an append file (``.bbappend``) for
  4884. those. For general information and recommendations on how to add
  4885. recipes to your layer, see the "`Creating Your Own
  4886. Layer <#creating-your-own-layer>`__" and "`Following Best
  4887. Practices When Creating
  4888. Layers <#best-practices-to-follow-when-creating-layers>`__"
  4889. sections.
  4890. - Add any image recipes that are specific to your distribution.
  4891. - Add a ``psplash`` append file for a branded splash screen. For
  4892. information on append files, see the "`Using .bbappend Files in
  4893. Your Layer <#using-bbappend-files>`__" section.
  4894. - Add any other append files to make custom changes that are
  4895. specific to individual recipes.
  4896. Creating a Custom Template Configuration Directory
  4897. ==================================================
  4898. If you are producing your own customized version of the build system for
  4899. use by other users, you might want to customize the message shown by the
  4900. setup script or you might want to change the template configuration
  4901. files (i.e. ``local.conf`` and ``bblayers.conf``) that are created in a
  4902. new build directory.
  4903. The OpenEmbedded build system uses the environment variable
  4904. ``TEMPLATECONF`` to locate the directory from which it gathers
  4905. configuration information that ultimately ends up in the
  4906. :term:`Build Directory` ``conf`` directory.
  4907. By default, ``TEMPLATECONF`` is set as follows in the ``poky``
  4908. repository:
  4909. ::
  4910. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  4911. This is the
  4912. directory used by the build system to find templates from which to build
  4913. some key configuration files. If you look at this directory, you will
  4914. see the ``bblayers.conf.sample``, ``local.conf.sample``, and
  4915. ``conf-notes.txt`` files. The build system uses these files to form the
  4916. respective ``bblayers.conf`` file, ``local.conf`` file, and display the
  4917. list of BitBake targets when running the setup script.
  4918. To override these default configuration files with configurations you
  4919. want used within every new Build Directory, simply set the
  4920. ``TEMPLATECONF`` variable to your directory. The ``TEMPLATECONF``
  4921. variable is set in the ``.templateconf`` file, which is in the top-level
  4922. :term:`Source Directory` folder
  4923. (e.g. ``poky``). Edit the ``.templateconf`` so that it can locate your
  4924. directory.
  4925. Best practices dictate that you should keep your template configuration
  4926. directory in your custom distribution layer. For example, suppose you
  4927. have a layer named ``meta-mylayer`` located in your home directory and
  4928. you want your template configuration directory named ``myconf``.
  4929. Changing the ``.templateconf`` as follows causes the OpenEmbedded build
  4930. system to look in your directory and base its configuration files on the
  4931. ``*.sample`` configuration files it finds. The final configuration files
  4932. (i.e. ``local.conf`` and ``bblayers.conf`` ultimately still end up in
  4933. your Build Directory, but they are based on your ``*.sample`` files.
  4934. ::
  4935. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  4936. Aside from the ``*.sample`` configuration files, the ``conf-notes.txt``
  4937. also resides in the default ``meta-poky/conf`` directory. The script
  4938. that sets up the build environment (i.e.
  4939. :ref:`structure-core-script`) uses this file to
  4940. display BitBake targets as part of the script output. Customizing this
  4941. ``conf-notes.txt`` file is a good way to make sure your list of custom
  4942. targets appears as part of the script's output.
  4943. Here is the default list of targets displayed as a result of running
  4944. either of the setup scripts:
  4945. ::
  4946. You can now run 'bitbake <target>'
  4947. Common targets are:
  4948. core-image-minimal
  4949. core-image-sato
  4950. meta-toolchain
  4951. meta-ide-support
  4952. Changing the listed common targets is as easy as editing your version of
  4953. ``conf-notes.txt`` in your custom template configuration directory and
  4954. making sure you have ``TEMPLATECONF`` set to your directory.
  4955. Conserving Disk Space During Builds
  4956. ===================================
  4957. To help conserve disk space during builds, you can add the following
  4958. statement to your project's ``local.conf`` configuration file found in
  4959. the :term:`Build Directory`:
  4960. ::
  4961. INHERIT += "rm_work"
  4962. Adding this statement deletes the work directory used for
  4963. building a recipe once the recipe is built. For more information on
  4964. "rm_work", see the
  4965. :ref:`rm_work <ref-classes-rm-work>` class in the
  4966. Yocto Project Reference Manual.
  4967. Working with Packages
  4968. =====================
  4969. This section describes a few tasks that involve packages:
  4970. - `Excluding packages from an
  4971. image <#excluding-packages-from-an-image>`__
  4972. - `Incrementing a binary package
  4973. version <#incrementing-a-binary-package-version>`__
  4974. - `Handling optional module
  4975. packaging <#handling-optional-module-packaging>`__
  4976. - `Using runtime package
  4977. management <#using-runtime-package-management>`__
  4978. - `Generating and using signed
  4979. packages <#generating-and-using-signed-packages>`__
  4980. - `Setting up and running package test
  4981. (ptest) <#testing-packages-with-ptest>`__
  4982. - `Creating node package manager (NPM)
  4983. packages <#creating-node-package-manager-npm-packages>`__
  4984. - `Adding custom metadata to
  4985. packages <#adding-custom-metadata-to-packages>`__
  4986. Excluding Packages from an Image
  4987. --------------------------------
  4988. You might find it necessary to prevent specific packages from being
  4989. installed into an image. If so, you can use several variables to direct
  4990. the build system to essentially ignore installing recommended packages
  4991. or to not install a package at all.
  4992. The following list introduces variables you can use to prevent packages
  4993. from being installed into your image. Each of these variables only works
  4994. with IPK and RPM package types. Support for Debian packages does not
  4995. exist. Also, you can use these variables from your ``local.conf`` file
  4996. or attach them to a specific image recipe by using a recipe name
  4997. override. For more detail on the variables, see the descriptions in the
  4998. Yocto Project Reference Manual's glossary chapter.
  4999. - :term:`BAD_RECOMMENDATIONS`:
  5000. Use this variable to specify "recommended-only" packages that you do
  5001. not want installed.
  5002. - :term:`NO_RECOMMENDATIONS`:
  5003. Use this variable to prevent all "recommended-only" packages from
  5004. being installed.
  5005. - :term:`PACKAGE_EXCLUDE`:
  5006. Use this variable to prevent specific packages from being installed
  5007. regardless of whether they are "recommended-only" or not. You need to
  5008. realize that the build process could fail with an error when you
  5009. prevent the installation of a package whose presence is required by
  5010. an installed package.
  5011. Incrementing a Package Version
  5012. ------------------------------
  5013. This section provides some background on how binary package versioning
  5014. is accomplished and presents some of the services, variables, and
  5015. terminology involved.
  5016. In order to understand binary package versioning, you need to consider
  5017. the following:
  5018. - Binary Package: The binary package that is eventually built and
  5019. installed into an image.
  5020. - Binary Package Version: The binary package version is composed of two
  5021. components - a version and a revision.
  5022. .. note::
  5023. Technically, a third component, the "epoch" (i.e. :term:`PE`) is involved
  5024. but this discussion for the most part ignores ``PE``.
  5025. The version and revision are taken from the
  5026. :term:`PV` and
  5027. :term:`PR` variables, respectively.
  5028. - ``PV``: The recipe version. ``PV`` represents the version of the
  5029. software being packaged. Do not confuse ``PV`` with the binary
  5030. package version.
  5031. - ``PR``: The recipe revision.
  5032. - :term:`SRCPV`: The OpenEmbedded
  5033. build system uses this string to help define the value of ``PV`` when
  5034. the source code revision needs to be included in it.
  5035. - :yocto_wiki:`PR Service </PR_Service>`: A
  5036. network-based service that helps automate keeping package feeds
  5037. compatible with existing package manager applications such as RPM,
  5038. APT, and OPKG.
  5039. Whenever the binary package content changes, the binary package version
  5040. must change. Changing the binary package version is accomplished by
  5041. changing or "bumping" the ``PR`` and/or ``PV`` values. Increasing these
  5042. values occurs one of two ways:
  5043. - Automatically using a Package Revision Service (PR Service).
  5044. - Manually incrementing the ``PR`` and/or ``PV`` variables.
  5045. Given a primary challenge of any build system and its users is how to
  5046. maintain a package feed that is compatible with existing package manager
  5047. applications such as RPM, APT, and OPKG, using an automated system is
  5048. much preferred over a manual system. In either system, the main
  5049. requirement is that binary package version numbering increases in a
  5050. linear fashion and that a number of version components exist that
  5051. support that linear progression. For information on how to ensure
  5052. package revisioning remains linear, see the "`Automatically Incrementing
  5053. a Binary Package Revision
  5054. Number <#automatically-incrementing-a-binary-package-revision-number>`__"
  5055. section.
  5056. The following three sections provide related information on the PR
  5057. Service, the manual method for "bumping" ``PR`` and/or ``PV``, and on
  5058. how to ensure binary package revisioning remains linear.
  5059. Working With a PR Service
  5060. ~~~~~~~~~~~~~~~~~~~~~~~~~
  5061. As mentioned, attempting to maintain revision numbers in the
  5062. :term:`Metadata` is error prone, inaccurate,
  5063. and causes problems for people submitting recipes. Conversely, the PR
  5064. Service automatically generates increasing numbers, particularly the
  5065. revision field, which removes the human element.
  5066. .. note::
  5067. For additional information on using a PR Service, you can see the
  5068. :yocto_wiki:`PR Service </PR_Service>` wiki page.
  5069. The Yocto Project uses variables in order of decreasing priority to
  5070. facilitate revision numbering (i.e.
  5071. :term:`PE`,
  5072. :term:`PV`, and
  5073. :term:`PR` for epoch, version, and
  5074. revision, respectively). The values are highly dependent on the policies
  5075. and procedures of a given distribution and package feed.
  5076. Because the OpenEmbedded build system uses
  5077. ":ref:`signatures <overview-manual/overview-manual-concepts:checksums (signatures)>`", which are
  5078. unique to a given build, the build system knows when to rebuild
  5079. packages. All the inputs into a given task are represented by a
  5080. signature, which can trigger a rebuild when different. Thus, the build
  5081. system itself does not rely on the ``PR``, ``PV``, and ``PE`` numbers to
  5082. trigger a rebuild. The signatures, however, can be used to generate
  5083. these values.
  5084. The PR Service works with both ``OEBasic`` and ``OEBasicHash``
  5085. generators. The value of ``PR`` bumps when the checksum changes and the
  5086. different generator mechanisms change signatures under different
  5087. circumstances.
  5088. As implemented, the build system includes values from the PR Service
  5089. into the ``PR`` field as an addition using the form "``.x``" so ``r0``
  5090. becomes ``r0.1``, ``r0.2`` and so forth. This scheme allows existing
  5091. ``PR`` values to be used for whatever reasons, which include manual
  5092. ``PR`` bumps, should it be necessary.
  5093. By default, the PR Service is not enabled or running. Thus, the packages
  5094. generated are just "self consistent". The build system adds and removes
  5095. packages and there are no guarantees about upgrade paths but images will
  5096. be consistent and correct with the latest changes.
  5097. The simplest form for a PR Service is for it to exist for a single host
  5098. development system that builds the package feed (building system). For
  5099. this scenario, you can enable a local PR Service by setting
  5100. :term:`PRSERV_HOST` in your
  5101. ``local.conf`` file in the :term:`Build Directory`:
  5102. ::
  5103. PRSERV_HOST = "localhost:0"
  5104. Once the service is started, packages will automatically
  5105. get increasing ``PR`` values and BitBake takes care of starting and
  5106. stopping the server.
  5107. If you have a more complex setup where multiple host development systems
  5108. work against a common, shared package feed, you have a single PR Service
  5109. running and it is connected to each building system. For this scenario,
  5110. you need to start the PR Service using the ``bitbake-prserv`` command:
  5111. ::
  5112. bitbake-prserv --host ip --port port --start
  5113. In addition to
  5114. hand-starting the service, you need to update the ``local.conf`` file of
  5115. each building system as described earlier so each system points to the
  5116. server and port.
  5117. It is also recommended you use build history, which adds some sanity
  5118. checks to binary package versions, in conjunction with the server that
  5119. is running the PR Service. To enable build history, add the following to
  5120. each building system's ``local.conf`` file:
  5121. ::
  5122. # It is recommended to activate "buildhistory" for testing the PR service
  5123. INHERIT += "buildhistory"
  5124. BUILDHISTORY_COMMIT = "1"
  5125. For information on build
  5126. history, see the "`Maintaining Build Output
  5127. Quality <#maintaining-build-output-quality>`__" section.
  5128. .. note::
  5129. The OpenEmbedded build system does not maintain ``PR`` information as
  5130. part of the shared state (sstate) packages. If you maintain an sstate
  5131. feed, its expected that either all your building systems that
  5132. contribute to the sstate feed use a shared PR Service, or you do not
  5133. run a PR Service on any of your building systems. Having some systems
  5134. use a PR Service while others do not leads to obvious problems.
  5135. For more information on shared state, see the
  5136. ":ref:`overview-manual/overview-manual-concepts:shared state cache`"
  5137. section in the Yocto Project Overview and Concepts Manual.
  5138. Manually Bumping PR
  5139. ~~~~~~~~~~~~~~~~~~~
  5140. The alternative to setting up a PR Service is to manually "bump" the
  5141. :term:`PR` variable.
  5142. If a committed change results in changing the package output, then the
  5143. value of the PR variable needs to be increased (or "bumped") as part of
  5144. that commit. For new recipes you should add the ``PR`` variable and set
  5145. its initial value equal to "r0", which is the default. Even though the
  5146. default value is "r0", the practice of adding it to a new recipe makes
  5147. it harder to forget to bump the variable when you make changes to the
  5148. recipe in future.
  5149. If you are sharing a common ``.inc`` file with multiple recipes, you can
  5150. also use the ``INC_PR`` variable to ensure that the recipes sharing the
  5151. ``.inc`` file are rebuilt when the ``.inc`` file itself is changed. The
  5152. ``.inc`` file must set ``INC_PR`` (initially to "r0"), and all recipes
  5153. referring to it should set ``PR`` to "${INC_PR}.0" initially,
  5154. incrementing the last number when the recipe is changed. If the ``.inc``
  5155. file is changed then its ``INC_PR`` should be incremented.
  5156. When upgrading the version of a binary package, assuming the ``PV``
  5157. changes, the ``PR`` variable should be reset to "r0" (or "${INC_PR}.0"
  5158. if you are using ``INC_PR``).
  5159. Usually, version increases occur only to binary packages. However, if
  5160. for some reason ``PV`` changes but does not increase, you can increase
  5161. the ``PE`` variable (Package Epoch). The ``PE`` variable defaults to
  5162. "0".
  5163. Binary package version numbering strives to follow the `Debian Version
  5164. Field Policy
  5165. Guidelines <https://www.debian.org/doc/debian-policy/ch-controlfields.html>`__.
  5166. These guidelines define how versions are compared and what "increasing"
  5167. a version means.
  5168. Automatically Incrementing a Package Version Number
  5169. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5170. When fetching a repository, BitBake uses the
  5171. :term:`SRCREV` variable to determine
  5172. the specific source code revision from which to build. You set the
  5173. ``SRCREV`` variable to
  5174. :term:`AUTOREV` to cause the
  5175. OpenEmbedded build system to automatically use the latest revision of
  5176. the software:
  5177. ::
  5178. SRCREV = "${AUTOREV}"
  5179. Furthermore, you need to reference ``SRCPV`` in ``PV`` in order to
  5180. automatically update the version whenever the revision of the source
  5181. code changes. Here is an example:
  5182. ::
  5183. PV = "1.0+git${SRCPV}"
  5184. The OpenEmbedded build system substitutes ``SRCPV`` with the following:
  5185. .. code-block:: none
  5186. AUTOINC+source_code_revision
  5187. The build system replaces the ``AUTOINC``
  5188. with a number. The number used depends on the state of the PR Service:
  5189. - If PR Service is enabled, the build system increments the number,
  5190. which is similar to the behavior of
  5191. :term:`PR`. This behavior results in
  5192. linearly increasing package versions, which is desirable. Here is an
  5193. example:
  5194. .. code-block:: none
  5195. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  5196. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  5197. - If PR Service is not enabled, the build system replaces the
  5198. ``AUTOINC`` placeholder with zero (i.e. "0"). This results in
  5199. changing the package version since the source revision is included.
  5200. However, package versions are not increased linearly. Here is an
  5201. example:
  5202. .. code-block:: none
  5203. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  5204. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  5205. In summary, the OpenEmbedded build system does not track the history of
  5206. binary package versions for this purpose. ``AUTOINC``, in this case, is
  5207. comparable to ``PR``. If PR server is not enabled, ``AUTOINC`` in the
  5208. package version is simply replaced by "0". If PR server is enabled, the
  5209. build system keeps track of the package versions and bumps the number
  5210. when the package revision changes.
  5211. Handling Optional Module Packaging
  5212. ----------------------------------
  5213. Many pieces of software split functionality into optional modules (or
  5214. plugins) and the plugins that are built might depend on configuration
  5215. options. To avoid having to duplicate the logic that determines what
  5216. modules are available in your recipe or to avoid having to package each
  5217. module by hand, the OpenEmbedded build system provides functionality to
  5218. handle module packaging dynamically.
  5219. To handle optional module packaging, you need to do two things:
  5220. - Ensure the module packaging is actually done.
  5221. - Ensure that any dependencies on optional modules from other recipes
  5222. are satisfied by your recipe.
  5223. Making Sure the Packaging is Done
  5224. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5225. To ensure the module packaging actually gets done, you use the
  5226. ``do_split_packages`` function within the ``populate_packages`` Python
  5227. function in your recipe. The ``do_split_packages`` function searches for
  5228. a pattern of files or directories under a specified path and creates a
  5229. package for each one it finds by appending to the
  5230. :term:`PACKAGES` variable and
  5231. setting the appropriate values for ``FILES_packagename``,
  5232. ``RDEPENDS_packagename``, ``DESCRIPTION_packagename``, and so forth.
  5233. Here is an example from the ``lighttpd`` recipe:
  5234. ::
  5235. python populate_packages_prepend () {
  5236. lighttpd_libdir = d.expand('${libdir}')
  5237. do_split_packages(d, lighttpd_libdir, '^mod_(.*).so$',
  5238. 'lighttpd-module-%s', 'Lighttpd module for %s',
  5239. extra_depends='')
  5240. }
  5241. The previous example specifies a number of things in the call to
  5242. ``do_split_packages``.
  5243. - A directory within the files installed by your recipe through
  5244. ``do_install`` in which to search.
  5245. - A regular expression used to match module files in that directory. In
  5246. the example, note the parentheses () that mark the part of the
  5247. expression from which the module name should be derived.
  5248. - A pattern to use for the package names.
  5249. - A description for each package.
  5250. - An empty string for ``extra_depends``, which disables the default
  5251. dependency on the main ``lighttpd`` package. Thus, if a file in
  5252. ``${libdir}`` called ``mod_alias.so`` is found, a package called
  5253. ``lighttpd-module-alias`` is created for it and the
  5254. :term:`DESCRIPTION` is set to
  5255. "Lighttpd module for alias".
  5256. Often, packaging modules is as simple as the previous example. However,
  5257. more advanced options exist that you can use within
  5258. ``do_split_packages`` to modify its behavior. And, if you need to, you
  5259. can add more logic by specifying a hook function that is called for each
  5260. package. It is also perfectly acceptable to call ``do_split_packages``
  5261. multiple times if you have more than one set of modules to package.
  5262. For more examples that show how to use ``do_split_packages``, see the
  5263. ``connman.inc`` file in the ``meta/recipes-connectivity/connman/``
  5264. directory of the ``poky`` :ref:`source repository <overview-manual/overview-manual-development-environment:yocto project source repositories>`. You can
  5265. also find examples in ``meta/classes/kernel.bbclass``.
  5266. Following is a reference that shows ``do_split_packages`` mandatory and
  5267. optional arguments:
  5268. ::
  5269. Mandatory arguments
  5270. root
  5271. The path in which to search
  5272. file_regex
  5273. Regular expression to match searched files.
  5274. Use parentheses () to mark the part of this
  5275. expression that should be used to derive the
  5276. module name (to be substituted where %s is
  5277. used in other function arguments as noted below)
  5278. output_pattern
  5279. Pattern to use for the package names. Must
  5280. include %s.
  5281. description
  5282. Description to set for each package. Must
  5283. include %s.
  5284. Optional arguments
  5285. postinst
  5286. Postinstall script to use for all packages
  5287. (as a string)
  5288. recursive
  5289. True to perform a recursive search - default
  5290. False
  5291. hook
  5292. A hook function to be called for every match.
  5293. The function will be called with the following
  5294. arguments (in the order listed):
  5295. f
  5296. Full path to the file/directory match
  5297. pkg
  5298. The package name
  5299. file_regex
  5300. As above
  5301. output_pattern
  5302. As above
  5303. modulename
  5304. The module name derived using file_regex
  5305. extra_depends
  5306. Extra runtime dependencies (RDEPENDS) to be
  5307. set for all packages. The default value of None
  5308. causes a dependency on the main package
  5309. (${PN}) - if you do not want this, pass empty
  5310. string '' for this parameter.
  5311. aux_files_pattern
  5312. Extra item(s) to be added to FILES for each
  5313. package. Can be a single string item or a list
  5314. of strings for multiple items. Must include %s.
  5315. postrm
  5316. postrm script to use for all packages (as a
  5317. string)
  5318. allow_dirs
  5319. True to allow directories to be matched -
  5320. default False
  5321. prepend
  5322. If True, prepend created packages to PACKAGES
  5323. instead of the default False which appends them
  5324. match_path
  5325. match file_regex on the whole relative path to
  5326. the root rather than just the file name
  5327. aux_files_pattern_verbatim
  5328. Extra item(s) to be added to FILES for each
  5329. package, using the actual derived module name
  5330. rather than converting it to something legal
  5331. for a package name. Can be a single string item
  5332. or a list of strings for multiple items. Must
  5333. include %s.
  5334. allow_links
  5335. True to allow symlinks to be matched - default
  5336. False
  5337. summary
  5338. Summary to set for each package. Must include %s;
  5339. defaults to description if not set.
  5340. Satisfying Dependencies
  5341. ~~~~~~~~~~~~~~~~~~~~~~~
  5342. The second part for handling optional module packaging is to ensure that
  5343. any dependencies on optional modules from other recipes are satisfied by
  5344. your recipe. You can be sure these dependencies are satisfied by using
  5345. the :term:`PACKAGES_DYNAMIC`
  5346. variable. Here is an example that continues with the ``lighttpd`` recipe
  5347. shown earlier:
  5348. ::
  5349. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  5350. The name
  5351. specified in the regular expression can of course be anything. In this
  5352. example, it is ``lighttpd-module-`` and is specified as the prefix to
  5353. ensure that any :term:`RDEPENDS` and
  5354. :term:`RRECOMMENDS` on a package
  5355. name starting with the prefix are satisfied during build time. If you
  5356. are using ``do_split_packages`` as described in the previous section,
  5357. the value you put in ``PACKAGES_DYNAMIC`` should correspond to the name
  5358. pattern specified in the call to ``do_split_packages``.
  5359. Using Runtime Package Management
  5360. --------------------------------
  5361. During a build, BitBake always transforms a recipe into one or more
  5362. packages. For example, BitBake takes the ``bash`` recipe and produces a
  5363. number of packages (e.g. ``bash``, ``bash-bashbug``,
  5364. ``bash-completion``, ``bash-completion-dbg``, ``bash-completion-dev``,
  5365. ``bash-completion-extra``, ``bash-dbg``, and so forth). Not all
  5366. generated packages are included in an image.
  5367. In several situations, you might need to update, add, remove, or query
  5368. the packages on a target device at runtime (i.e. without having to
  5369. generate a new image). Examples of such situations include:
  5370. - You want to provide in-the-field updates to deployed devices (e.g.
  5371. security updates).
  5372. - You want to have a fast turn-around development cycle for one or more
  5373. applications that run on your device.
  5374. - You want to temporarily install the "debug" packages of various
  5375. applications on your device so that debugging can be greatly improved
  5376. by allowing access to symbols and source debugging.
  5377. - You want to deploy a more minimal package selection of your device
  5378. but allow in-the-field updates to add a larger selection for
  5379. customization.
  5380. In all these situations, you have something similar to a more
  5381. traditional Linux distribution in that in-field devices are able to
  5382. receive pre-compiled packages from a server for installation or update.
  5383. Being able to install these packages on a running, in-field device is
  5384. what is termed "runtime package management".
  5385. In order to use runtime package management, you need a host or server
  5386. machine that serves up the pre-compiled packages plus the required
  5387. metadata. You also need package manipulation tools on the target. The
  5388. build machine is a likely candidate to act as the server. However, that
  5389. machine does not necessarily have to be the package server. The build
  5390. machine could push its artifacts to another machine that acts as the
  5391. server (e.g. Internet-facing). In fact, doing so is advantageous for a
  5392. production environment as getting the packages away from the development
  5393. system's build directory prevents accidental overwrites.
  5394. A simple build that targets just one device produces more than one
  5395. package database. In other words, the packages produced by a build are
  5396. separated out into a couple of different package groupings based on
  5397. criteria such as the target's CPU architecture, the target board, or the
  5398. C library used on the target. For example, a build targeting the
  5399. ``qemux86`` device produces the following three package databases:
  5400. ``noarch``, ``i586``, and ``qemux86``. If you wanted your ``qemux86``
  5401. device to be aware of all the packages that were available to it, you
  5402. would need to point it to each of these databases individually. In a
  5403. similar way, a traditional Linux distribution usually is configured to
  5404. be aware of a number of software repositories from which it retrieves
  5405. packages.
  5406. Using runtime package management is completely optional and not required
  5407. for a successful build or deployment in any way. But if you want to make
  5408. use of runtime package management, you need to do a couple things above
  5409. and beyond the basics. The remainder of this section describes what you
  5410. need to do.
  5411. Build Considerations
  5412. ~~~~~~~~~~~~~~~~~~~~
  5413. This section describes build considerations of which you need to be
  5414. aware in order to provide support for runtime package management.
  5415. When BitBake generates packages, it needs to know what format or formats
  5416. to use. In your configuration, you use the
  5417. :term:`PACKAGE_CLASSES`
  5418. variable to specify the format:
  5419. 1. Open the ``local.conf`` file inside your
  5420. :term:`Build Directory` (e.g.
  5421. ``~/poky/build/conf/local.conf``).
  5422. 2. Select the desired package format as follows:
  5423. ::
  5424. PACKAGE_CLASSES ?= "package_packageformat"
  5425. where packageformat can be "ipk", "rpm",
  5426. "deb", or "tar" which are the supported package formats.
  5427. .. note::
  5428. Because the Yocto Project supports four different package formats,
  5429. you can set the variable with more than one argument. However, the
  5430. OpenEmbedded build system only uses the first argument when
  5431. creating an image or Software Development Kit (SDK).
  5432. If you would like your image to start off with a basic package database
  5433. containing the packages in your current build as well as to have the
  5434. relevant tools available on the target for runtime package management,
  5435. you can include "package-management" in the
  5436. :term:`IMAGE_FEATURES`
  5437. variable. Including "package-management" in this configuration variable
  5438. ensures that when the image is assembled for your target, the image
  5439. includes the currently-known package databases as well as the
  5440. target-specific tools required for runtime package management to be
  5441. performed on the target. However, this is not strictly necessary. You
  5442. could start your image off without any databases but only include the
  5443. required on-target package tool(s). As an example, you could include
  5444. "opkg" in your
  5445. :term:`IMAGE_INSTALL` variable
  5446. if you are using the IPK package format. You can then initialize your
  5447. target's package database(s) later once your image is up and running.
  5448. Whenever you perform any sort of build step that can potentially
  5449. generate a package or modify existing package, it is always a good idea
  5450. to re-generate the package index after the build by using the following
  5451. command:
  5452. ::
  5453. $ bitbake package-index
  5454. It might be tempting to build the
  5455. package and the package index at the same time with a command such as
  5456. the following:
  5457. ::
  5458. $ bitbake some-package package-index
  5459. Do not do this as
  5460. BitBake does not schedule the package index for after the completion of
  5461. the package you are building. Consequently, you cannot be sure of the
  5462. package index including information for the package you just built.
  5463. Thus, be sure to run the package update step separately after building
  5464. any packages.
  5465. You can use the
  5466. :term:`PACKAGE_FEED_ARCHS`,
  5467. :term:`PACKAGE_FEED_BASE_PATHS`,
  5468. and
  5469. :term:`PACKAGE_FEED_URIS`
  5470. variables to pre-configure target images to use a package feed. If you
  5471. do not define these variables, then manual steps as described in the
  5472. subsequent sections are necessary to configure the target. You should
  5473. set these variables before building the image in order to produce a
  5474. correctly configured image.
  5475. When your build is complete, your packages reside in the
  5476. ``${TMPDIR}/deploy/packageformat`` directory. For example, if
  5477. ``${``\ :term:`TMPDIR`\ ``}`` is
  5478. ``tmp`` and your selected package type is RPM, then your RPM packages
  5479. are available in ``tmp/deploy/rpm``.
  5480. Host or Server Machine Setup
  5481. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5482. Although other protocols are possible, a server using HTTP typically
  5483. serves packages. If you want to use HTTP, then set up and configure a
  5484. web server such as Apache 2, lighttpd, or Python web server on the
  5485. machine serving the packages.
  5486. To keep things simple, this section describes how to set up a
  5487. Python web server to share package feeds from the developer's
  5488. machine. Although this server might not be the best for a production
  5489. environment, the setup is simple and straight forward. Should you want
  5490. to use a different server more suited for production (e.g. Apache 2,
  5491. Lighttpd, or Nginx), take the appropriate steps to do so.
  5492. From within the build directory where you have built an image based on
  5493. your packaging choice (i.e. the
  5494. :term:`PACKAGE_CLASSES`
  5495. setting), simply start the server. The following example assumes a build
  5496. directory of ``~/poky/build/tmp/deploy/rpm`` and a ``PACKAGE_CLASSES``
  5497. setting of "package_rpm":
  5498. ::
  5499. $ cd ~/poky/build/tmp/deploy/rpm
  5500. $ python3 -m http.server
  5501. Target Setup
  5502. ~~~~~~~~~~~~
  5503. Setting up the target differs depending on the package management
  5504. system. This section provides information for RPM, IPK, and DEB.
  5505. Using RPM
  5506. ^^^^^^^^^
  5507. The `Dandified Packaging
  5508. Tool <https://en.wikipedia.org/wiki/DNF_(software)>`__ (DNF) performs
  5509. runtime package management of RPM packages. In order to use DNF for
  5510. runtime package management, you must perform an initial setup on the
  5511. target machine for cases where the ``PACKAGE_FEED_*`` variables were not
  5512. set as part of the image that is running on the target. This means if
  5513. you built your image and did not not use these variables as part of the
  5514. build and your image is now running on the target, you need to perform
  5515. the steps in this section if you want to use runtime package management.
  5516. .. note::
  5517. For information on the ``PACKAGE_FEED_*`` variables, see
  5518. :term:`PACKAGE_FEED_ARCHS`, :term:`PACKAGE_FEED_BASE_PATHS`, and
  5519. :term:`PACKAGE_FEED_URIS` in the Yocto Project Reference Manual variables
  5520. glossary.
  5521. On the target, you must inform DNF that package databases are available.
  5522. You do this by creating a file named
  5523. ``/etc/yum.repos.d/oe-packages.repo`` and defining the ``oe-packages``.
  5524. As an example, assume the target is able to use the following package
  5525. databases: ``all``, ``i586``, and ``qemux86`` from a server named
  5526. ``my.server``. The specifics for setting up the web server are up to
  5527. you. The critical requirement is that the URIs in the target repository
  5528. configuration point to the correct remote location for the feeds.
  5529. .. note::
  5530. For development purposes, you can point the web server to the build
  5531. system's ``deploy`` directory. However, for production use, it is better to
  5532. copy the package directories to a location outside of the build area and use
  5533. that location. Doing so avoids situations where the build system
  5534. overwrites or changes the ``deploy`` directory.
  5535. When telling DNF where to look for the package databases, you must
  5536. declare individual locations per architecture or a single location used
  5537. for all architectures. You cannot do both:
  5538. - *Create an Explicit List of Architectures:* Define individual base
  5539. URLs to identify where each package database is located:
  5540. .. code-block:: none
  5541. [oe-packages]
  5542. baseurl=http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all
  5543. This example
  5544. informs DNF about individual package databases for all three
  5545. architectures.
  5546. - *Create a Single (Full) Package Index:* Define a single base URL that
  5547. identifies where a full package database is located:
  5548. ::
  5549. [oe-packages]
  5550. baseurl=http://my.server/rpm
  5551. This example informs DNF about a single
  5552. package database that contains all the package index information for
  5553. all supported architectures.
  5554. Once you have informed DNF where to find the package databases, you need
  5555. to fetch them:
  5556. .. code-block:: none
  5557. # dnf makecache
  5558. DNF is now able to find, install, and
  5559. upgrade packages from the specified repository or repositories.
  5560. .. note::
  5561. See the `DNF documentation <https://dnf.readthedocs.io/en/latest/>`__ for
  5562. additional information.
  5563. Using IPK
  5564. ^^^^^^^^^
  5565. The ``opkg`` application performs runtime package management of IPK
  5566. packages. You must perform an initial setup for ``opkg`` on the target
  5567. machine if the
  5568. :term:`PACKAGE_FEED_ARCHS`,
  5569. :term:`PACKAGE_FEED_BASE_PATHS`,
  5570. and
  5571. :term:`PACKAGE_FEED_URIS`
  5572. variables have not been set or the target image was built before the
  5573. variables were set.
  5574. The ``opkg`` application uses configuration files to find available
  5575. package databases. Thus, you need to create a configuration file inside
  5576. the ``/etc/opkg/`` direction, which informs ``opkg`` of any repository
  5577. you want to use.
  5578. As an example, suppose you are serving packages from a ``ipk/``
  5579. directory containing the ``i586``, ``all``, and ``qemux86`` databases
  5580. through an HTTP server named ``my.server``. On the target, create a
  5581. configuration file (e.g. ``my_repo.conf``) inside the ``/etc/opkg/``
  5582. directory containing the following:
  5583. .. code-block:: none
  5584. src/gz all http://my.server/ipk/all
  5585. src/gz i586 http://my.server/ipk/i586
  5586. src/gz qemux86 http://my.server/ipk/qemux86
  5587. Next, instruct ``opkg`` to fetch the
  5588. repository information:
  5589. .. code-block:: none
  5590. # opkg update
  5591. The ``opkg`` application is now able to find, install, and upgrade packages
  5592. from the specified repository.
  5593. Using DEB
  5594. ^^^^^^^^^
  5595. The ``apt`` application performs runtime package management of DEB
  5596. packages. This application uses a source list file to find available
  5597. package databases. You must perform an initial setup for ``apt`` on the
  5598. target machine if the
  5599. :term:`PACKAGE_FEED_ARCHS`,
  5600. :term:`PACKAGE_FEED_BASE_PATHS`,
  5601. and
  5602. :term:`PACKAGE_FEED_URIS`
  5603. variables have not been set or the target image was built before the
  5604. variables were set.
  5605. To inform ``apt`` of the repository you want to use, you might create a
  5606. list file (e.g. ``my_repo.list``) inside the
  5607. ``/etc/apt/sources.list.d/`` directory. As an example, suppose you are
  5608. serving packages from a ``deb/`` directory containing the ``i586``,
  5609. ``all``, and ``qemux86`` databases through an HTTP server named
  5610. ``my.server``. The list file should contain:
  5611. .. code-block:: none
  5612. deb http://my.server/deb/all ./
  5613. deb http://my.server/deb/i586 ./
  5614. deb http://my.server/deb/qemux86 ./
  5615. Next, instruct the ``apt`` application
  5616. to fetch the repository information:
  5617. .. code-block:: none
  5618. # apt-get update
  5619. After this step,
  5620. ``apt`` is able to find, install, and upgrade packages from the
  5621. specified repository.
  5622. Generating and Using Signed Packages
  5623. ------------------------------------
  5624. In order to add security to RPM packages used during a build, you can
  5625. take steps to securely sign them. Once a signature is verified, the
  5626. OpenEmbedded build system can use the package in the build. If security
  5627. fails for a signed package, the build system aborts the build.
  5628. This section describes how to sign RPM packages during a build and how
  5629. to use signed package feeds (repositories) when doing a build.
  5630. Signing RPM Packages
  5631. ~~~~~~~~~~~~~~~~~~~~
  5632. To enable signing RPM packages, you must set up the following
  5633. configurations in either your ``local.config`` or ``distro.config``
  5634. file:
  5635. ::
  5636. # Inherit sign_rpm.bbclass to enable signing functionality
  5637. INHERIT += " sign_rpm"
  5638. # Define the GPG key that will be used for signing.
  5639. RPM_GPG_NAME = "key_name"
  5640. # Provide passphrase for the key
  5641. RPM_GPG_PASSPHRASE = "passphrase"
  5642. .. note::
  5643. Be sure to supply appropriate values for both `key_name` and
  5644. `passphrase`.
  5645. Aside from the ``RPM_GPG_NAME`` and ``RPM_GPG_PASSPHRASE`` variables in
  5646. the previous example, two optional variables related to signing 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. Processing Package Feeds
  5652. ~~~~~~~~~~~~~~~~~~~~~~~~
  5653. In addition to being able to sign RPM packages, you can also enable
  5654. signed package feeds for IPK and RPM packages.
  5655. The steps you need to take to enable signed package feed use are similar
  5656. to the steps used to sign RPM packages. You must define the following in
  5657. your ``local.config`` or ``distro.config`` file:
  5658. ::
  5659. INHERIT += "sign_package_feed"
  5660. PACKAGE_FEED_GPG_NAME = "key_name"
  5661. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "path_to_file_containing_passphrase"
  5662. For signed package feeds, the passphrase must exist in a separate file,
  5663. which is pointed to by the ``PACKAGE_FEED_GPG_PASSPHRASE_FILE``
  5664. variable. Regarding security, keeping a plain text passphrase out of the
  5665. configuration is more secure.
  5666. Aside from the ``PACKAGE_FEED_GPG_NAME`` and
  5667. ``PACKAGE_FEED_GPG_PASSPHRASE_FILE`` variables, three optional variables
  5668. related to signed package feeds exist:
  5669. - *GPG_BIN* Specifies a ``gpg`` binary/wrapper that is executed
  5670. when the package is signed.
  5671. - *GPG_PATH:* Specifies the ``gpg`` home directory used when the
  5672. package is signed.
  5673. - *PACKAGE_FEED_GPG_SIGNATURE_TYPE:* Specifies the type of ``gpg``
  5674. signature. This variable applies only to RPM and IPK package feeds.
  5675. Allowable values for the ``PACKAGE_FEED_GPG_SIGNATURE_TYPE`` are
  5676. "ASC", which is the default and specifies ascii armored, and "BIN",
  5677. which specifies binary.
  5678. Testing Packages With ptest
  5679. ---------------------------
  5680. A Package Test (ptest) runs tests against packages built by the
  5681. OpenEmbedded build system on the target machine. A ptest contains at
  5682. least two items: the actual test, and a shell script (``run-ptest``)
  5683. that starts the test. The shell script that starts the test must not
  5684. contain the actual test - the script only starts the test. On the other
  5685. hand, the test can be anything from a simple shell script that runs a
  5686. binary and checks the output to an elaborate system of test binaries and
  5687. data files.
  5688. The test generates output in the format used by Automake:
  5689. ::
  5690. result: testname
  5691. where the result can be ``PASS``, ``FAIL``, or ``SKIP``, and
  5692. the testname can be any identifying string.
  5693. For a list of Yocto Project recipes that are already enabled with ptest,
  5694. see the :yocto_wiki:`Ptest </Ptest>` wiki page.
  5695. .. note::
  5696. A recipe is "ptest-enabled" if it inherits the
  5697. :ref:`ptest <ref-classes-ptest>` class.
  5698. Adding ptest to Your Build
  5699. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  5700. To add package testing to your build, add the
  5701. :term:`DISTRO_FEATURES` and
  5702. :term:`EXTRA_IMAGE_FEATURES`
  5703. variables to your ``local.conf`` file, which is found in the
  5704. :term:`Build Directory`:
  5705. ::
  5706. DISTRO_FEATURES_append = " ptest"
  5707. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  5708. Once your build is complete, the ptest files are installed into the
  5709. ``/usr/lib/package/ptest`` directory within the image, where ``package``
  5710. is the name of the package.
  5711. Running ptest
  5712. ~~~~~~~~~~~~~
  5713. The ``ptest-runner`` package installs a shell script that loops through
  5714. all installed ptest test suites and runs them in sequence. Consequently,
  5715. you might want to add this package to your image.
  5716. Getting Your Package Ready
  5717. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  5718. In order to enable a recipe to run installed ptests on target hardware,
  5719. you need to prepare the recipes that build the packages you want to
  5720. test. Here is what you have to do for each recipe:
  5721. - *Be sure the recipe inherits
  5722. the* :ref:`ptest <ref-classes-ptest>` *class:*
  5723. Include the following line in each recipe:
  5724. ::
  5725. inherit ptest
  5726. - *Create run-ptest:* This script starts your test. Locate the
  5727. script where you will refer to it using
  5728. :term:`SRC_URI`. Here is an
  5729. example that starts a test for ``dbus``:
  5730. ::
  5731. #!/bin/sh
  5732. cd test
  5733. make -k runtest-TESTS
  5734. - *Ensure dependencies are met:* If the test adds build or runtime
  5735. dependencies that normally do not exist for the package (such as
  5736. requiring "make" to run the test suite), use the
  5737. :term:`DEPENDS` and
  5738. :term:`RDEPENDS` variables in
  5739. your recipe in order for the package to meet the dependencies. Here
  5740. is an example where the package has a runtime dependency on "make":
  5741. ::
  5742. RDEPENDS_${PN}-ptest += "make"
  5743. - *Add a function to build the test suite:* Not many packages support
  5744. cross-compilation of their test suites. Consequently, you usually
  5745. need to add a cross-compilation function to the package.
  5746. Many packages based on Automake compile and run the test suite by
  5747. using a single command such as ``make check``. However, the host
  5748. ``make check`` builds and runs on the same computer, while
  5749. cross-compiling requires that the package is built on the host but
  5750. executed for the target architecture (though often, as in the case
  5751. for ptest, the execution occurs on the host). The built version of
  5752. Automake that ships with the Yocto Project includes a patch that
  5753. separates building and execution. Consequently, packages that use the
  5754. unaltered, patched version of ``make check`` automatically
  5755. cross-compiles.
  5756. Regardless, you still must add a ``do_compile_ptest`` function to
  5757. build the test suite. Add a function similar to the following to your
  5758. recipe:
  5759. ::
  5760. do_compile_ptest() {
  5761. oe_runmake buildtest-TESTS
  5762. }
  5763. - *Ensure special configurations are set:* If the package requires
  5764. special configurations prior to compiling the test code, you must
  5765. insert a ``do_configure_ptest`` function into the recipe.
  5766. - *Install the test suite:* The ``ptest`` class automatically copies
  5767. the file ``run-ptest`` to the target and then runs make
  5768. ``install-ptest`` to run the tests. If this is not enough, you need
  5769. to create a ``do_install_ptest`` function and make sure it gets
  5770. called after the "make install-ptest" completes.
  5771. Creating Node Package Manager (NPM) Packages
  5772. --------------------------------------------
  5773. `NPM <https://en.wikipedia.org/wiki/Npm_(software)>`__ is a package
  5774. manager for the JavaScript programming language. The Yocto Project
  5775. supports the NPM :ref:`fetcher <bitbake:bitbake-user-manual/bitbake-user-manual-fetching:fetchers>`. You can
  5776. use this fetcher in combination with
  5777. :doc:`devtool </ref-manual/ref-devtool-reference>` to create
  5778. recipes that produce NPM packages.
  5779. Two workflows exist that allow you to create NPM packages using
  5780. ``devtool``: the NPM registry modules method and the NPM project code
  5781. method.
  5782. .. note::
  5783. While it is possible to create NPM recipes manually, using
  5784. ``devtool`` is far simpler.
  5785. Additionally, some requirements and caveats exist.
  5786. Requirements and Caveats
  5787. ~~~~~~~~~~~~~~~~~~~~~~~~
  5788. You need to be aware of the following before using ``devtool`` to create
  5789. NPM packages:
  5790. - Of the two methods that you can use ``devtool`` to create NPM
  5791. packages, the registry approach is slightly simpler. However, you
  5792. might consider the project approach because you do not have to
  5793. publish your module in the NPM registry
  5794. (`npm-registry <https://docs.npmjs.com/misc/registry>`_), which
  5795. is NPM's public registry.
  5796. - Be familiar with
  5797. :doc:`devtool </ref-manual/ref-devtool-reference>`.
  5798. - The NPM host tools need the native ``nodejs-npm`` package, which is
  5799. part of the OpenEmbedded environment. You need to get the package by
  5800. cloning the https://github.com/openembedded/meta-openembedded
  5801. repository out of GitHub. Be sure to add the path to your local copy
  5802. to your ``bblayers.conf`` file.
  5803. - ``devtool`` cannot detect native libraries in module dependencies.
  5804. Consequently, you must manually add packages to your recipe.
  5805. - While deploying NPM packages, ``devtool`` cannot determine which
  5806. dependent packages are missing on the target (e.g. the node runtime
  5807. ``nodejs``). Consequently, you need to find out what files are
  5808. missing and be sure they are on the target.
  5809. - Although you might not need NPM to run your node package, it is
  5810. useful to have NPM on your target. The NPM package name is
  5811. ``nodejs-npm``.
  5812. Using the Registry Modules Method
  5813. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5814. This section presents an example that uses the ``cute-files`` module,
  5815. which is a file browser web application.
  5816. .. note::
  5817. You must know the ``cute-files`` module version.
  5818. The first thing you need to do is use ``devtool`` and the NPM fetcher to
  5819. create the recipe:
  5820. ::
  5821. $ devtool add "npm://registry.npmjs.org;package=cute-files;version=1.0.2"
  5822. The
  5823. ``devtool add`` command runs ``recipetool create`` and uses the same
  5824. fetch URI to download each dependency and capture license details where
  5825. possible. The result is a generated recipe.
  5826. The recipe file is fairly simple and contains every license that
  5827. ``recipetool`` finds and includes the licenses in the recipe's
  5828. :term:`LIC_FILES_CHKSUM`
  5829. variables. You need to examine the variables and look for those with
  5830. "unknown" in the :term:`LICENSE`
  5831. field. You need to track down the license information for "unknown"
  5832. modules and manually add the information to the recipe.
  5833. ``recipetool`` creates a "shrinkwrap" file for your recipe. Shrinkwrap
  5834. files capture the version of all dependent modules. Many packages do not
  5835. provide shrinkwrap files. ``recipetool`` create a shrinkwrap file as it
  5836. runs.
  5837. .. note::
  5838. A package is created for each sub-module. This policy is the only
  5839. practical way to have the licenses for all of the dependencies
  5840. represented in the license manifest of the image.
  5841. The ``devtool edit-recipe`` command lets you take a look at the recipe:
  5842. ::
  5843. $ devtool edit-recipe cute-files
  5844. SUMMARY = "Turn any folder on your computer into a cute file browser, available on the local network."
  5845. LICENSE = "MIT & ISC & Unknown"
  5846. LIC_FILES_CHKSUM = "file://LICENSE;md5=71d98c0a1db42956787b1909c74a86ca \
  5847. file://node_modules/toidentifier/LICENSE;md5=1a261071a044d02eb6f2bb47f51a3502 \
  5848. file://node_modules/debug/LICENSE;md5=ddd815a475e7338b0be7a14d8ee35a99 \
  5849. ...
  5850. SRC_URI = " \
  5851. npm://registry.npmjs.org/;package=cute-files;version=${PV} \
  5852. npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \
  5853. "
  5854. S = "${WORKDIR}/npm"
  5855. inherit npm LICENSE_${PN} = "MIT"
  5856. LICENSE_${PN}-accepts = "MIT"
  5857. LICENSE_${PN}-array-flatten = "MIT"
  5858. ...
  5859. LICENSE_${PN}-vary = "MIT"
  5860. Three key points exist in the previous example:
  5861. - :term:`SRC_URI` uses the NPM
  5862. scheme so that the NPM fetcher is used.
  5863. - ``recipetool`` collects all the license information. If a
  5864. sub-module's license is unavailable, the sub-module's name appears in
  5865. the comments.
  5866. - The ``inherit npm`` statement causes the
  5867. :ref:`npm <ref-classes-npm>` class to package
  5868. up all the modules.
  5869. You can run the following command to build the ``cute-files`` package:
  5870. ::
  5871. $ devtool build cute-files
  5872. Remember that ``nodejs`` must be installed on
  5873. the target before your package.
  5874. Assuming 192.168.7.2 for the target's IP address, use the following
  5875. command to deploy your package:
  5876. ::
  5877. $ devtool deploy-target -s cute-files root@192.168.7.2
  5878. Once the package is installed on the target, you can
  5879. test the application:
  5880. .. note::
  5881. Because of a known issue, you cannot simply run ``cute-files`` as you would
  5882. if you had run ``npm install``.
  5883. ::
  5884. $ cd /usr/lib/node_modules/cute-files
  5885. $ node cute-files.js
  5886. On a browser,
  5887. go to ``http://192.168.7.2:3000`` and you see the following:
  5888. .. image:: figures/cute-files-npm-example.png
  5889. :align: center
  5890. You can find the recipe in ``workspace/recipes/cute-files``. You can use
  5891. the recipe in any layer you choose.
  5892. Using the NPM Projects Code Method
  5893. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5894. Although it is useful to package modules already in the NPM registry,
  5895. adding ``node.js`` projects under development is a more common developer
  5896. use case.
  5897. This section covers the NPM projects code method, which is very similar
  5898. to the "registry" approach described in the previous section. In the NPM
  5899. projects method, you provide ``devtool`` with an URL that points to the
  5900. source files.
  5901. Replicating the same example, (i.e. ``cute-files``) use the following
  5902. command:
  5903. ::
  5904. $ devtool add https://github.com/martinaglv/cute-files.git
  5905. The
  5906. recipe this command generates is very similar to the recipe created in
  5907. the previous section. However, the ``SRC_URI`` looks like the following:
  5908. ::
  5909. SRC_URI = " \
  5910. git://github.com/martinaglv/cute-files.git;protocol=https \
  5911. npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \
  5912. "
  5913. In this example,
  5914. the main module is taken from the Git repository and dependencies are
  5915. taken from the NPM registry. Other than those differences, the recipe is
  5916. basically the same between the two methods. You can build and deploy the
  5917. package exactly as described in the previous section that uses the
  5918. registry modules method.
  5919. Adding custom metadata to packages
  5920. ----------------------------------
  5921. The variable
  5922. :term:`PACKAGE_ADD_METADATA`
  5923. can be used to add additional metadata to packages. This is reflected in
  5924. the package control/spec file. To take the ipk format for example, the
  5925. CONTROL file stored inside would contain the additional metadata as
  5926. additional lines.
  5927. The variable can be used in multiple ways, including using suffixes to
  5928. set it for a specific package type and/or package. Note that the order
  5929. of precedence is the same as this list:
  5930. - ``PACKAGE_ADD_METADATA_<PKGTYPE>_<PN>``
  5931. - ``PACKAGE_ADD_METADATA_<PKGTYPE>``
  5932. - ``PACKAGE_ADD_METADATA_<PN>``
  5933. - ``PACKAGE_ADD_METADATA``
  5934. `<PKGTYPE>` is a parameter and expected to be a distinct name of specific
  5935. package type:
  5936. - IPK for .ipk packages
  5937. - DEB for .deb packages
  5938. - RPM for .rpm packages
  5939. `<PN>` is a parameter and expected to be a package name.
  5940. The variable can contain multiple [one-line] metadata fields separated
  5941. by the literal sequence '\\n'. The separator can be redefined using the
  5942. variable flag ``separator``.
  5943. The following is an example that adds two custom fields for ipk
  5944. packages:
  5945. ::
  5946. PACKAGE_ADD_METADATA_IPK = "Vendor: CustomIpk\nGroup:Applications/Spreadsheets"
  5947. Efficiently Fetching Source Files During a Build
  5948. ================================================
  5949. The OpenEmbedded build system works with source files located through
  5950. the :term:`SRC_URI` variable. When
  5951. you build something using BitBake, a big part of the operation is
  5952. locating and downloading all the source tarballs. For images,
  5953. downloading all the source for various packages can take a significant
  5954. amount of time.
  5955. This section shows you how you can use mirrors to speed up fetching
  5956. source files and how you can pre-fetch files all of which leads to more
  5957. efficient use of resources and time.
  5958. Setting up Effective Mirrors
  5959. ----------------------------
  5960. A good deal that goes into a Yocto Project build is simply downloading
  5961. all of the source tarballs. Maybe you have been working with another
  5962. build system (OpenEmbedded or Angstrom) for which you have built up a
  5963. sizable directory of source tarballs. Or, perhaps someone else has such
  5964. a directory for which you have read access. If so, you can save time by
  5965. adding statements to your configuration file so that the build process
  5966. checks local directories first for existing tarballs before checking the
  5967. Internet.
  5968. Here is an efficient way to set it up in your ``local.conf`` file:
  5969. ::
  5970. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  5971. INHERIT += "own-mirrors"
  5972. BB_GENERATE_MIRROR_TARBALLS = "1"
  5973. # BB_NO_NETWORK = "1"
  5974. In the previous example, the
  5975. :term:`BB_GENERATE_MIRROR_TARBALLS`
  5976. variable causes the OpenEmbedded build system to generate tarballs of
  5977. the Git repositories and store them in the
  5978. :term:`DL_DIR` directory. Due to
  5979. performance reasons, generating and storing these tarballs is not the
  5980. build system's default behavior.
  5981. You can also use the
  5982. :term:`PREMIRRORS` variable. For
  5983. an example, see the variable's glossary entry in the Yocto Project
  5984. Reference Manual.
  5985. Getting Source Files and Suppressing the Build
  5986. ----------------------------------------------
  5987. Another technique you can use to ready yourself for a successive string
  5988. of build operations, is to pre-fetch all the source files without
  5989. actually starting a build. This technique lets you work through any
  5990. download issues and ultimately gathers all the source files into your
  5991. download directory :ref:`structure-build-downloads`,
  5992. which is located with :term:`DL_DIR`.
  5993. Use the following BitBake command form to fetch all the necessary
  5994. sources without starting the build:
  5995. ::
  5996. $ bitbake target --runall=fetch
  5997. This
  5998. variation of the BitBake command guarantees that you have all the
  5999. sources for that BitBake target should you disconnect from the Internet
  6000. and want to do the build later offline.
  6001. Selecting an Initialization Manager
  6002. ===================================
  6003. By default, the Yocto Project uses SysVinit as the initialization
  6004. manager. However, support also exists for systemd, which is a full
  6005. replacement for init with parallel starting of services, reduced shell
  6006. overhead and other features that are used by many distributions.
  6007. Within the system, SysVinit treats system components as services. These
  6008. services are maintained as shell scripts stored in the ``/etc/init.d/``
  6009. directory. Services organize into different run levels. This
  6010. organization is maintained by putting links to the services in the
  6011. ``/etc/rcN.d/`` directories, where `N/` is one of the following options:
  6012. "S", "0", "1", "2", "3", "4", "5", or "6".
  6013. .. note::
  6014. Each runlevel has a dependency on the previous runlevel. This
  6015. dependency allows the services to work properly.
  6016. In comparison, systemd treats components as units. Using units is a
  6017. broader concept as compared to using a service. A unit includes several
  6018. different types of entities. Service is one of the types of entities.
  6019. The runlevel concept in SysVinit corresponds to the concept of a target
  6020. in systemd, where target is also a type of supported unit.
  6021. In a SysVinit-based system, services load sequentially (i.e. one by one)
  6022. during init and parallelization is not supported. With systemd, services
  6023. start in parallel. Needless to say, the method can have an impact on
  6024. system startup performance.
  6025. If you want to use SysVinit, you do not have to do anything. But, if you
  6026. want to use systemd, you must take some steps as described in the
  6027. following sections.
  6028. Using systemd Exclusively
  6029. -------------------------
  6030. Set these variables in your distribution configuration file as follows:
  6031. ::
  6032. DISTRO_FEATURES_append = " systemd"
  6033. VIRTUAL-RUNTIME_init_manager = "systemd"
  6034. You can also prevent the SysVinit distribution feature from
  6035. being automatically enabled as follows:
  6036. ::
  6037. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  6038. Doing so removes any
  6039. redundant SysVinit scripts.
  6040. To remove initscripts from your image altogether, set this variable
  6041. also:
  6042. ::
  6043. VIRTUAL-RUNTIME_initscripts = ""
  6044. For information on the backfill variable, see
  6045. :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`.
  6046. Using systemd for the Main Image and Using SysVinit for the Rescue Image
  6047. ------------------------------------------------------------------------
  6048. Set these variables in your distribution configuration file as follows:
  6049. ::
  6050. DISTRO_FEATURES_append = " systemd"
  6051. VIRTUAL-RUNTIME_init_manager = "systemd"
  6052. Doing so causes your main image to use the
  6053. ``packagegroup-core-boot.bb`` recipe and systemd. The rescue/minimal
  6054. image cannot use this package group. However, it can install SysVinit
  6055. and the appropriate packages will have support for both systemd and
  6056. SysVinit.
  6057. Selecting a Device Manager
  6058. ==========================
  6059. The Yocto Project provides multiple ways to manage the device manager
  6060. (``/dev``):
  6061. - Persistent and Pre-Populated\ ``/dev``: For this case, the ``/dev``
  6062. directory is persistent and the required device nodes are created
  6063. during the build.
  6064. - Use ``devtmpfs`` with a Device Manager: For this case, the ``/dev``
  6065. directory is provided by the kernel as an in-memory file system and
  6066. is automatically populated by the kernel at runtime. Additional
  6067. configuration of device nodes is done in user space by a device
  6068. manager like ``udev`` or ``busybox-mdev``.
  6069. Using Persistent and Pre-Populated\ ``/dev``
  6070. --------------------------------------------
  6071. To use the static method for device population, you need to set the
  6072. :term:`USE_DEVFS` variable to "0"
  6073. as follows:
  6074. ::
  6075. USE_DEVFS = "0"
  6076. The content of the resulting ``/dev`` directory is defined in a Device
  6077. Table file. The
  6078. :term:`IMAGE_DEVICE_TABLES`
  6079. variable defines the Device Table to use and should be set in the
  6080. machine or distro configuration file. Alternatively, you can set this
  6081. variable in your ``local.conf`` configuration file.
  6082. If you do not define the ``IMAGE_DEVICE_TABLES`` variable, the default
  6083. ``device_table-minimal.txt`` is used:
  6084. ::
  6085. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  6086. The population is handled by the ``makedevs`` utility during image
  6087. creation:
  6088. Using ``devtmpfs`` and a Device Manager
  6089. ---------------------------------------
  6090. To use the dynamic method for device population, you need to use (or be
  6091. sure to set) the :term:`USE_DEVFS`
  6092. variable to "1", which is the default:
  6093. ::
  6094. USE_DEVFS = "1"
  6095. With this
  6096. setting, the resulting ``/dev`` directory is populated by the kernel
  6097. using ``devtmpfs``. Make sure the corresponding kernel configuration
  6098. variable ``CONFIG_DEVTMPFS`` is set when building you build a Linux
  6099. kernel.
  6100. All devices created by ``devtmpfs`` will be owned by ``root`` and have
  6101. permissions ``0600``.
  6102. To have more control over the device nodes, you can use a device manager
  6103. like ``udev`` or ``busybox-mdev``. You choose the device manager by
  6104. defining the ``VIRTUAL-RUNTIME_dev_manager`` variable in your machine or
  6105. distro configuration file. Alternatively, you can set this variable in
  6106. your ``local.conf`` configuration file:
  6107. ::
  6108. VIRTUAL-RUNTIME_dev_manager = "udev"
  6109. # Some alternative values
  6110. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  6111. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  6112. Using an External SCM
  6113. =====================
  6114. If you're working on a recipe that pulls from an external Source Code
  6115. Manager (SCM), it is possible to have the OpenEmbedded build system
  6116. notice new recipe changes added to the SCM and then build the resulting
  6117. packages that depend on the new recipes by using the latest versions.
  6118. This only works for SCMs from which it is possible to get a sensible
  6119. revision number for changes. Currently, you can do this with Apache
  6120. Subversion (SVN), Git, and Bazaar (BZR) repositories.
  6121. To enable this behavior, the :term:`PV` of
  6122. the recipe needs to reference
  6123. :term:`SRCPV`. Here is an example:
  6124. ::
  6125. PV = "1.2.3+git${SRCPV}"
  6126. Then, you can add the following to your
  6127. ``local.conf``:
  6128. ::
  6129. SRCREV_pn-PN = "${AUTOREV}"
  6130. :term:`PN` is the name of the recipe for
  6131. which you want to enable automatic source revision updating.
  6132. If you do not want to update your local configuration file, you can add
  6133. the following directly to the recipe to finish enabling the feature:
  6134. ::
  6135. SRCREV = "${AUTOREV}"
  6136. The Yocto Project provides a distribution named ``poky-bleeding``, whose
  6137. configuration file contains the line:
  6138. ::
  6139. require conf/distro/include/poky-floating-revisions.inc
  6140. This line pulls in the
  6141. listed include file that contains numerous lines of exactly that form:
  6142. ::
  6143. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  6144. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  6145. #SRCREV_pn-opkg ?= "${AUTOREV}"
  6146. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  6147. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  6148. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  6149. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  6150. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  6151. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  6152. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  6153. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  6154. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  6155. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  6156. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  6157. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  6158. SRCREV_pn-screenshot ?= "${AUTOREV}"
  6159. . . .
  6160. These lines allow you to
  6161. experiment with building a distribution that tracks the latest
  6162. development source for numerous packages.
  6163. .. note::
  6164. The ``poky-bleeding`` distribution is not tested on a regular basis. Keep
  6165. this in mind if you use it.
  6166. Creating a Read-Only Root Filesystem
  6167. ====================================
  6168. Suppose, for security reasons, you need to disable your target device's
  6169. root filesystem's write permissions (i.e. you need a read-only root
  6170. filesystem). Or, perhaps you are running the device's operating system
  6171. from a read-only storage device. For either case, you can customize your
  6172. image for that behavior.
  6173. .. note::
  6174. Supporting a read-only root filesystem requires that the system and
  6175. applications do not try to write to the root filesystem. You must
  6176. configure all parts of the target system to write elsewhere, or to
  6177. gracefully fail in the event of attempting to write to the root
  6178. filesystem.
  6179. Creating the Root Filesystem
  6180. ----------------------------
  6181. To create the read-only root filesystem, simply add the
  6182. "read-only-rootfs" feature to your image, normally in one of two ways.
  6183. The first way is to add the "read-only-rootfs" image feature in the
  6184. image's recipe file via the ``IMAGE_FEATURES`` variable:
  6185. ::
  6186. IMAGE_FEATURES += "read-only-rootfs"
  6187. As an alternative, you can add the same feature
  6188. from within your build directory's ``local.conf`` file with the
  6189. associated ``EXTRA_IMAGE_FEATURES`` variable, as in:
  6190. ::
  6191. EXTRA_IMAGE_FEATURES = "read-only-rootfs"
  6192. For more information on how to use these variables, see the
  6193. ":ref:`dev-manual/common-tasks:Customizing Images Using Custom \`\`IMAGE_FEATURES\`\` and \`\`EXTRA_IMAGE_FEATURES\`\``"
  6194. section. For information on the variables, see
  6195. :term:`IMAGE_FEATURES` and
  6196. :term:`EXTRA_IMAGE_FEATURES`.
  6197. Post-Installation Scripts and Read-Only Root Filesystem
  6198. -------------------------------------------------------
  6199. It is very important that you make sure all post-Installation
  6200. (``pkg_postinst``) scripts for packages that are installed into the
  6201. image can be run at the time when the root filesystem is created during
  6202. the build on the host system. These scripts cannot attempt to run during
  6203. first-boot on the target device. With the "read-only-rootfs" feature
  6204. enabled, the build system checks during root filesystem creation to make
  6205. sure all post-installation scripts succeed. If any of these scripts
  6206. still need to be run after the root filesystem is created, the build
  6207. immediately fails. These build-time checks ensure that the build fails
  6208. rather than the target device fails later during its initial boot
  6209. operation.
  6210. Most of the common post-installation scripts generated by the build
  6211. system for the out-of-the-box Yocto Project are engineered so that they
  6212. can run during root filesystem creation (e.g. post-installation scripts
  6213. for caching fonts). However, if you create and add custom scripts, you
  6214. need to be sure they can be run during this file system creation.
  6215. Here are some common problems that prevent post-installation scripts
  6216. from running during root filesystem creation:
  6217. - *Not using $D in front of absolute paths:* The build system defines
  6218. ``$``\ :term:`D` when the root
  6219. filesystem is created. Furthermore, ``$D`` is blank when the script
  6220. is run on the target device. This implies two purposes for ``$D``:
  6221. ensuring paths are valid in both the host and target environments,
  6222. and checking to determine which environment is being used as a method
  6223. for taking appropriate actions.
  6224. - *Attempting to run processes that are specific to or dependent on the
  6225. target architecture:* You can work around these attempts by using
  6226. native tools, which run on the host system, to accomplish the same
  6227. tasks, or by alternatively running the processes under QEMU, which
  6228. has the ``qemu_run_binary`` function. For more information, see the
  6229. :ref:`qemu <ref-classes-qemu>` class.
  6230. Areas With Write Access
  6231. -----------------------
  6232. With the "read-only-rootfs" feature enabled, any attempt by the target
  6233. to write to the root filesystem at runtime fails. Consequently, you must
  6234. make sure that you configure processes and applications that attempt
  6235. these types of writes do so to directories with write access (e.g.
  6236. ``/tmp`` or ``/var/run``).
  6237. Maintaining Build Output Quality
  6238. ================================
  6239. Many factors can influence the quality of a build. For example, if you
  6240. upgrade a recipe to use a new version of an upstream software package or
  6241. you experiment with some new configuration options, subtle changes can
  6242. occur that you might not detect until later. Consider the case where
  6243. your recipe is using a newer version of an upstream package. In this
  6244. case, a new version of a piece of software might introduce an optional
  6245. dependency on another library, which is auto-detected. If that library
  6246. has already been built when the software is building, the software will
  6247. link to the built library and that library will be pulled into your
  6248. image along with the new software even if you did not want the library.
  6249. The :ref:`buildhistory <ref-classes-buildhistory>`
  6250. class exists to help you maintain the quality of your build output. You
  6251. can use the class to highlight unexpected and possibly unwanted changes
  6252. in the build output. When you enable build history, it records
  6253. information about the contents of each package and image and then
  6254. commits that information to a local Git repository where you can examine
  6255. the information.
  6256. The remainder of this section describes the following:
  6257. - :ref:`How you can enable and disable build history <dev-manual/common-tasks:enabling and disabling build history>`
  6258. - :ref:`How to understand what the build history contains <dev-manual/common-tasks:understanding what the build history contains>`
  6259. - :ref:`How to limit the information used for build history <dev-manual/common-tasks:using build history to gather image information only>`
  6260. - :ref:`How to examine the build history from both a command-line and web interface <dev-manual/common-tasks:examining build history information>`
  6261. Enabling and Disabling Build History
  6262. ------------------------------------
  6263. Build history is disabled by default. To enable it, add the following
  6264. ``INHERIT`` statement and set the
  6265. :term:`BUILDHISTORY_COMMIT`
  6266. variable to "1" at the end of your ``conf/local.conf`` file found in the
  6267. :term:`Build Directory`:
  6268. ::
  6269. INHERIT += "buildhistory"
  6270. BUILDHISTORY_COMMIT = "1"
  6271. Enabling build history as
  6272. previously described causes the OpenEmbedded build system to collect
  6273. build output information and commit it as a single commit to a local
  6274. :ref:`overview-manual/overview-manual-development-environment:git` repository.
  6275. .. note::
  6276. Enabling build history increases your build times slightly,
  6277. particularly for images, and increases the amount of disk space used
  6278. during the build.
  6279. You can disable build history by removing the previous statements from
  6280. your ``conf/local.conf`` file.
  6281. Understanding What the Build History Contains
  6282. ---------------------------------------------
  6283. Build history information is kept in
  6284. ``${``\ :term:`TOPDIR`\ ``}/buildhistory``
  6285. in the Build Directory as defined by the
  6286. :term:`BUILDHISTORY_DIR`
  6287. variable. The following is an example abbreviated listing:
  6288. .. image:: figures/buildhistory.png
  6289. :align: center
  6290. At the top level, a ``metadata-revs`` file exists that lists the
  6291. revisions of the repositories for the enabled layers when the build was
  6292. produced. The rest of the data splits into separate ``packages``,
  6293. ``images`` and ``sdk`` directories, the contents of which are described
  6294. as follows.
  6295. Build History Package Information
  6296. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6297. The history for each package contains a text file that has name-value
  6298. pairs with information about the package. For example,
  6299. ``buildhistory/packages/i586-poky-linux/busybox/busybox/latest``
  6300. contains the following:
  6301. .. code-block:: none
  6302. PV = 1.22.1
  6303. PR = r32
  6304. RPROVIDES =
  6305. RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
  6306. RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
  6307. PKGSIZE = 540168
  6308. FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
  6309. /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
  6310. /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
  6311. /usr/share/pixmaps /usr/share/applications /usr/share/idl \
  6312. /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
  6313. FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
  6314. /etc/busybox.links.nosuid /etc/busybox.links.suid
  6315. Most of these
  6316. name-value pairs correspond to variables used to produce the package.
  6317. The exceptions are ``FILELIST``, which is the actual list of files in
  6318. the package, and ``PKGSIZE``, which is the total size of files in the
  6319. package in bytes.
  6320. A file also exists that corresponds to the recipe from which the package
  6321. came (e.g. ``buildhistory/packages/i586-poky-linux/busybox/latest``):
  6322. .. code-block:: none
  6323. PV = 1.22.1
  6324. PR = r32
  6325. DEPENDS = initscripts kern-tools-native update-rc.d-native \
  6326. virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
  6327. virtual/libc virtual/update-alternatives
  6328. PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
  6329. busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
  6330. busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
  6331. Finally, for those recipes fetched from a version control system (e.g.,
  6332. Git), a file exists that lists source revisions that are specified in
  6333. the recipe and lists the actual revisions used during the build. Listed
  6334. and actual revisions might differ when
  6335. :term:`SRCREV` is set to
  6336. ${:term:`AUTOREV`}. Here is an
  6337. example assuming
  6338. ``buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev``):
  6339. ::
  6340. # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  6341. SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  6342. # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  6343. SRCREV_meta ="a227f20eff056e511d504b2e490f3774ab260d6f"
  6344. You can use the
  6345. ``buildhistory-collect-srcrevs`` command with the ``-a`` option to
  6346. collect the stored ``SRCREV`` values from build history and report them
  6347. in a format suitable for use in global configuration (e.g.,
  6348. ``local.conf`` or a distro include file) to override floating
  6349. ``AUTOREV`` values to a fixed set of revisions. Here is some example
  6350. output from this command:
  6351. ::
  6352. $ buildhistory-collect-srcrevs -a
  6353. # i586-poky-linux
  6354. SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
  6355. SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
  6356. SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
  6357. SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  6358. # x86_64-linux
  6359. SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
  6360. SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
  6361. SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
  6362. SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
  6363. SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
  6364. SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
  6365. SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
  6366. SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
  6367. SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  6368. # qemux86-poky-linux
  6369. SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  6370. SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
  6371. # all-poky-linux
  6372. SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
  6373. .. note::
  6374. Here are some notes on using the ``buildhistory-collect-srcrevs`` command:
  6375. - By default, only values where the ``SRCREV`` was not hardcoded
  6376. (usually when ``AUTOREV`` is used) are reported. Use the ``-a``
  6377. option to see all ``SRCREV`` values.
  6378. - The output statements might not have any effect if overrides are
  6379. applied elsewhere in the build system configuration. Use the
  6380. ``-f`` option to add the ``forcevariable`` override to each output
  6381. line if you need to work around this restriction.
  6382. - The script does apply special handling when building for multiple
  6383. machines. However, the script does place a comment before each set
  6384. of values that specifies which triplet to which they belong as
  6385. previously shown (e.g., ``i586-poky-linux``).
  6386. Build History Image Information
  6387. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6388. The files produced for each image are as follows:
  6389. - ``image-files:`` A directory containing selected files from the root
  6390. filesystem. The files are defined by
  6391. :term:`BUILDHISTORY_IMAGE_FILES`.
  6392. - ``build-id.txt:`` Human-readable information about the build
  6393. configuration and metadata source revisions. This file contains the
  6394. full build header as printed by BitBake.
  6395. - ``*.dot:`` Dependency graphs for the image that are compatible with
  6396. ``graphviz``.
  6397. - ``files-in-image.txt:`` A list of files in the image with
  6398. permissions, owner, group, size, and symlink information.
  6399. - ``image-info.txt:`` A text file containing name-value pairs with
  6400. information about the image. See the following listing example for
  6401. more information.
  6402. - ``installed-package-names.txt:`` A list of installed packages by name
  6403. only.
  6404. - ``installed-package-sizes.txt:`` A list of installed packages ordered
  6405. by size.
  6406. - ``installed-packages.txt:`` A list of installed packages with full
  6407. package filenames.
  6408. .. note::
  6409. Installed package information is able to be gathered and produced
  6410. even if package management is disabled for the final image.
  6411. Here is an example of ``image-info.txt``:
  6412. .. code-block:: none
  6413. DISTRO = poky
  6414. DISTRO_VERSION = 1.7
  6415. USER_CLASSES = buildstats image-mklibs image-prelink
  6416. IMAGE_CLASSES = image_types
  6417. IMAGE_FEATURES = debug-tweaks
  6418. IMAGE_LINGUAS =
  6419. IMAGE_INSTALL = packagegroup-core-boot run-postinsts
  6420. BAD_RECOMMENDATIONS =
  6421. NO_RECOMMENDATIONS =
  6422. PACKAGE_EXCLUDE =
  6423. ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
  6424. write_image_manifest ; buildhistory_list_installed_image ; \
  6425. buildhistory_get_image_installed ; ssh_allow_empty_password; \
  6426. postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
  6427. IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
  6428. IMAGESIZE = 6900
  6429. Other than ``IMAGESIZE``,
  6430. which is the total size of the files in the image in Kbytes, the
  6431. name-value pairs are variables that may have influenced the content of
  6432. the image. This information is often useful when you are trying to
  6433. determine why a change in the package or file listings has occurred.
  6434. Using Build History to Gather Image Information Only
  6435. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6436. As you can see, build history produces image information, including
  6437. dependency graphs, so you can see why something was pulled into the
  6438. image. If you are just interested in this information and not interested
  6439. in collecting specific package or SDK information, you can enable
  6440. writing only image information without any history by adding the
  6441. following to your ``conf/local.conf`` file found in the
  6442. :term:`Build Directory`:
  6443. ::
  6444. INHERIT += "buildhistory"
  6445. BUILDHISTORY_COMMIT = "0"
  6446. BUILDHISTORY_FEATURES = "image"
  6447. Here, you set the
  6448. :term:`BUILDHISTORY_FEATURES`
  6449. variable to use the image feature only.
  6450. Build History SDK Information
  6451. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6452. Build history collects similar information on the contents of SDKs (e.g.
  6453. ``bitbake -c populate_sdk imagename``) as compared to information it
  6454. collects for images. Furthermore, this information differs depending on
  6455. whether an extensible or standard SDK is being produced.
  6456. The following list shows the files produced for SDKs:
  6457. - ``files-in-sdk.txt:`` A list of files in the SDK with permissions,
  6458. owner, group, size, and symlink information. This list includes both
  6459. the host and target parts of the SDK.
  6460. - ``sdk-info.txt:`` A text file containing name-value pairs with
  6461. information about the SDK. See the following listing example for more
  6462. information.
  6463. - ``sstate-task-sizes.txt:`` A text file containing name-value pairs
  6464. with information about task group sizes (e.g. ``do_populate_sysroot``
  6465. tasks have a total size). The ``sstate-task-sizes.txt`` file exists
  6466. only when an extensible SDK is created.
  6467. - ``sstate-package-sizes.txt:`` A text file containing name-value pairs
  6468. with information for the shared-state packages and sizes in the SDK.
  6469. The ``sstate-package-sizes.txt`` file exists only when an extensible
  6470. SDK is created.
  6471. - ``sdk-files:`` A folder that contains copies of the files mentioned
  6472. in ``BUILDHISTORY_SDK_FILES`` if the files are present in the output.
  6473. Additionally, the default value of ``BUILDHISTORY_SDK_FILES`` is
  6474. specific to the extensible SDK although you can set it differently if
  6475. you would like to pull in specific files from the standard SDK.
  6476. The default files are ``conf/local.conf``, ``conf/bblayers.conf``,
  6477. ``conf/auto.conf``, ``conf/locked-sigs.inc``, and
  6478. ``conf/devtool.conf``. Thus, for an extensible SDK, these files get
  6479. copied into the ``sdk-files`` directory.
  6480. - The following information appears under each of the ``host`` and
  6481. ``target`` directories for the portions of the SDK that run on the
  6482. host and on the target, respectively:
  6483. .. note::
  6484. The following files for the most part are empty when producing an
  6485. extensible SDK because this type of SDK is not constructed from
  6486. packages as is the standard SDK.
  6487. - ``depends.dot:`` Dependency graph for the SDK that is compatible
  6488. with ``graphviz``.
  6489. - ``installed-package-names.txt:`` A list of installed packages by
  6490. name only.
  6491. - ``installed-package-sizes.txt:`` A list of installed packages
  6492. ordered by size.
  6493. - ``installed-packages.txt:`` A list of installed packages with full
  6494. package filenames.
  6495. Here is an example of ``sdk-info.txt``:
  6496. .. code-block:: none
  6497. DISTRO = poky
  6498. DISTRO_VERSION = 1.3+snapshot-20130327
  6499. SDK_NAME = poky-glibc-i686-arm
  6500. SDK_VERSION = 1.3+snapshot
  6501. SDKMACHINE =
  6502. SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
  6503. BAD_RECOMMENDATIONS =
  6504. SDKSIZE = 352712
  6505. Other than ``SDKSIZE``, which is
  6506. the total size of the files in the SDK in Kbytes, the name-value pairs
  6507. are variables that might have influenced the content of the SDK. This
  6508. information is often useful when you are trying to determine why a
  6509. change in the package or file listings has occurred.
  6510. Examining Build History Information
  6511. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6512. You can examine build history output from the command line or from a web
  6513. interface.
  6514. To see any changes that have occurred (assuming you have
  6515. :term:`BUILDHISTORY_COMMIT` = "1"),
  6516. you can simply use any Git command that allows you to view the history
  6517. of a repository. Here is one method:
  6518. ::
  6519. $ git log -p
  6520. You need to realize,
  6521. however, that this method does show changes that are not significant
  6522. (e.g. a package's size changing by a few bytes).
  6523. A command-line tool called ``buildhistory-diff`` does exist, though,
  6524. that queries the Git repository and prints just the differences that
  6525. might be significant in human-readable form. Here is an example:
  6526. ::
  6527. $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
  6528. Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
  6529. /etc/anotherpkg.conf was added
  6530. /sbin/anotherpkg was added
  6531. * (installed-package-names.txt):
  6532. * anotherpkg was added
  6533. Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
  6534. anotherpkg was added
  6535. packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
  6536. * PR changed from "r0" to "r1"
  6537. * PV changed from "0.1.10" to "0.1.12"
  6538. packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
  6539. * PR changed from "r0" to "r1"
  6540. * PV changed from "0.1.10" to "0.1.12"
  6541. .. note::
  6542. The ``buildhistory-diff`` tool requires the ``GitPython``
  6543. package. Be sure to install it using Pip3 as follows:
  6544. ::
  6545. $ pip3 install GitPython --user
  6546. Alternatively, you can install ``python3-git`` using the appropriate
  6547. distribution package manager (e.g. ``apt-get``, ``dnf``, or ``zipper``).
  6548. To see changes to the build history using a web interface, follow the
  6549. instruction in the ``README`` file
  6550. :yocto_git:`here </buildhistory-web/>`.
  6551. Here is a sample screenshot of the interface:
  6552. .. image:: figures/buildhistory-web.png
  6553. :align: center
  6554. Performing Automated Runtime Testing
  6555. ====================================
  6556. The OpenEmbedded build system makes available a series of automated
  6557. tests for images to verify runtime functionality. You can run these
  6558. tests on either QEMU or actual target hardware. Tests are written in
  6559. Python making use of the ``unittest`` module, and the majority of them
  6560. run commands on the target system over SSH. This section describes how
  6561. you set up the environment to use these tests, run available tests, and
  6562. write and add your own tests.
  6563. For information on the test and QA infrastructure available within the
  6564. Yocto Project, see the ":ref:`ref-manual/ref-release-process:testing and quality assurance`"
  6565. section in the Yocto Project Reference Manual.
  6566. Enabling Tests
  6567. --------------
  6568. Depending on whether you are planning to run tests using QEMU or on the
  6569. hardware, you have to take different steps to enable the tests. See the
  6570. following subsections for information on how to enable both types of
  6571. tests.
  6572. Enabling Runtime Tests on QEMU
  6573. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6574. In order to run tests, you need to do the following:
  6575. - *Set up to avoid interaction with sudo for networking:* To
  6576. accomplish this, you must do one of the following:
  6577. - Add ``NOPASSWD`` for your user in ``/etc/sudoers`` either for all
  6578. commands or just for ``runqemu-ifup``. You must provide the full
  6579. path as that can change if you are using multiple clones of the
  6580. source repository.
  6581. .. note::
  6582. On some distributions, you also need to comment out "Defaults
  6583. requiretty" in ``/etc/sudoers``.
  6584. - Manually configure a tap interface for your system.
  6585. - Run as root the script in ``scripts/runqemu-gen-tapdevs``, which
  6586. should generate a list of tap devices. This is the option
  6587. typically chosen for Autobuilder-type environments.
  6588. .. note::
  6589. - Be sure to use an absolute path when calling this script
  6590. with sudo.
  6591. - The package recipe ``qemu-helper-native`` is required to run
  6592. this script. Build the package using the following command:
  6593. ::
  6594. $ bitbake qemu-helper-native
  6595. - *Set the DISPLAY variable:* You need to set this variable so that
  6596. you have an X server available (e.g. start ``vncserver`` for a
  6597. headless machine).
  6598. - *Be sure your host's firewall accepts incoming connections from
  6599. 192.168.7.0/24:* Some of the tests (in particular DNF tests) start an
  6600. HTTP server on a random high number port, which is used to serve
  6601. files to the target. The DNF module serves
  6602. ``${WORKDIR}/oe-rootfs-repo`` so it can run DNF channel commands.
  6603. That means your host's firewall must accept incoming connections from
  6604. 192.168.7.0/24, which is the default IP range used for tap devices by
  6605. ``runqemu``.
  6606. - *Be sure your host has the correct packages installed:* Depending
  6607. your host's distribution, you need to have the following packages
  6608. installed:
  6609. - Ubuntu and Debian: ``sysstat`` and ``iproute2``
  6610. - OpenSUSE: ``sysstat`` and ``iproute2``
  6611. - Fedora: ``sysstat`` and ``iproute``
  6612. - CentOS: ``sysstat`` and ``iproute``
  6613. Once you start running the tests, the following happens:
  6614. 1. A copy of the root filesystem is written to ``${WORKDIR}/testimage``.
  6615. 2. The image is booted under QEMU using the standard ``runqemu`` script.
  6616. 3. A default timeout of 500 seconds occurs to allow for the boot process
  6617. to reach the login prompt. You can change the timeout period by
  6618. setting
  6619. :term:`TEST_QEMUBOOT_TIMEOUT`
  6620. in the ``local.conf`` file.
  6621. 4. Once the boot process is reached and the login prompt appears, the
  6622. tests run. The full boot log is written to
  6623. ``${WORKDIR}/testimage/qemu_boot_log``.
  6624. 5. Each test module loads in the order found in ``TEST_SUITES``. You can
  6625. find the full output of the commands run over SSH in
  6626. ``${WORKDIR}/testimgage/ssh_target_log``.
  6627. 6. If no failures occur, the task running the tests ends successfully.
  6628. You can find the output from the ``unittest`` in the task log at
  6629. ``${WORKDIR}/temp/log.do_testimage``.
  6630. Enabling Runtime Tests on Hardware
  6631. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6632. The OpenEmbedded build system can run tests on real hardware, and for
  6633. certain devices it can also deploy the image to be tested onto the
  6634. device beforehand.
  6635. For automated deployment, a "master image" is installed onto the
  6636. hardware once as part of setup. Then, each time tests are to be run, the
  6637. following occurs:
  6638. 1. The master image is booted into and used to write the image to be
  6639. tested to a second partition.
  6640. 2. The device is then rebooted using an external script that you need to
  6641. provide.
  6642. 3. The device boots into the image to be tested.
  6643. When running tests (independent of whether the image has been deployed
  6644. automatically or not), the device is expected to be connected to a
  6645. network on a pre-determined IP address. You can either use static IP
  6646. addresses written into the image, or set the image to use DHCP and have
  6647. your DHCP server on the test network assign a known IP address based on
  6648. the MAC address of the device.
  6649. In order to run tests on hardware, you need to set ``TEST_TARGET`` to an
  6650. appropriate value. For QEMU, you do not have to change anything, the
  6651. default value is "qemu". For running tests on hardware, the following
  6652. options exist:
  6653. - *"simpleremote":* Choose "simpleremote" if you are going to run tests
  6654. on a target system that is already running the image to be tested and
  6655. is available on the network. You can use "simpleremote" in
  6656. conjunction with either real hardware or an image running within a
  6657. separately started QEMU or any other virtual machine manager.
  6658. - *"SystemdbootTarget":* Choose "SystemdbootTarget" if your hardware is
  6659. an EFI-based machine with ``systemd-boot`` as bootloader and
  6660. ``core-image-testmaster`` (or something similar) is installed. Also,
  6661. your hardware under test must be in a DHCP-enabled network that gives
  6662. it the same IP address for each reboot.
  6663. If you choose "SystemdbootTarget", there are additional requirements
  6664. and considerations. See the "`Selecting
  6665. SystemdbootTarget <#selecting-systemdboottarget>`__" section, which
  6666. follows, for more information.
  6667. - *"BeagleBoneTarget":* Choose "BeagleBoneTarget" if you are deploying
  6668. images and running tests on the BeagleBone "Black" or original
  6669. "White" hardware. For information on how to use these tests, see the
  6670. comments at the top of the BeagleBoneTarget
  6671. ``meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py`` file.
  6672. - *"EdgeRouterTarget":* Choose "EdgeRouterTarget" if you are deploying
  6673. images and running tests on the Ubiquiti Networks EdgeRouter Lite.
  6674. For information on how to use these tests, see the comments at the
  6675. top of the EdgeRouterTarget
  6676. ``meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py`` file.
  6677. - *"GrubTarget":* Choose "GrubTarget" if you are deploying images and running
  6678. tests on any generic PC that boots using GRUB. For information on how
  6679. to use these tests, see the comments at the top of the GrubTarget
  6680. ``meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py`` file.
  6681. - *"your-target":* Create your own custom target if you want to run
  6682. tests when you are deploying images and running tests on a custom
  6683. machine within your BSP layer. To do this, you need to add a Python
  6684. unit that defines the target class under ``lib/oeqa/controllers/``
  6685. within your layer. You must also provide an empty ``__init__.py``.
  6686. For examples, see files in ``meta-yocto-bsp/lib/oeqa/controllers/``.
  6687. Selecting SystemdbootTarget
  6688. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6689. If you did not set ``TEST_TARGET`` to "SystemdbootTarget", then you do
  6690. not need any information in this section. You can skip down to the
  6691. "`Running Tests <#qemu-image-running-tests>`__" section.
  6692. If you did set ``TEST_TARGET`` to "SystemdbootTarget", you also need to
  6693. perform a one-time setup of your master image by doing the following:
  6694. 1. *Set EFI_PROVIDER:* Be sure that ``EFI_PROVIDER`` is as follows:
  6695. ::
  6696. EFI_PROVIDER = "systemd-boot"
  6697. 2. *Build the master image:* Build the ``core-image-testmaster`` image.
  6698. The ``core-image-testmaster`` recipe is provided as an example for a
  6699. "master" image and you can customize the image recipe as you would
  6700. any other recipe.
  6701. Here are the image recipe requirements:
  6702. - Inherits ``core-image`` so that kernel modules are installed.
  6703. - Installs normal linux utilities not busybox ones (e.g. ``bash``,
  6704. ``coreutils``, ``tar``, ``gzip``, and ``kmod``).
  6705. - Uses a custom Initial RAM Disk (initramfs) image with a custom
  6706. installer. A normal image that you can install usually creates a
  6707. single rootfs partition. This image uses another installer that
  6708. creates a specific partition layout. Not all Board Support
  6709. Packages (BSPs) can use an installer. For such cases, you need to
  6710. manually create the following partition layout on the target:
  6711. - First partition mounted under ``/boot``, labeled "boot".
  6712. - The main rootfs partition where this image gets installed,
  6713. which is mounted under ``/``.
  6714. - Another partition labeled "testrootfs" where test images get
  6715. deployed.
  6716. 3. *Install image:* Install the image that you just built on the target
  6717. system.
  6718. The final thing you need to do when setting ``TEST_TARGET`` to
  6719. "SystemdbootTarget" is to set up the test image:
  6720. 1. *Set up your local.conf file:* Make sure you have the following
  6721. statements in your ``local.conf`` file:
  6722. ::
  6723. IMAGE_FSTYPES += "tar.gz"
  6724. INHERIT += "testimage"
  6725. TEST_TARGET = "SystemdbootTarget"
  6726. TEST_TARGET_IP = "192.168.2.3"
  6727. 2. *Build your test image:* Use BitBake to build the image:
  6728. ::
  6729. $ bitbake core-image-sato
  6730. Power Control
  6731. ~~~~~~~~~~~~~
  6732. For most hardware targets other than "simpleremote", you can control
  6733. power:
  6734. - You can use ``TEST_POWERCONTROL_CMD`` together with
  6735. ``TEST_POWERCONTROL_EXTRA_ARGS`` as a command that runs on the host
  6736. and does power cycling. The test code passes one argument to that
  6737. command: off, on or cycle (off then on). Here is an example that
  6738. could appear in your ``local.conf`` file:
  6739. ::
  6740. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  6741. In this example, the expect
  6742. script does the following:
  6743. .. code-block:: shell
  6744. ssh test@10.11.12.1 "pyctl nuc1 arg"
  6745. It then runs a Python script that controls power for a label called
  6746. ``nuc1``.
  6747. .. note::
  6748. You need to customize ``TEST_POWERCONTROL_CMD`` and
  6749. ``TEST_POWERCONTROL_EXTRA_ARGS`` for your own setup. The one requirement
  6750. is that it accepts "on", "off", and "cycle" as the last argument.
  6751. - When no command is defined, it connects to the device over SSH and
  6752. uses the classic reboot command to reboot the device. Classic reboot
  6753. is fine as long as the machine actually reboots (i.e. the SSH test
  6754. has not failed). It is useful for scenarios where you have a simple
  6755. setup, typically with a single board, and where some manual
  6756. interaction is okay from time to time.
  6757. If you have no hardware to automatically perform power control but still
  6758. wish to experiment with automated hardware testing, you can use the
  6759. ``dialog-power-control`` script that shows a dialog prompting you to perform
  6760. the required power action. This script requires either KDialog or Zenity
  6761. to be installed. To use this script, set the
  6762. :term:`TEST_POWERCONTROL_CMD`
  6763. variable as follows:
  6764. ::
  6765. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  6766. Serial Console Connection
  6767. ~~~~~~~~~~~~~~~~~~~~~~~~~
  6768. For test target classes requiring a serial console to interact with the
  6769. bootloader (e.g. BeagleBoneTarget, EdgeRouterTarget, and GrubTarget),
  6770. you need to specify a command to use to connect to the serial console of
  6771. the target machine by using the
  6772. :term:`TEST_SERIALCONTROL_CMD`
  6773. variable and optionally the
  6774. :term:`TEST_SERIALCONTROL_EXTRA_ARGS`
  6775. variable.
  6776. These cases could be a serial terminal program if the machine is
  6777. connected to a local serial port, or a ``telnet`` or ``ssh`` command
  6778. connecting to a remote console server. Regardless of the case, the
  6779. command simply needs to connect to the serial console and forward that
  6780. connection to standard input and output as any normal terminal program
  6781. does. For example, to use the picocom terminal program on serial device
  6782. ``/dev/ttyUSB0`` at 115200bps, you would set the variable as follows:
  6783. ::
  6784. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  6785. For local
  6786. devices where the serial port device disappears when the device reboots,
  6787. an additional "serdevtry" wrapper script is provided. To use this
  6788. wrapper, simply prefix the terminal command with
  6789. ``${COREBASE}/scripts/contrib/serdevtry``:
  6790. ::
  6791. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b 115200 /dev/ttyUSB0"
  6792. Running Tests
  6793. -------------
  6794. You can start the tests automatically or manually:
  6795. - *Automatically running tests:* To run the tests automatically after
  6796. the OpenEmbedded build system successfully creates an image, first
  6797. set the
  6798. :term:`TESTIMAGE_AUTO`
  6799. variable to "1" in your ``local.conf`` file in the
  6800. :term:`Build Directory`:
  6801. ::
  6802. TESTIMAGE_AUTO = "1"
  6803. Next, build your image. If the image successfully builds, the
  6804. tests run:
  6805. ::
  6806. bitbake core-image-sato
  6807. - *Manually running tests:* To manually run the tests, first globally
  6808. inherit the
  6809. :ref:`testimage <ref-classes-testimage*>` class
  6810. by editing your ``local.conf`` file:
  6811. ::
  6812. INHERIT += "testimage"
  6813. Next, use BitBake to run the tests:
  6814. ::
  6815. bitbake -c testimage image
  6816. All test files reside in ``meta/lib/oeqa/runtime`` in the
  6817. :term:`Source Directory`. A test name maps
  6818. directly to a Python module. Each test module may contain a number of
  6819. individual tests. Tests are usually grouped together by the area tested
  6820. (e.g tests for systemd reside in ``meta/lib/oeqa/runtime/systemd.py``).
  6821. You can add tests to any layer provided you place them in the proper
  6822. area and you extend :term:`BBPATH` in
  6823. the ``local.conf`` file as normal. Be sure that tests reside in
  6824. ``layer/lib/oeqa/runtime``.
  6825. .. note::
  6826. Be sure that module names do not collide with module names used in
  6827. the default set of test modules in ``meta/lib/oeqa/runtime``.
  6828. You can change the set of tests run by appending or overriding
  6829. :term:`TEST_SUITES` variable in
  6830. ``local.conf``. Each name in ``TEST_SUITES`` represents a required test
  6831. for the image. Test modules named within ``TEST_SUITES`` cannot be
  6832. skipped even if a test is not suitable for an image (e.g. running the
  6833. RPM tests on an image without ``rpm``). Appending "auto" to
  6834. ``TEST_SUITES`` causes the build system to try to run all tests that are
  6835. suitable for the image (i.e. each test module may elect to skip itself).
  6836. The order you list tests in ``TEST_SUITES`` is important and influences
  6837. test dependencies. Consequently, tests that depend on other tests should
  6838. be added after the test on which they depend. For example, since the
  6839. ``ssh`` test depends on the ``ping`` test, "ssh" needs to come after
  6840. "ping" in the list. The test class provides no re-ordering or dependency
  6841. handling.
  6842. .. note::
  6843. Each module can have multiple classes with multiple test methods.
  6844. And, Python ``unittest`` rules apply.
  6845. Here are some things to keep in mind when running tests:
  6846. - The default tests for the image are defined as:
  6847. ::
  6848. DEFAULT_TEST_SUITES_pn-image = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  6849. - Add your own test to the list of the by using the following:
  6850. ::
  6851. TEST_SUITES_append = " mytest"
  6852. - Run a specific list of tests as follows:
  6853. ::
  6854. TEST_SUITES = "test1 test2 test3"
  6855. Remember, order is important. Be sure to place a test that is
  6856. dependent on another test later in the order.
  6857. Exporting Tests
  6858. ---------------
  6859. You can export tests so that they can run independently of the build
  6860. system. Exporting tests is required if you want to be able to hand the
  6861. test execution off to a scheduler. You can only export tests that are
  6862. defined in :term:`TEST_SUITES`.
  6863. If your image is already built, make sure the following are set in your
  6864. ``local.conf`` file:
  6865. ::
  6866. INHERIT += "testexport"
  6867. TEST_TARGET_IP = "IP-address-for-the-test-target"
  6868. TEST_SERVER_IP = "IP-address-for-the-test-server"
  6869. You can then export the tests with the
  6870. following BitBake command form:
  6871. ::
  6872. $ bitbake image -c testexport
  6873. Exporting the tests places them in the
  6874. :term:`Build Directory` in
  6875. ``tmp/testexport/``\ image, which is controlled by the
  6876. ``TEST_EXPORT_DIR`` variable.
  6877. You can now run the tests outside of the build environment:
  6878. ::
  6879. $ cd tmp/testexport/image
  6880. $ ./runexported.py testdata.json
  6881. Here is a complete example that shows IP addresses and uses the
  6882. ``core-image-sato`` image:
  6883. ::
  6884. INHERIT += "testexport"
  6885. TEST_TARGET_IP = "192.168.7.2"
  6886. TEST_SERVER_IP = "192.168.7.1"
  6887. Use BitBake to export the tests:
  6888. ::
  6889. $ bitbake core-image-sato -c testexport
  6890. Run the tests outside of
  6891. the build environment using the following:
  6892. ::
  6893. $ cd tmp/testexport/core-image-sato
  6894. $ ./runexported.py testdata.json
  6895. Writing New Tests
  6896. -----------------
  6897. As mentioned previously, all new test files need to be in the proper
  6898. place for the build system to find them. New tests for additional
  6899. functionality outside of the core should be added to the layer that adds
  6900. the functionality, in ``layer/lib/oeqa/runtime`` (as long as
  6901. :term:`BBPATH` is extended in the
  6902. layer's ``layer.conf`` file as normal). Just remember the following:
  6903. - Filenames need to map directly to test (module) names.
  6904. - Do not use module names that collide with existing core tests.
  6905. - Minimally, an empty ``__init__.py`` file must exist in the runtime
  6906. directory.
  6907. To create a new test, start by copying an existing module (e.g.
  6908. ``syslog.py`` or ``gcc.py`` are good ones to use). Test modules can use
  6909. code from ``meta/lib/oeqa/utils``, which are helper classes.
  6910. .. note::
  6911. Structure shell commands such that you rely on them and they return a
  6912. single code for success. Be aware that sometimes you will need to
  6913. parse the output. See the ``df.py`` and ``date.py`` modules for examples.
  6914. You will notice that all test classes inherit ``oeRuntimeTest``, which
  6915. is found in ``meta/lib/oetest.py``. This base class offers some helper
  6916. attributes, which are described in the following sections:
  6917. Class Methods
  6918. ~~~~~~~~~~~~~
  6919. Class methods are as follows:
  6920. - *hasPackage(pkg):* Returns "True" if ``pkg`` is in the installed
  6921. package list of the image, which is based on the manifest file that
  6922. is generated during the ``do_rootfs`` task.
  6923. - *hasFeature(feature):* Returns "True" if the feature is in
  6924. :term:`IMAGE_FEATURES` or
  6925. :term:`DISTRO_FEATURES`.
  6926. Class Attributes
  6927. ~~~~~~~~~~~~~~~~
  6928. Class attributes are as follows:
  6929. - *pscmd:* Equals "ps -ef" if ``procps`` is installed in the image.
  6930. Otherwise, ``pscmd`` equals "ps" (busybox).
  6931. - *tc:* The called test context, which gives access to the
  6932. following attributes:
  6933. - *d:* The BitBake datastore, which allows you to use stuff such
  6934. as ``oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")``.
  6935. - *testslist and testsrequired:* Used internally. The tests
  6936. do not need these.
  6937. - *filesdir:* The absolute path to
  6938. ``meta/lib/oeqa/runtime/files``, which contains helper files for
  6939. tests meant for copying on the target such as small files written
  6940. in C for compilation.
  6941. - *target:* The target controller object used to deploy and
  6942. start an image on a particular target (e.g. Qemu, SimpleRemote,
  6943. and SystemdbootTarget). Tests usually use the following:
  6944. - *ip:* The target's IP address.
  6945. - *server_ip:* The host's IP address, which is usually used
  6946. by the DNF test suite.
  6947. - *run(cmd, timeout=None):* The single, most used method.
  6948. This command is a wrapper for: ``ssh root@host "cmd"``. The
  6949. command returns a tuple: (status, output), which are what their
  6950. names imply - the return code of "cmd" and whatever output it
  6951. produces. The optional timeout argument represents the number
  6952. of seconds the test should wait for "cmd" to return. If the
  6953. argument is "None", the test uses the default instance's
  6954. timeout period, which is 300 seconds. If the argument is "0",
  6955. the test runs until the command returns.
  6956. - *copy_to(localpath, remotepath):*
  6957. ``scp localpath root@ip:remotepath``.
  6958. - *copy_from(remotepath, localpath):*
  6959. ``scp root@host:remotepath localpath``.
  6960. Instance Attributes
  6961. ~~~~~~~~~~~~~~~~~~~
  6962. A single instance attribute exists, which is ``target``. The ``target``
  6963. instance attribute is identical to the class attribute of the same name,
  6964. which is described in the previous section. This attribute exists as
  6965. both an instance and class attribute so tests can use
  6966. ``self.target.run(cmd)`` in instance methods instead of
  6967. ``oeRuntimeTest.tc.target.run(cmd)``.
  6968. Installing Packages in the DUT Without the Package Manager
  6969. ----------------------------------------------------------
  6970. When a test requires a package built by BitBake, it is possible to
  6971. install that package. Installing the package does not require a package
  6972. manager be installed in the device under test (DUT). It does, however,
  6973. require an SSH connection and the target must be using the
  6974. ``sshcontrol`` class.
  6975. .. note::
  6976. This method uses ``scp`` to copy files from the host to the target, which
  6977. causes permissions and special attributes to be lost.
  6978. A JSON file is used to define the packages needed by a test. This file
  6979. must be in the same path as the file used to define the tests.
  6980. Furthermore, the filename must map directly to the test module name with
  6981. a ``.json`` extension.
  6982. The JSON file must include an object with the test name as keys of an
  6983. object or an array. This object (or array of objects) uses the following
  6984. data:
  6985. - "pkg" - A mandatory string that is the name of the package to be
  6986. installed.
  6987. - "rm" - An optional boolean, which defaults to "false", that specifies
  6988. to remove the package after the test.
  6989. - "extract" - An optional boolean, which defaults to "false", that
  6990. specifies if the package must be extracted from the package format.
  6991. When set to "true", the package is not automatically installed into
  6992. the DUT.
  6993. Following is an example JSON file that handles test "foo" installing
  6994. package "bar" and test "foobar" installing packages "foo" and "bar".
  6995. Once the test is complete, the packages are removed from the DUT.
  6996. ::
  6997. {
  6998. "foo": {
  6999. "pkg": "bar"
  7000. },
  7001. "foobar": [
  7002. {
  7003. "pkg": "foo",
  7004. "rm": true
  7005. },
  7006. {
  7007. "pkg": "bar",
  7008. "rm": true
  7009. }
  7010. ]
  7011. }
  7012. Debugging Tools and Techniques
  7013. ==============================
  7014. The exact method for debugging build failures depends on the nature of
  7015. the problem and on the system's area from which the bug originates.
  7016. Standard debugging practices such as comparison against the last known
  7017. working version with examination of the changes and the re-application
  7018. of steps to identify the one causing the problem are valid for the Yocto
  7019. Project just as they are for any other system. Even though it is
  7020. impossible to detail every possible potential failure, this section
  7021. provides some general tips to aid in debugging given a variety of
  7022. situations.
  7023. .. note::
  7024. A useful feature for debugging is the error reporting tool.
  7025. Configuring the Yocto Project to use this tool causes the
  7026. OpenEmbedded build system to produce error reporting commands as part
  7027. of the console output. You can enter the commands after the build
  7028. completes to log error information into a common database, that can
  7029. help you figure out what might be going wrong. For information on how
  7030. to enable and use this feature, see the
  7031. ":ref:`dev-manual/common-tasks:using the error reporting tool`"
  7032. section.
  7033. The following list shows the debugging topics in the remainder of this
  7034. section:
  7035. - "`Viewing Logs from Failed
  7036. Tasks <#dev-debugging-viewing-logs-from-failed-tasks>`__" describes
  7037. how to find and view logs from tasks that failed during the build
  7038. process.
  7039. - "`Viewing Variable
  7040. Values <#dev-debugging-viewing-variable-values>`__" describes how to
  7041. use the BitBake ``-e`` option to examine variable values after a
  7042. recipe has been parsed.
  7043. - ":ref:`dev-manual/common-tasks:viewing package information with \`\`oe-pkgdata-util\`\``"
  7044. describes how to use the ``oe-pkgdata-util`` utility to query
  7045. :term:`PKGDATA_DIR` and
  7046. display package-related information for built packages.
  7047. - "`Viewing Dependencies Between Recipes and
  7048. Tasks <#dev-viewing-dependencies-between-recipes-and-tasks>`__"
  7049. describes how to use the BitBake ``-g`` option to display recipe
  7050. dependency information used during the build.
  7051. - "`Viewing Task Variable
  7052. Dependencies <#dev-viewing-task-variable-dependencies>`__" describes
  7053. how to use the ``bitbake-dumpsig`` command in conjunction with key
  7054. subdirectories in the
  7055. :term:`Build Directory` to determine
  7056. variable dependencies.
  7057. - "`Running Specific Tasks <#dev-debugging-taskrunning>`__" describes
  7058. how to use several BitBake options (e.g. ``-c``, ``-C``, and ``-f``)
  7059. to run specific tasks in the build chain. It can be useful to run
  7060. tasks "out-of-order" when trying isolate build issues.
  7061. - "`General BitBake Problems <#dev-debugging-bitbake>`__" describes how
  7062. to use BitBake's ``-D`` debug output option to reveal more about what
  7063. BitBake is doing during the build.
  7064. - "`Building with No Dependencies <#dev-debugging-buildfile>`__"
  7065. describes how to use the BitBake ``-b`` option to build a recipe
  7066. while ignoring dependencies.
  7067. - "`Recipe Logging Mechanisms <#recipe-logging-mechanisms>`__"
  7068. describes how to use the many recipe logging functions to produce
  7069. debugging output and report errors and warnings.
  7070. - "`Debugging Parallel Make Races <#debugging-parallel-make-races>`__"
  7071. describes how to debug situations where the build consists of several
  7072. parts that are run simultaneously and when the output or result of
  7073. one part is not ready for use with a different part of the build that
  7074. depends on that output.
  7075. - "`Debugging With the GNU Project Debugger (GDB)
  7076. Remotely <#platdev-gdb-remotedebug>`__" describes how to use GDB to
  7077. allow you to examine running programs, which can help you fix
  7078. problems.
  7079. - "`Debugging with the GNU Project Debugger (GDB) on the
  7080. Target <#debugging-with-the-gnu-project-debugger-gdb-on-the-target>`__"
  7081. describes how to use GDB directly on target hardware for debugging.
  7082. - "`Other Debugging Tips <#dev-other-debugging-others>`__" describes
  7083. miscellaneous debugging tips that can be useful.
  7084. Viewing Logs from Failed Tasks
  7085. ------------------------------
  7086. You can find the log for a task in the file
  7087. ``${``\ :term:`WORKDIR`\ ``}/temp/log.do_``\ `taskname`.
  7088. For example, the log for the
  7089. :ref:`ref-tasks-compile` task of the
  7090. QEMU minimal image for the x86 machine (``qemux86``) might be in
  7091. ``tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile``.
  7092. To see the commands :term:`BitBake` ran
  7093. to generate a log, look at the corresponding ``run.do_``\ `taskname` file
  7094. in the same directory.
  7095. ``log.do_``\ `taskname` and ``run.do_``\ `taskname` are actually symbolic
  7096. links to ``log.do_``\ `taskname`\ ``.``\ `pid` and
  7097. ``log.run_``\ `taskname`\ ``.``\ `pid`, where `pid` is the PID the task had
  7098. when it ran. The symlinks always point to the files corresponding to the
  7099. most recent run.
  7100. Viewing Variable Values
  7101. -----------------------
  7102. Sometimes you need to know the value of a variable as a result of
  7103. BitBake's parsing step. This could be because some unexpected behavior
  7104. occurred in your project. Perhaps an attempt to :ref:`modify a variable
  7105. <bitbake:bitbake-user-manual/bitbake-user-manual-metadata:modifying existing
  7106. variables>` did not work out as expected.
  7107. BitBake's ``-e`` option is used to display variable values after
  7108. parsing. The following command displays the variable values after the
  7109. configuration files (i.e. ``local.conf``, ``bblayers.conf``,
  7110. ``bitbake.conf`` and so forth) have been parsed:
  7111. ::
  7112. $ bitbake -e
  7113. The following command displays variable values after a specific recipe has
  7114. been parsed. The variables include those from the configuration as well:
  7115. ::
  7116. $ bitbake -e recipename
  7117. .. note::
  7118. Each recipe has its own private set of variables (datastore).
  7119. Internally, after parsing the configuration, a copy of the resulting
  7120. datastore is made prior to parsing each recipe. This copying implies
  7121. that variables set in one recipe will not be visible to other
  7122. recipes.
  7123. Likewise, each task within a recipe gets a private datastore based on
  7124. the recipe datastore, which means that variables set within one task
  7125. will not be visible to other tasks.
  7126. In the output of ``bitbake -e``, each variable is preceded by a
  7127. description of how the variable got its value, including temporary
  7128. values that were later overridden. This description also includes
  7129. variable flags (varflags) set on the variable. The output can be very
  7130. helpful during debugging.
  7131. Variables that are exported to the environment are preceded by
  7132. ``export`` in the output of ``bitbake -e``. See the following example:
  7133. ::
  7134. export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
  7135. In addition to variable values, the output of the ``bitbake -e`` and
  7136. ``bitbake -e`` recipe commands includes the following information:
  7137. - The output starts with a tree listing all configuration files and
  7138. classes included globally, recursively listing the files they include
  7139. or inherit in turn. Much of the behavior of the OpenEmbedded build
  7140. system (including the behavior of the :ref:`ref-manual/ref-tasks:normal recipe build tasks`) is
  7141. implemented in the
  7142. :ref:`base <ref-classes-base>` class and the
  7143. classes it inherits, rather than being built into BitBake itself.
  7144. - After the variable values, all functions appear in the output. For
  7145. shell functions, variables referenced within the function body are
  7146. expanded. If a function has been modified using overrides or using
  7147. override-style operators like ``_append`` and ``_prepend``, then the
  7148. final assembled function body appears in the output.
  7149. Viewing Package Information with ``oe-pkgdata-util``
  7150. ----------------------------------------------------
  7151. You can use the ``oe-pkgdata-util`` command-line utility to query
  7152. :term:`PKGDATA_DIR` and display
  7153. various package-related information. When you use the utility, you must
  7154. use it to view information on packages that have already been built.
  7155. Following are a few of the available ``oe-pkgdata-util`` subcommands.
  7156. .. note::
  7157. You can use the standard \* and ? globbing wildcards as part of
  7158. package names and paths.
  7159. - ``oe-pkgdata-util list-pkgs [pattern]``: Lists all packages
  7160. that have been built, optionally limiting the match to packages that
  7161. match pattern.
  7162. - ``oe-pkgdata-util list-pkg-files package ...``: Lists the
  7163. files and directories contained in the given packages.
  7164. .. note::
  7165. A different way to view the contents of a package is to look at
  7166. the
  7167. ``${``\ :term:`WORKDIR`\ ``}/packages-split``
  7168. directory of the recipe that generates the package. This directory
  7169. is created by the
  7170. :ref:`ref-tasks-package` task
  7171. and has one subdirectory for each package the recipe generates,
  7172. which contains the files stored in that package.
  7173. If you want to inspect the ``${WORKDIR}/packages-split``
  7174. directory, make sure that
  7175. :ref:`rm_work <ref-classes-rm-work>` is not
  7176. enabled when you build the recipe.
  7177. - ``oe-pkgdata-util find-path path ...``: Lists the names of
  7178. the packages that contain the given paths. For example, the following
  7179. tells us that ``/usr/share/man/man1/make.1`` is contained in the
  7180. ``make-doc`` package:
  7181. ::
  7182. $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
  7183. make-doc: /usr/share/man/man1/make.1
  7184. - ``oe-pkgdata-util lookup-recipe package ...``: Lists the name
  7185. of the recipes that produce the given packages.
  7186. For more information on the ``oe-pkgdata-util`` command, use the help
  7187. facility:
  7188. ::
  7189. $ oe-pkgdata-util --help
  7190. $ oe-pkgdata-util subcommand --help
  7191. Viewing Dependencies Between Recipes and Tasks
  7192. ----------------------------------------------
  7193. Sometimes it can be hard to see why BitBake wants to build other recipes
  7194. before the one you have specified. Dependency information can help you
  7195. understand why a recipe is built.
  7196. To generate dependency information for a recipe, run the following
  7197. command:
  7198. ::
  7199. $ bitbake -g recipename
  7200. This command writes the following files in the current directory:
  7201. - ``pn-buildlist``: A list of recipes/targets involved in building
  7202. `recipename`. "Involved" here means that at least one task from the
  7203. recipe needs to run when building `recipename` from scratch. Targets
  7204. that are in
  7205. :term:`ASSUME_PROVIDED`
  7206. are not listed.
  7207. - ``task-depends.dot``: A graph showing dependencies between tasks.
  7208. The graphs are in
  7209. `DOT <https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29>`__
  7210. format and can be converted to images (e.g. using the ``dot`` tool from
  7211. `Graphviz <https://www.graphviz.org/>`__).
  7212. .. note::
  7213. - DOT files use a plain text format. The graphs generated using the
  7214. ``bitbake -g`` command are often so large as to be difficult to
  7215. read without special pruning (e.g. with Bitbake's ``-I`` option)
  7216. and processing. Despite the form and size of the graphs, the
  7217. corresponding ``.dot`` files can still be possible to read and
  7218. provide useful information.
  7219. As an example, the ``task-depends.dot`` file contains lines such
  7220. as the following:
  7221. ::
  7222. "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
  7223. The above example line reveals that the
  7224. :ref:`ref-tasks-configure`
  7225. task in ``libxslt`` depends on the
  7226. :ref:`ref-tasks-populate_sysroot`
  7227. task in ``libxml2``, which is a normal
  7228. :term:`DEPENDS` dependency
  7229. between the two recipes.
  7230. - For an example of how ``.dot`` files can be processed, see the
  7231. ``scripts/contrib/graph-tool`` Python script, which finds and
  7232. displays paths between graph nodes.
  7233. You can use a different method to view dependency information by using
  7234. the following command:
  7235. ::
  7236. $ bitbake -g -u taskexp recipename
  7237. This command
  7238. displays a GUI window from which you can view build-time and runtime
  7239. dependencies for the recipes involved in building recipename.
  7240. Viewing Task Variable Dependencies
  7241. ----------------------------------
  7242. As mentioned in the
  7243. ":ref:`bitbake:bitbake-user-manual/bitbake-user-manual-execution:checksums (signatures)`" section of the BitBake
  7244. User Manual, BitBake tries to automatically determine what variables a
  7245. task depends on so that it can rerun the task if any values of the
  7246. variables change. This determination is usually reliable. However, if
  7247. you do things like construct variable names at runtime, then you might
  7248. have to manually declare dependencies on those variables using
  7249. ``vardeps`` as described in the
  7250. ":ref:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata:variable flags`" section of the BitBake
  7251. User Manual.
  7252. If you are unsure whether a variable dependency is being picked up
  7253. automatically for a given task, you can list the variable dependencies
  7254. BitBake has determined by doing the following:
  7255. 1. Build the recipe containing the task:
  7256. ::
  7257. $ bitbake recipename
  7258. 2. Inside the :term:`STAMPS_DIR`
  7259. directory, find the signature data (``sigdata``) file that
  7260. corresponds to the task. The ``sigdata`` files contain a pickled
  7261. Python database of all the metadata that went into creating the input
  7262. checksum for the task. As an example, for the
  7263. :ref:`ref-tasks-fetch` task of the
  7264. ``db`` recipe, the ``sigdata`` file might be found in the following
  7265. location:
  7266. ::
  7267. ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  7268. For tasks that are accelerated through the shared state
  7269. (:ref:`sstate <overview-manual/overview-manual-concepts:shared state cache>`) cache, an
  7270. additional ``siginfo`` file is written into
  7271. :term:`SSTATE_DIR` along with
  7272. the cached task output. The ``siginfo`` files contain exactly the
  7273. same information as ``sigdata`` files.
  7274. 3. Run ``bitbake-dumpsig`` on the ``sigdata`` or ``siginfo`` file. Here
  7275. is an example:
  7276. ::
  7277. $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  7278. In the output of the above command, you will find a line like the
  7279. following, which lists all the (inferred) variable dependencies for
  7280. the task. This list also includes indirect dependencies from
  7281. variables depending on other variables, recursively.
  7282. ::
  7283. Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
  7284. .. note::
  7285. Functions (e.g. ``base_do_fetch``) also count as variable dependencies.
  7286. These functions in turn depend on the variables they reference.
  7287. The output of ``bitbake-dumpsig`` also includes the value each
  7288. variable had, a list of dependencies for each variable, and
  7289. :term:`bitbake:BB_HASHBASE_WHITELIST`
  7290. information.
  7291. There is also a ``bitbake-diffsigs`` command for comparing two
  7292. ``siginfo`` or ``sigdata`` files. This command can be helpful when
  7293. trying to figure out what changed between two versions of a task. If you
  7294. call ``bitbake-diffsigs`` with just one file, the command behaves like
  7295. ``bitbake-dumpsig``.
  7296. You can also use BitBake to dump out the signature construction
  7297. information without executing tasks by using either of the following
  7298. BitBake command-line options:
  7299. ::
  7300. ‐‐dump-signatures=SIGNATURE_HANDLER
  7301. -S SIGNATURE_HANDLER
  7302. .. note::
  7303. Two common values for `SIGNATURE_HANDLER` are "none" and "printdiff", which
  7304. dump only the signature or compare the dumped signature with the cached one,
  7305. respectively.
  7306. Using BitBake with either of these options causes BitBake to dump out
  7307. ``sigdata`` files in the ``stamps`` directory for every task it would
  7308. have executed instead of building the specified target package.
  7309. Viewing Metadata Used to Create the Input Signature of a Shared State Task
  7310. --------------------------------------------------------------------------
  7311. Seeing what metadata went into creating the input signature of a shared
  7312. state (sstate) task can be a useful debugging aid. This information is
  7313. available in signature information (``siginfo``) files in
  7314. :term:`SSTATE_DIR`. For
  7315. information on how to view and interpret information in ``siginfo``
  7316. files, see the "`Viewing Task Variable
  7317. Dependencies <#dev-viewing-task-variable-dependencies>`__" section.
  7318. For conceptual information on shared state, see the
  7319. ":ref:`overview-manual/overview-manual-concepts:shared state`"
  7320. section in the Yocto Project Overview and Concepts Manual.
  7321. Invalidating Shared State to Force a Task to Run
  7322. ------------------------------------------------
  7323. The OpenEmbedded build system uses
  7324. :ref:`checksums <overview-manual/overview-manual-concepts:checksums (signatures)>` and
  7325. :ref:`overview-manual/overview-manual-concepts:shared state` cache to avoid unnecessarily
  7326. rebuilding tasks. Collectively, this scheme is known as "shared state
  7327. code".
  7328. As with all schemes, this one has some drawbacks. It is possible that
  7329. you could make implicit changes to your code that the checksum
  7330. calculations do not take into account. These implicit changes affect a
  7331. task's output but do not trigger the shared state code into rebuilding a
  7332. recipe. Consider an example during which a tool changes its output.
  7333. Assume that the output of ``rpmdeps`` changes. The result of the change
  7334. should be that all the ``package`` and ``package_write_rpm`` shared
  7335. state cache items become invalid. However, because the change to the
  7336. output is external to the code and therefore implicit, the associated
  7337. shared state cache items do not become invalidated. In this case, the
  7338. build process uses the cached items rather than running the task again.
  7339. Obviously, these types of implicit changes can cause problems.
  7340. To avoid these problems during the build, you need to understand the
  7341. effects of any changes you make. Realize that changes you make directly
  7342. to a function are automatically factored into the checksum calculation.
  7343. Thus, these explicit changes invalidate the associated area of shared
  7344. state cache. However, you need to be aware of any implicit changes that
  7345. are not obvious changes to the code and could affect the output of a
  7346. given task.
  7347. When you identify an implicit change, you can easily take steps to
  7348. invalidate the cache and force the tasks to run. The steps you can take
  7349. are as simple as changing a function's comments in the source code. For
  7350. example, to invalidate package shared state files, change the comment
  7351. statements of
  7352. :ref:`ref-tasks-package` or the
  7353. comments of one of the functions it calls. Even though the change is
  7354. purely cosmetic, it causes the checksum to be recalculated and forces
  7355. the build system to run the task again.
  7356. .. note::
  7357. For an example of a commit that makes a cosmetic change to invalidate
  7358. shared state, see this
  7359. :yocto_git:`commit </poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54>`.
  7360. Running Specific Tasks
  7361. ----------------------
  7362. Any given recipe consists of a set of tasks. The standard BitBake
  7363. behavior in most cases is: ``do_fetch``, ``do_unpack``, ``do_patch``,
  7364. ``do_configure``, ``do_compile``, ``do_install``, ``do_package``,
  7365. ``do_package_write_*``, and ``do_build``. The default task is
  7366. ``do_build`` and any tasks on which it depends build first. Some tasks,
  7367. such as ``do_devshell``, are not part of the default build chain. If you
  7368. wish to run a task that is not part of the default build chain, you can
  7369. use the ``-c`` option in BitBake. Here is an example:
  7370. ::
  7371. $ bitbake matchbox-desktop -c devshell
  7372. The ``-c`` option respects task dependencies, which means that all other
  7373. tasks (including tasks from other recipes) that the specified task
  7374. depends on will be run before the task. Even when you manually specify a
  7375. task to run with ``-c``, BitBake will only run the task if it considers
  7376. it "out of date". See the
  7377. ":ref:`overview-manual/overview-manual-concepts:stamp files and the rerunning of tasks`"
  7378. section in the Yocto Project Overview and Concepts Manual for how
  7379. BitBake determines whether a task is "out of date".
  7380. If you want to force an up-to-date task to be rerun (e.g. because you
  7381. made manual modifications to the recipe's
  7382. :term:`WORKDIR` that you want to try
  7383. out), then you can use the ``-f`` option.
  7384. .. note::
  7385. The reason ``-f`` is never required when running the
  7386. :ref:`ref-tasks-devshell` task is because the
  7387. [\ :ref:`nostamp <bitbake:bitbake-user-manual/bitbake-user-manual-metadata:variable flags>`\ ]
  7388. variable flag is already set for the task.
  7389. The following example shows one way you can use the ``-f`` option:
  7390. ::
  7391. $ bitbake matchbox-desktop
  7392. .
  7393. .
  7394. make some changes to the source code in the work directory
  7395. .
  7396. .
  7397. $ bitbake matchbox-desktop -c compile -f
  7398. $ bitbake matchbox-desktop
  7399. This sequence first builds and then recompiles ``matchbox-desktop``. The
  7400. last command reruns all tasks (basically the packaging tasks) after the
  7401. compile. BitBake recognizes that the ``do_compile`` task was rerun and
  7402. therefore understands that the other tasks also need to be run again.
  7403. Another, shorter way to rerun a task and all
  7404. :ref:`ref-manual/ref-tasks:normal recipe build tasks`
  7405. that depend on it is to use the ``-C`` option.
  7406. .. note::
  7407. This option is upper-cased and is separate from the ``-c``
  7408. option, which is lower-cased.
  7409. Using this option invalidates the given task and then runs the
  7410. :ref:`ref-tasks-build` task, which is
  7411. the default task if no task is given, and the tasks on which it depends.
  7412. You could replace the final two commands in the previous example with
  7413. the following single command:
  7414. ::
  7415. $ bitbake matchbox-desktop -C compile
  7416. Internally, the ``-f`` and ``-C`` options work by tainting (modifying)
  7417. the input checksum of the specified task. This tainting indirectly
  7418. causes the task and its dependent tasks to be rerun through the normal
  7419. task dependency mechanisms.
  7420. .. note::
  7421. BitBake explicitly keeps track of which tasks have been tainted in
  7422. this fashion, and will print warnings such as the following for
  7423. builds involving such tasks:
  7424. .. code-block:: none
  7425. WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
  7426. The purpose of the warning is to let you know that the work directory
  7427. and build output might not be in the clean state they would be in for
  7428. a "normal" build, depending on what actions you took. To get rid of
  7429. such warnings, you can remove the work directory and rebuild the
  7430. recipe, as follows:
  7431. ::
  7432. $ bitbake matchbox-desktop -c clean
  7433. $ bitbake matchbox-desktop
  7434. You can view a list of tasks in a given package by running the
  7435. ``do_listtasks`` task as follows:
  7436. ::
  7437. $ bitbake matchbox-desktop -c listtasks
  7438. The results appear as output to the console and are also in
  7439. the file ``${WORKDIR}/temp/log.do_listtasks``.
  7440. General BitBake Problems
  7441. ------------------------
  7442. You can see debug output from BitBake by using the ``-D`` option. The
  7443. debug output gives more information about what BitBake is doing and the
  7444. reason behind it. Each ``-D`` option you use increases the logging
  7445. level. The most common usage is ``-DDD``.
  7446. The output from ``bitbake -DDD -v targetname`` can reveal why BitBake
  7447. chose a certain version of a package or why BitBake picked a certain
  7448. provider. This command could also help you in a situation where you
  7449. think BitBake did something unexpected.
  7450. Building with No Dependencies
  7451. -----------------------------
  7452. To build a specific recipe (``.bb`` file), you can use the following
  7453. command form:
  7454. ::
  7455. $ bitbake -b somepath/somerecipe.bb
  7456. This command form does
  7457. not check for dependencies. Consequently, you should use it only when
  7458. you know existing dependencies have been met.
  7459. .. note::
  7460. You can also specify fragments of the filename. In this case, BitBake
  7461. checks for a unique match.
  7462. Recipe Logging Mechanisms
  7463. -------------------------
  7464. The Yocto Project provides several logging functions for producing
  7465. debugging output and reporting errors and warnings. For Python
  7466. functions, the following logging functions exist. All of these functions
  7467. log to ``${T}/log.do_``\ `task`, and can also log to standard output
  7468. (stdout) with the right settings:
  7469. - ``bb.plain(msg)``: Writes msg as is to the log while also
  7470. logging to stdout.
  7471. - ``bb.note(msg)``: Writes "NOTE: msg" to the log. Also logs to
  7472. stdout if BitBake is called with "-v".
  7473. - ``bb.debug(level, msg)``: Writes "DEBUG: msg" to the
  7474. log. Also logs to stdout if the log level is greater than or equal to
  7475. level. See the ":ref:`-D <bitbake:bitbake-user-manual/bitbake-user-manual-intro:usage and syntax>`" option
  7476. in the BitBake User Manual for more information.
  7477. - ``bb.warn(msg)``: Writes "WARNING: msg" to the log while also
  7478. logging to stdout.
  7479. - ``bb.error(msg)``: Writes "ERROR: msg" to the log while also
  7480. logging to standard out (stdout).
  7481. .. note::
  7482. Calling this function does not cause the task to fail.
  7483. - ``bb.fatal(``\ msg\ ``)``: This logging function is similar to
  7484. ``bb.error(``\ msg\ ``)`` but also causes the calling task to fail.
  7485. .. note::
  7486. ``bb.fatal()`` raises an exception, which means you do not need to put a
  7487. "return" statement after the function.
  7488. The same logging functions are also available in shell functions, under
  7489. the names ``bbplain``, ``bbnote``, ``bbdebug``, ``bbwarn``, ``bberror``,
  7490. and ``bbfatal``. The
  7491. :ref:`logging <ref-classes-logging>` class
  7492. implements these functions. See that class in the ``meta/classes``
  7493. folder of the :term:`Source Directory` for information.
  7494. Logging With Python
  7495. ~~~~~~~~~~~~~~~~~~~
  7496. When creating recipes using Python and inserting code that handles build
  7497. logs, keep in mind the goal is to have informative logs while keeping
  7498. the console as "silent" as possible. Also, if you want status messages
  7499. in the log, use the "debug" loglevel.
  7500. Following is an example written in Python. The code handles logging for
  7501. a function that determines the number of tasks needed to be run. See the
  7502. ":ref:`ref-tasks-listtasks`"
  7503. section for additional information:
  7504. ::
  7505. python do_listtasks() {
  7506. bb.debug(2, "Starting to figure out the task list")
  7507. if noteworthy_condition:
  7508. bb.note("There are 47 tasks to run")
  7509. bb.debug(2, "Got to point xyz")
  7510. if warning_trigger:
  7511. bb.warn("Detected warning_trigger, this might be a problem later.")
  7512. if recoverable_error:
  7513. bb.error("Hit recoverable_error, you really need to fix this!")
  7514. if fatal_error:
  7515. bb.fatal("fatal_error detected, unable to print the task list")
  7516. bb.plain("The tasks present are abc")
  7517. bb.debug(2, "Finished figuring out the tasklist")
  7518. }
  7519. Logging With Bash
  7520. ~~~~~~~~~~~~~~~~~
  7521. When creating recipes using Bash and inserting code that handles build
  7522. logs, you have the same goals - informative with minimal console output.
  7523. The syntax you use for recipes written in Bash is similar to that of
  7524. recipes written in Python described in the previous section.
  7525. Following is an example written in Bash. The code logs the progress of
  7526. the ``do_my_function`` function.
  7527. ::
  7528. do_my_function() {
  7529. bbdebug 2 "Running do_my_function"
  7530. if [ exceptional_condition ]; then
  7531. bbnote "Hit exceptional_condition"
  7532. fi
  7533. bbdebug 2 "Got to point xyz"
  7534. if [ warning_trigger ]; then
  7535. bbwarn "Detected warning_trigger, this might cause a problem later."
  7536. fi
  7537. if [ recoverable_error ]; then
  7538. bberror "Hit recoverable_error, correcting"
  7539. fi
  7540. if [ fatal_error ]; then
  7541. bbfatal "fatal_error detected"
  7542. fi
  7543. bbdebug 2 "Completed do_my_function"
  7544. }
  7545. Debugging Parallel Make Races
  7546. -----------------------------
  7547. A parallel ``make`` race occurs when the build consists of several parts
  7548. that are run simultaneously and a situation occurs when the output or
  7549. result of one part is not ready for use with a different part of the
  7550. build that depends on that output. Parallel make races are annoying and
  7551. can sometimes be difficult to reproduce and fix. However, some simple
  7552. tips and tricks exist that can help you debug and fix them. This section
  7553. presents a real-world example of an error encountered on the Yocto
  7554. Project autobuilder and the process used to fix it.
  7555. .. note::
  7556. If you cannot properly fix a ``make`` race condition, you can work around it
  7557. by clearing either the :term:`PARALLEL_MAKE` or :term:`PARALLEL_MAKEINST`
  7558. variables.
  7559. The Failure
  7560. ~~~~~~~~~~~
  7561. For this example, assume that you are building an image that depends on
  7562. the "neard" package. And, during the build, BitBake runs into problems
  7563. and creates the following output.
  7564. .. note::
  7565. This example log file has longer lines artificially broken to make
  7566. the listing easier to read.
  7567. If you examine the output or the log file, you see the failure during
  7568. ``make``:
  7569. .. code-block:: none
  7570. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  7571. | DEBUG: Executing shell function do_compile
  7572. | NOTE: make -j 16
  7573. | make --no-print-directory all-am
  7574. | /bin/mkdir -p include/near
  7575. | /bin/mkdir -p include/near
  7576. | /bin/mkdir -p include/near
  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/types.h include/near/types.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/log.h include/near/log.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/plugin.h include/near/plugin.h
  7583. | /bin/mkdir -p include/near
  7584. | /bin/mkdir -p include/near
  7585. | /bin/mkdir -p include/near
  7586. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7587. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  7588. | /bin/mkdir -p include/near
  7589. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7590. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  7591. | /bin/mkdir -p include/near
  7592. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7593. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  7594. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7595. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  7596. | /bin/mkdir -p include/near
  7597. | /bin/mkdir -p include/near
  7598. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7599. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  7600. | /bin/mkdir -p include/near
  7601. | /bin/mkdir -p include/near
  7602. | /bin/mkdir -p include/near
  7603. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7604. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  7605. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7606. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  7607. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7608. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  7609. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7610. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  7611. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  7612. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  7613. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  7614. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  7615. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  7616. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  7617. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  7618. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  7619. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  7620. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  7621. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  7622. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  7623. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  7624. -o tools/snep-send.o tools/snep-send.c
  7625. | In file included from tools/snep-send.c:16:0:
  7626. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  7627. | #include <near/dbus.h>
  7628. | ^
  7629. | compilation terminated.
  7630. | make[1]: *** [tools/snep-send.o] Error 1
  7631. | make[1]: *** Waiting for unfinished jobs....
  7632. | make: *** [all] Error 2
  7633. | ERROR: oe_runmake failed
  7634. Reproducing the Error
  7635. ~~~~~~~~~~~~~~~~~~~~~
  7636. Because race conditions are intermittent, they do not manifest
  7637. themselves every time you do the build. In fact, most times the build
  7638. will complete without problems even though the potential race condition
  7639. exists. Thus, once the error surfaces, you need a way to reproduce it.
  7640. In this example, compiling the "neard" package is causing the problem.
  7641. So the first thing to do is build "neard" locally. Before you start the
  7642. build, set the
  7643. :term:`PARALLEL_MAKE` variable
  7644. in your ``local.conf`` file to a high number (e.g. "-j 20"). Using a
  7645. high value for ``PARALLEL_MAKE`` increases the chances of the race
  7646. condition showing up:
  7647. ::
  7648. $ bitbake neard
  7649. Once the local build for "neard" completes, start a ``devshell`` build:
  7650. ::
  7651. $ bitbake neard -c devshell
  7652. For information on how to use a
  7653. ``devshell``, see the "`Using a Development
  7654. Shell <#platdev-appdev-devshell>`__" section.
  7655. In the ``devshell``, do the following:
  7656. ::
  7657. $ make clean
  7658. $ make tools/snep-send.o
  7659. The ``devshell`` commands cause the failure to clearly
  7660. be visible. In this case, a missing dependency exists for the "neard"
  7661. Makefile target. Here is some abbreviated, sample output with the
  7662. missing dependency clearly visible at the end:
  7663. ::
  7664. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  7665. .
  7666. .
  7667. .
  7668. tools/snep-send.c
  7669. In file included from tools/snep-send.c:16:0:
  7670. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  7671. #include <near/dbus.h>
  7672. ^
  7673. compilation terminated.
  7674. make: *** [tools/snep-send.o] Error 1
  7675. $
  7676. Creating a Patch for the Fix
  7677. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7678. Because there is a missing dependency for the Makefile target, you need
  7679. to patch the ``Makefile.am`` file, which is generated from
  7680. ``Makefile.in``. You can use Quilt to create the patch:
  7681. ::
  7682. $ quilt new parallelmake.patch
  7683. Patch patches/parallelmake.patch is now on top
  7684. $ quilt add Makefile.am
  7685. File Makefile.am added to patch patches/parallelmake.patch
  7686. For more information on using Quilt, see the
  7687. "`Using Quilt in Your Workflow <#using-a-quilt-workflow>`__" section.
  7688. At this point you need to make the edits to ``Makefile.am`` to add the
  7689. missing dependency. For our example, you have to add the following line
  7690. to the file:
  7691. ::
  7692. tools/snep-send.$(OBJEXT): include/near/dbus.h
  7693. Once you have edited the file, use the ``refresh`` command to create the
  7694. patch:
  7695. ::
  7696. $ quilt refresh
  7697. Refreshed patch patches/parallelmake.patch
  7698. Once
  7699. the patch file exists, you need to add it back to the originating recipe
  7700. folder. Here is an example assuming a top-level
  7701. :term:`Source Directory` named ``poky``:
  7702. ::
  7703. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  7704. The final thing you need to do to implement the fix in the build is to
  7705. update the "neard" recipe (i.e. ``neard-0.14.bb``) so that the
  7706. :term:`SRC_URI` statement includes
  7707. the patch file. The recipe file is in the folder above the patch. Here
  7708. is what the edited ``SRC_URI`` statement would look like:
  7709. ::
  7710. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  7711. file://neard.in \
  7712. file://neard.service.in \
  7713. file://parallelmake.patch \
  7714. "
  7715. With the patch complete and moved to the correct folder and the
  7716. ``SRC_URI`` statement updated, you can exit the ``devshell``:
  7717. ::
  7718. $ exit
  7719. Testing the Build
  7720. ~~~~~~~~~~~~~~~~~
  7721. With everything in place, you can get back to trying the build again
  7722. locally:
  7723. ::
  7724. $ bitbake neard
  7725. This build should succeed.
  7726. Now you can open up a ``devshell`` again and repeat the clean and make
  7727. operations as follows:
  7728. ::
  7729. $ bitbake neard -c devshell
  7730. $ make clean
  7731. $ make tools/snep-send.o
  7732. The build should work without issue.
  7733. As with all solved problems, if they originated upstream, you need to
  7734. submit the fix for the recipe in OE-Core and upstream so that the
  7735. problem is taken care of at its source. See the "`Submitting a Change to
  7736. the Yocto Project <#how-to-submit-a-change>`__" section for more
  7737. information.
  7738. Debugging With the GNU Project Debugger (GDB) Remotely
  7739. ------------------------------------------------------
  7740. GDB allows you to examine running programs, which in turn helps you to
  7741. understand and fix problems. It also allows you to perform post-mortem
  7742. style analysis of program crashes. GDB is available as a package within
  7743. the Yocto Project and is installed in SDK images by default. See the
  7744. ":ref:`ref-manual/ref-images:Images`" chapter in the Yocto
  7745. Project Reference Manual for a description of these images. You can find
  7746. information on GDB at https://sourceware.org/gdb/.
  7747. .. note::
  7748. For best results, install debug (``-dbg``) packages for the applications you
  7749. are going to debug. Doing so makes extra debug symbols available that give
  7750. you more meaningful output.
  7751. Sometimes, due to memory or disk space constraints, it is not possible
  7752. to use GDB directly on the remote target to debug applications. These
  7753. constraints arise because GDB needs to load the debugging information
  7754. and the binaries of the process being debugged. Additionally, GDB needs
  7755. to perform many computations to locate information such as function
  7756. names, variable names and values, stack traces and so forth - even
  7757. before starting the debugging process. These extra computations place
  7758. more load on the target system and can alter the characteristics of the
  7759. program being debugged.
  7760. To help get past the previously mentioned constraints, you can use
  7761. gdbserver, which runs on the remote target and does not load any
  7762. debugging information from the debugged process. Instead, a GDB instance
  7763. processes the debugging information that is run on a remote computer -
  7764. the host GDB. The host GDB then sends control commands to gdbserver to
  7765. make it stop or start the debugged program, as well as read or write
  7766. memory regions of that debugged program. All the debugging information
  7767. loaded and processed as well as all the heavy debugging is done by the
  7768. host GDB. Offloading these processes gives the gdbserver running on the
  7769. target a chance to remain small and fast.
  7770. Because the host GDB is responsible for loading the debugging
  7771. information and for doing the necessary processing to make actual
  7772. debugging happen, you have to make sure the host can access the
  7773. unstripped binaries complete with their debugging information and also
  7774. be sure the target is compiled with no optimizations. The host GDB must
  7775. also have local access to all the libraries used by the debugged
  7776. program. Because gdbserver does not need any local debugging
  7777. information, the binaries on the remote target can remain stripped.
  7778. However, the binaries must also be compiled without optimization so they
  7779. match the host's binaries.
  7780. To remain consistent with GDB documentation and terminology, the binary
  7781. being debugged on the remote target machine is referred to as the
  7782. "inferior" binary. For documentation on GDB see the `GDB
  7783. site <https://sourceware.org/gdb/documentation/>`__.
  7784. The following steps show you how to debug using the GNU project
  7785. debugger.
  7786. 1. *Configure your build system to construct the companion debug
  7787. filesystem:*
  7788. In your ``local.conf`` file, set the following:
  7789. ::
  7790. IMAGE_GEN_DEBUGFS = "1"
  7791. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  7792. These options cause the
  7793. OpenEmbedded build system to generate a special companion filesystem
  7794. fragment, which contains the matching source and debug symbols to
  7795. your deployable filesystem. The build system does this by looking at
  7796. what is in the deployed filesystem, and pulling the corresponding
  7797. ``-dbg`` packages.
  7798. The companion debug filesystem is not a complete filesystem, but only
  7799. contains the debug fragments. This filesystem must be combined with
  7800. the full filesystem for debugging. Subsequent steps in this procedure
  7801. show how to combine the partial filesystem with the full filesystem.
  7802. 2. *Configure the system to include gdbserver in the target filesystem:*
  7803. Make the following addition in either your ``local.conf`` file or in
  7804. an image recipe:
  7805. ::
  7806. IMAGE_INSTALL_append = " gdbserver"
  7807. The change makes
  7808. sure the ``gdbserver`` package is included.
  7809. 3. *Build the environment:*
  7810. Use the following command to construct the image and the companion
  7811. Debug Filesystem:
  7812. ::
  7813. $ bitbake image
  7814. Build the cross GDB component and
  7815. make it available for debugging. Build the SDK that matches the
  7816. image. Building the SDK is best for a production build that can be
  7817. used later for debugging, especially during long term maintenance:
  7818. ::
  7819. $ bitbake -c populate_sdk image
  7820. Alternatively, you can build the minimal toolchain components that
  7821. match the target. Doing so creates a smaller than typical SDK and
  7822. only contains a minimal set of components with which to build simple
  7823. test applications, as well as run the debugger:
  7824. ::
  7825. $ bitbake meta-toolchain
  7826. A final method is to build Gdb itself within the build system:
  7827. ::
  7828. $ bitbake gdb-cross-<architecture>
  7829. Doing so produces a temporary copy of
  7830. ``cross-gdb`` you can use for debugging during development. While
  7831. this is the quickest approach, the two previous methods in this step
  7832. are better when considering long-term maintenance strategies.
  7833. .. note::
  7834. If you run ``bitbake gdb-cross``, the OpenEmbedded build system suggests
  7835. the actual image (e.g. ``gdb-cross-i586``). The suggestion is usually the
  7836. actual name you want to use.
  7837. 4. *Set up the* ``debugfs``\ *:*
  7838. Run the following commands to set up the ``debugfs``:
  7839. ::
  7840. $ mkdir debugfs
  7841. $ cd debugfs
  7842. $ tar xvfj build-dir/tmp-glibc/deploy/images/machine/image.rootfs.tar.bz2
  7843. $ tar xvfj build-dir/tmp-glibc/deploy/images/machine/image-dbg.rootfs.tar.bz2
  7844. 5. *Set up GDB:*
  7845. Install the SDK (if you built one) and then source the correct
  7846. environment file. Sourcing the environment file puts the SDK in your
  7847. ``PATH`` environment variable.
  7848. If you are using the build system, Gdb is located in
  7849. `build-dir`\ ``/tmp/sysroots/``\ `host`\ ``/usr/bin/``\ `architecture`\ ``/``\ `architecture`\ ``-gdb``
  7850. 6. *Boot the target:*
  7851. For information on how to run QEMU, see the `QEMU
  7852. Documentation <https://wiki.qemu.org/Documentation/GettingStartedDevelopers>`__.
  7853. .. note::
  7854. Be sure to verify that your host can access the target via TCP.
  7855. 7. *Debug a program:*
  7856. Debugging a program involves running gdbserver on the target and then
  7857. running Gdb on the host. The example in this step debugs ``gzip``:
  7858. .. code-block:: shell
  7859. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  7860. For
  7861. additional gdbserver options, see the `GDB Server
  7862. Documentation <https://www.gnu.org/software/gdb/documentation/>`__.
  7863. After running gdbserver on the target, you need to run Gdb on the
  7864. host and configure it and connect to the target. Use these commands:
  7865. ::
  7866. $ cd directory-holding-the-debugfs-directory
  7867. $ arch-gdb
  7868. (gdb) set sysroot debugfs
  7869. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  7870. (gdb) target remote IP-of-target:1234
  7871. At this
  7872. point, everything should automatically load (i.e. matching binaries,
  7873. symbols and headers).
  7874. .. note::
  7875. The Gdb ``set`` commands in the previous example can be placed into the
  7876. users ``~/.gdbinit`` file. Upon starting, Gdb automatically runs whatever
  7877. commands are in that file.
  7878. 8. *Deploying without a full image rebuild:*
  7879. In many cases, during development you want a quick method to deploy a
  7880. new binary to the target and debug it, without waiting for a full
  7881. image build.
  7882. One approach to solving this situation is to just build the component
  7883. you want to debug. Once you have built the component, copy the
  7884. executable directly to both the target and the host ``debugfs``.
  7885. If the binary is processed through the debug splitting in
  7886. OpenEmbedded, you should also copy the debug items (i.e. ``.debug``
  7887. contents and corresponding ``/usr/src/debug`` files) from the work
  7888. directory. Here is an example:
  7889. ::
  7890. $ bitbake bash
  7891. $ bitbake -c devshell bash
  7892. $ cd ..
  7893. $ scp packages-split/bash/bin/bash target:/bin/bash
  7894. $ cp -a packages-split/bash-dbg/\* path/debugfs
  7895. Debugging with the GNU Project Debugger (GDB) on the Target
  7896. -----------------------------------------------------------
  7897. The previous section addressed using GDB remotely for debugging
  7898. purposes, which is the most usual case due to the inherent hardware
  7899. limitations on many embedded devices. However, debugging in the target
  7900. hardware itself is also possible with more powerful devices. This
  7901. section describes what you need to do in order to support using GDB to
  7902. debug on the target hardware.
  7903. To support this kind of debugging, you need do the following:
  7904. - Ensure that GDB is on the target. You can do this by adding "gdb" to
  7905. :term:`IMAGE_INSTALL`:
  7906. ::
  7907. IMAGE_INSTALL_append = " gdb"
  7908. Alternatively, you can add "tools-debug" to :term:`IMAGE_FEATURES`:
  7909. ::
  7910. IMAGE_FEATURES_append = " tools-debug"
  7911. - Ensure that debug symbols are present. You can make sure these
  7912. symbols are present by installing ``-dbg``:
  7913. ::
  7914. IMAGE_INSTALL_append = "packagename-dbg"
  7915. Alternatively, you can do the following to include
  7916. all the debug symbols:
  7917. ::
  7918. IMAGE_FEATURES_append = " dbg-pkgs"
  7919. .. note::
  7920. To improve the debug information accuracy, you can reduce the level
  7921. of optimization used by the compiler. For example, when adding the
  7922. following line to your ``local.conf`` file, you will reduce optimization
  7923. from :term:`FULL_OPTIMIZATION` of "-O2" to :term:`DEBUG_OPTIMIZATION`
  7924. of "-O -fno-omit-frame-pointer":
  7925. ::
  7926. DEBUG_BUILD = "1"
  7927. Consider that this will reduce the application's performance and is
  7928. recommended only for debugging purposes.
  7929. Other Debugging Tips
  7930. --------------------
  7931. Here are some other tips that you might find useful:
  7932. - When adding new packages, it is worth watching for undesirable items
  7933. making their way into compiler command lines. For example, you do not
  7934. want references to local system files like ``/usr/lib/`` or
  7935. ``/usr/include/``.
  7936. - If you want to remove the ``psplash`` boot splashscreen, add
  7937. ``psplash=false`` to the kernel command line. Doing so prevents
  7938. ``psplash`` from loading and thus allows you to see the console. It
  7939. is also possible to switch out of the splashscreen by switching the
  7940. virtual console (e.g. Fn+Left or Fn+Right on a Zaurus).
  7941. - Removing :term:`TMPDIR` (usually
  7942. ``tmp/``, within the
  7943. :term:`Build Directory`) can often fix
  7944. temporary build issues. Removing ``TMPDIR`` is usually a relatively
  7945. cheap operation, because task output will be cached in
  7946. :term:`SSTATE_DIR` (usually
  7947. ``sstate-cache/``, which is also in the Build Directory).
  7948. .. note::
  7949. Removing ``TMPDIR`` might be a workaround rather than a fix.
  7950. Consequently, trying to determine the underlying cause of an issue before
  7951. removing the directory is a good idea.
  7952. - Understanding how a feature is used in practice within existing
  7953. recipes can be very helpful. It is recommended that you configure
  7954. some method that allows you to quickly search through files.
  7955. Using GNU Grep, you can use the following shell function to
  7956. recursively search through common recipe-related files, skipping
  7957. binary files, ``.git`` directories, and the Build Directory (assuming
  7958. its name starts with "build"):
  7959. ::
  7960. g() {
  7961. grep -Ir \
  7962. --exclude-dir=.git \
  7963. --exclude-dir='build*' \
  7964. --include='*.bb*' \
  7965. --include='*.inc*' \
  7966. --include='*.conf*' \
  7967. --include='*.py*' \
  7968. "$@"
  7969. }
  7970. Following are some usage examples:
  7971. ::
  7972. $ g FOO # Search recursively for "FOO"
  7973. $ g -i foo # Search recursively for "foo", ignoring case
  7974. $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
  7975. If figuring
  7976. out how some feature works requires a lot of searching, it might
  7977. indicate that the documentation should be extended or improved. In
  7978. such cases, consider filing a documentation bug using the Yocto
  7979. Project implementation of
  7980. :yocto_bugs:`Bugzilla <>`. For information on
  7981. how to submit a bug against the Yocto Project, see the Yocto Project
  7982. Bugzilla :yocto_wiki:`wiki page </Bugzilla_Configuration_and_Bug_Tracking>`
  7983. and the "`Submitting a Defect Against the Yocto
  7984. Project <#submitting-a-defect-against-the-yocto-project>`__" section.
  7985. .. note::
  7986. The manuals might not be the right place to document variables
  7987. that are purely internal and have a limited scope (e.g. internal
  7988. variables used to implement a single ``.bbclass`` file).
  7989. Making Changes to the Yocto Project
  7990. ===================================
  7991. Because the Yocto Project is an open-source, community-based project,
  7992. you can effect changes to the project. This section presents procedures
  7993. that show you how to submit a defect against the project and how to
  7994. submit a change.
  7995. Submitting a Defect Against the Yocto Project
  7996. ---------------------------------------------
  7997. Use the Yocto Project implementation of
  7998. `Bugzilla <https://www.bugzilla.org/about/>`__ to submit a defect (bug)
  7999. against the Yocto Project. For additional information on this
  8000. implementation of Bugzilla see the ":ref:`Yocto Project
  8001. Bugzilla <resources-bugtracker>`" section in the
  8002. Yocto Project Reference Manual. For more detail on any of the following
  8003. steps, see the Yocto Project
  8004. :yocto_wiki:`Bugzilla wiki page </Bugzilla_Configuration_and_Bug_Tracking>`.
  8005. Use the following general steps to submit a bug:
  8006. 1. Open the Yocto Project implementation of :yocto_bugs:`Bugzilla <>`.
  8007. 2. Click "File a Bug" to enter a new bug.
  8008. 3. Choose the appropriate "Classification", "Product", and "Component"
  8009. for which the bug was found. Bugs for the Yocto Project fall into
  8010. one of several classifications, which in turn break down into
  8011. several products and components. For example, for a bug against the
  8012. ``meta-intel`` layer, you would choose "Build System, Metadata &
  8013. Runtime", "BSPs", and "bsps-meta-intel", respectively.
  8014. 4. Choose the "Version" of the Yocto Project for which you found the
  8015. bug (e.g. &DISTRO;).
  8016. 5. Determine and select the "Severity" of the bug. The severity
  8017. indicates how the bug impacted your work.
  8018. 6. Choose the "Hardware" that the bug impacts.
  8019. 7. Choose the "Architecture" that the bug impacts.
  8020. 8. Choose a "Documentation change" item for the bug. Fixing a bug might
  8021. or might not affect the Yocto Project documentation. If you are
  8022. unsure of the impact to the documentation, select "Don't Know".
  8023. 9. Provide a brief "Summary" of the bug. Try to limit your summary to
  8024. just a line or two and be sure to capture the essence of the bug.
  8025. 10. Provide a detailed "Description" of the bug. You should provide as
  8026. much detail as you can about the context, behavior, output, and so
  8027. forth that surrounds the bug. You can even attach supporting files
  8028. for output from logs by using the "Add an attachment" button.
  8029. 11. Click the "Submit Bug" button submit the bug. A new Bugzilla number
  8030. is assigned to the bug and the defect is logged in the bug tracking
  8031. system.
  8032. Once you file a bug, the bug is processed by the Yocto Project Bug
  8033. Triage Team and further details concerning the bug are assigned (e.g.
  8034. priority and owner). You are the "Submitter" of the bug and any further
  8035. categorization, progress, or comments on the bug result in Bugzilla
  8036. sending you an automated email concerning the particular change or
  8037. progress to the bug.
  8038. Submitting a Change to the Yocto Project
  8039. ----------------------------------------
  8040. Contributions to the Yocto Project and OpenEmbedded are very welcome.
  8041. Because the system is extremely configurable and flexible, we recognize
  8042. that developers will want to extend, configure or optimize it for their
  8043. specific uses.
  8044. The Yocto Project uses a mailing list and a patch-based workflow that is
  8045. similar to the Linux kernel but contains important differences. In
  8046. general, a mailing list exists through which you can submit patches. You
  8047. should send patches to the appropriate mailing list so that they can be
  8048. reviewed and merged by the appropriate maintainer. The specific mailing
  8049. list you need to use depends on the location of the code you are
  8050. changing. Each component (e.g. layer) should have a ``README`` file that
  8051. indicates where to send the changes and which process to follow.
  8052. You can send the patch to the mailing list using whichever approach you
  8053. feel comfortable with to generate the patch. Once sent, the patch is
  8054. usually reviewed by the community at large. If somebody has concerns
  8055. with the patch, they will usually voice their concern over the mailing
  8056. list. If a patch does not receive any negative reviews, the maintainer
  8057. of the affected layer typically takes the patch, tests it, and then
  8058. based on successful testing, merges the patch.
  8059. The "poky" repository, which is the Yocto Project's reference build
  8060. environment, is a hybrid repository that contains several individual
  8061. pieces (e.g. BitBake, Metadata, documentation, and so forth) built using
  8062. the combo-layer tool. The upstream location used for submitting changes
  8063. varies by component:
  8064. - *Core Metadata:* Send your patch to the
  8065. :oe_lists:`openembedded-core </g/openembedded-core>`
  8066. mailing list. For example, a change to anything under the ``meta`` or
  8067. ``scripts`` directories should be sent to this mailing list.
  8068. - *BitBake:* For changes to BitBake (i.e. anything under the
  8069. ``bitbake`` directory), send your patch to the
  8070. :oe_lists:`bitbake-devel </g/bitbake-devel>`
  8071. mailing list.
  8072. - *"meta-\*" trees:* These trees contain Metadata. Use the
  8073. :yocto_lists:`poky </g/poky>` mailing list.
  8074. - *Documentation*: For changes to the Yocto Project documentation, use the
  8075. :yocto_lists:`docs </g/docs>` mailing list.
  8076. For changes to other layers hosted in the Yocto Project source
  8077. repositories (i.e. ``yoctoproject.org``) and tools use the
  8078. :yocto_lists:`Yocto Project </g/yocto/>` general mailing list.
  8079. .. note::
  8080. Sometimes a layer's documentation specifies to use a particular
  8081. mailing list. If so, use that list.
  8082. For additional recipes that do not fit into the core Metadata, you
  8083. should determine which layer the recipe should go into and submit the
  8084. change in the manner recommended by the documentation (e.g. the
  8085. ``README`` file) supplied with the layer. If in doubt, please ask on the
  8086. Yocto general mailing list or on the openembedded-devel mailing list.
  8087. You can also push a change upstream and request a maintainer to pull the
  8088. change into the component's upstream repository. You do this by pushing
  8089. to a contribution repository that is upstream. See the
  8090. ":ref:`overview-manual/overview-manual-development-environment:git workflows and the yocto project`"
  8091. section in the Yocto Project Overview and Concepts Manual for additional
  8092. concepts on working in the Yocto Project development environment.
  8093. Maintainers commonly use ``-next`` branches to test submissions prior to
  8094. merging patches. Thus, you can get an idea of the status of a patch based on
  8095. whether the patch has been merged into one of these branches. The commonly
  8096. used testing branches for OpenEmbedded-Core are as follows:
  8097. - *openembedded-core "master-next" branch:* This branch is part of the
  8098. :oe_git:`openembedded-core </openembedded-core/>` repository and contains
  8099. proposed changes to the core metadata.
  8100. - *poky "master-next" branch:* This branch is part of the
  8101. :yocto_git:`poky </poky/>` repository and combines proposed
  8102. changes to bitbake, the core metadata and the poky distro.
  8103. Similarly, stable branches maintained by the project may have corresponding
  8104. ``-next`` branches which collect proposed changes. For example,
  8105. ``&DISTRO_NAME_NO_CAP;-next`` and ``&DISTRO_NAME_NO_CAP_MINUS_ONE;-next``
  8106. branches in both the "openembdedded-core" and "poky" repositories.
  8107. Other layers may have similar testing branches but there is no formal
  8108. requirement or standard for these so please check the documentation for the
  8109. layers you are contributing to.
  8110. The following sections provide procedures for submitting a change.
  8111. Preparing Changes for Submission
  8112. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8113. 1. *Make Your Changes Locally:* Make your changes in your local Git
  8114. repository. You should make small, controlled, isolated changes.
  8115. Keeping changes small and isolated aids review, makes
  8116. merging/rebasing easier and keeps the change history clean should
  8117. anyone need to refer to it in future.
  8118. 2. *Stage Your Changes:* Stage your changes by using the ``git add``
  8119. command on each file you changed.
  8120. 3. *Commit Your Changes:* Commit the change by using the ``git commit``
  8121. command. Make sure your commit information follows standards by
  8122. following these accepted conventions:
  8123. - Be sure to include a "Signed-off-by:" line in the same style as
  8124. required by the Linux kernel. Adding this line signifies that you,
  8125. the submitter, have agreed to the Developer's Certificate of
  8126. Origin 1.1 as follows:
  8127. .. code-block:: none
  8128. Developer's Certificate of Origin 1.1
  8129. By making a contribution to this project, I certify that:
  8130. (a) The contribution was created in whole or in part by me and I
  8131. have the right to submit it under the open source license
  8132. indicated in the file; or
  8133. (b) The contribution is based upon previous work that, to the best
  8134. of my knowledge, is covered under an appropriate open source
  8135. license and I have the right under that license to submit that
  8136. work with modifications, whether created in whole or in part
  8137. by me, under the same open source license (unless I am
  8138. permitted to submit under a different license), as indicated
  8139. in the file; or
  8140. (c) The contribution was provided directly to me by some other
  8141. person who certified (a), (b) or (c) and I have not modified
  8142. it.
  8143. (d) I understand and agree that this project and the contribution
  8144. are public and that a record of the contribution (including all
  8145. personal information I submit with it, including my sign-off) is
  8146. maintained indefinitely and may be redistributed consistent with
  8147. this project or the open source license(s) involved.
  8148. - Provide a single-line summary of the change and, if more
  8149. explanation is needed, provide more detail in the body of the
  8150. commit. This summary is typically viewable in the "shortlist" of
  8151. changes. Thus, providing something short and descriptive that
  8152. gives the reader a summary of the change is useful when viewing a
  8153. list of many commits. You should prefix this short description
  8154. with the recipe name (if changing a recipe), or else with the
  8155. short form path to the file being changed.
  8156. - For the body of the commit message, provide detailed information
  8157. that describes what you changed, why you made the change, and the
  8158. approach you used. It might also be helpful if you mention how you
  8159. tested the change. Provide as much detail as you can in the body
  8160. of the commit message.
  8161. .. note::
  8162. You do not need to provide a more detailed explanation of a
  8163. change if the change is minor to the point of the single line
  8164. summary providing all the information.
  8165. - If the change addresses a specific bug or issue that is associated
  8166. with a bug-tracking ID, include a reference to that ID in your
  8167. detailed description. For example, the Yocto Project uses a
  8168. specific convention for bug references - any commit that addresses
  8169. a specific bug should use the following form for the detailed
  8170. description. Be sure to use the actual bug-tracking ID from
  8171. Bugzilla for bug-id:
  8172. ::
  8173. Fixes [YOCTO #bug-id]
  8174. detailed description of change
  8175. Using Email to Submit a Patch
  8176. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8177. Depending on the components changed, you need to submit the email to a
  8178. specific mailing list. For some guidance on which mailing list to use,
  8179. see the `list <#figuring-out-the-mailing-list-to-use>`__ at the
  8180. 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/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/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. "`License Flag Matching <#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/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