dev-manual-common-tasks.xml 813 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
  3. [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
  4. <chapter id='extendpoky'>
  5. <title>Common Tasks</title>
  6. <para>
  7. This chapter describes fundamental procedures such as creating layers,
  8. adding new software packages, extending or customizing images,
  9. porting work to new hardware (adding a new machine), and so forth.
  10. You will find that the procedures documented here occur often in the
  11. development cycle using the Yocto Project.
  12. </para>
  13. <section id="understanding-and-creating-layers">
  14. <title>Understanding and Creating Layers</title>
  15. <para>
  16. The OpenEmbedded build system supports organizing
  17. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> into
  18. multiple layers.
  19. Layers allow you to isolate different types of customizations from
  20. each other.
  21. For introductory information on the Yocto Project Layer Model,
  22. see the
  23. "<ulink url='&YOCTO_DOCS_OM_URL;#the-yocto-project-layer-model'>The Yocto Project Layer Model</ulink>"
  24. section in the Yocto Project Overview and Concepts Manual.
  25. </para>
  26. <section id='creating-your-own-layer'>
  27. <title>Creating Your Own Layer</title>
  28. <para>
  29. It is very easy to create your own layers to use with the
  30. OpenEmbedded build system.
  31. The Yocto Project ships with tools that speed up creating
  32. layers.
  33. This section describes the steps you perform by hand to create
  34. layers so that you can better understand them.
  35. For information about the layer-creation tools, see the
  36. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'>Creating a New BSP Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  37. section in the Yocto Project Board Support Package (BSP)
  38. Developer's Guide and the
  39. "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>"
  40. section further down in this manual.
  41. </para>
  42. <para>
  43. Follow these general steps to create your layer without using
  44. tools:
  45. <orderedlist>
  46. <listitem><para>
  47. <emphasis>Check Existing Layers:</emphasis>
  48. Before creating a new layer, you should be sure someone
  49. has not already created a layer containing the Metadata
  50. you need.
  51. You can see the
  52. <ulink url='http://layers.openembedded.org/layerindex/layers/'>OpenEmbedded Metadata Index</ulink>
  53. for a list of layers from the OpenEmbedded community
  54. that can be used in the Yocto Project.
  55. You could find a layer that is identical or close to
  56. what you need.
  57. </para></listitem>
  58. <listitem><para>
  59. <emphasis>Create a Directory:</emphasis>
  60. Create the directory for your layer.
  61. When you create the layer, be sure to create the
  62. directory in an area not associated with the
  63. Yocto Project
  64. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  65. (e.g. the cloned <filename>poky</filename> repository).
  66. </para>
  67. <para>While not strictly required, prepend the name of
  68. the directory with the string "meta-".
  69. For example:
  70. <literallayout class='monospaced'>
  71. meta-mylayer
  72. meta-GUI_xyz
  73. meta-mymachine
  74. </literallayout>
  75. With rare exceptions, a layer's name follows this
  76. form:
  77. <literallayout class='monospaced'>
  78. meta-<replaceable>root_name</replaceable>
  79. </literallayout>
  80. Following this layer naming convention can
  81. save you trouble later when tools, components, or
  82. variables "assume" your layer name begins with "meta-".
  83. A notable example is in configuration files as
  84. shown in the following step where layer names without
  85. the "meta-" string are appended
  86. to several variables used in the configuration.
  87. </para></listitem>
  88. <listitem><para id='dev-layer-config-file-description'>
  89. <emphasis>Create a Layer Configuration File:</emphasis>
  90. Inside your new layer folder, you need to create a
  91. <filename>conf/layer.conf</filename> file.
  92. It is easiest to take an existing layer configuration
  93. file and copy that to your layer's
  94. <filename>conf</filename> directory and then modify the
  95. file as needed.</para>
  96. <para>The
  97. <filename>meta-yocto-bsp/conf/layer.conf</filename> file
  98. in the Yocto Project
  99. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta-yocto-bsp/conf'>Source Repositories</ulink>
  100. demonstrates the required syntax.
  101. For your layer, you need to replace "yoctobsp" with
  102. a unique identifier for your layer (e.g. "machinexyz"
  103. for a layer named "meta-machinexyz"):
  104. <literallayout class='monospaced'>
  105. # We have a conf and classes directory, add to BBPATH
  106. BBPATH .= ":${LAYERDIR}"
  107. # We have recipes-* directories, add to BBFILES
  108. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  109. ${LAYERDIR}/recipes-*/*/*.bbappend"
  110. BBFILE_COLLECTIONS += "yoctobsp"
  111. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  112. BBFILE_PRIORITY_yoctobsp = "5"
  113. LAYERVERSION_yoctobsp = "4"
  114. LAYERSERIES_COMPAT_yoctobsp = "&DISTRO_NAME_NO_CAP;"
  115. </literallayout>
  116. Following is an explanation of the layer configuration
  117. file:
  118. <itemizedlist>
  119. <listitem><para>
  120. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>:
  121. Adds the layer's root directory to BitBake's
  122. search path.
  123. Through the use of the
  124. <filename>BBPATH</filename> variable, BitBake
  125. locates class files
  126. (<filename>.bbclass</filename>),
  127. configuration files, and files that are
  128. included with <filename>include</filename> and
  129. <filename>require</filename> statements.
  130. For these cases, BitBake uses the first file
  131. that matches the name found in
  132. <filename>BBPATH</filename>.
  133. This is similar to the way the
  134. <filename>PATH</filename> variable is used for
  135. binaries.
  136. It is recommended, therefore, that you use
  137. unique class and configuration filenames in
  138. your custom layer.
  139. </para></listitem>
  140. <listitem><para>
  141. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>:
  142. Defines the location for all recipes in the
  143. layer.
  144. </para></listitem>
  145. <listitem><para>
  146. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'><filename>BBFILE_COLLECTIONS</filename></ulink>:
  147. Establishes the current layer through a
  148. unique identifier that is used throughout the
  149. OpenEmbedded build system to refer to the layer.
  150. In this example, the identifier "yoctobsp" is
  151. the representation for the container layer
  152. named "meta-yocto-bsp".
  153. </para></listitem>
  154. <listitem><para>
  155. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'><filename>BBFILE_PATTERN</filename></ulink>:
  156. Expands immediately during parsing to
  157. provide the directory of the layer.
  158. </para></listitem>
  159. <listitem><para>
  160. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>:
  161. Establishes a priority to use for
  162. recipes in the layer when the OpenEmbedded build
  163. finds recipes of the same name in different
  164. layers.
  165. </para></listitem>
  166. <listitem><para>
  167. <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'><filename>LAYERVERSION</filename></ulink>:
  168. Establishes a version number for the layer.
  169. You can use this version number to specify this
  170. exact version of the layer as a dependency when
  171. using the
  172. <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDEPENDS'><filename>LAYERDEPENDS</filename></ulink>
  173. variable.
  174. </para></listitem>
  175. <listitem><para>
  176. <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERSERIES_COMPAT'><filename>LAYERSERIES_COMPAT</filename></ulink>:
  177. Lists the
  178. <ulink url='&YOCTO_WIKI_URL;/wiki/Releases'>Yocto Project</ulink>
  179. releases for which the current version is
  180. compatible.
  181. This variable is a good way to indicate if
  182. your particular layer is current.
  183. </para></listitem>
  184. </itemizedlist>
  185. </para></listitem>
  186. <listitem><para>
  187. <emphasis>Add Content:</emphasis>
  188. Depending on the type of layer, add the content.
  189. If the layer adds support for a machine, add the machine
  190. configuration in a <filename>conf/machine/</filename>
  191. file within the layer.
  192. If the layer adds distro policy, add the distro
  193. configuration in a <filename>conf/distro/</filename>
  194. file within the layer.
  195. If the layer introduces new recipes, put the recipes
  196. you need in <filename>recipes-*</filename>
  197. subdirectories within the layer.
  198. <note>
  199. For an explanation of layer hierarchy that
  200. is compliant with the Yocto Project, see
  201. the
  202. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout'>Example Filesystem Layout</ulink>"
  203. section in the Yocto Project Board
  204. Support Package (BSP) Developer's Guide.
  205. </note>
  206. </para></listitem>
  207. <listitem><para>
  208. <emphasis>Optionally Test for Compatibility:</emphasis>
  209. If you want permission to use the Yocto Project
  210. Compatibility logo with your layer or application that
  211. uses your layer, perform the steps to apply for
  212. compatibility.
  213. See the
  214. "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>"
  215. section for more information.
  216. </para></listitem>
  217. </orderedlist>
  218. </para>
  219. </section>
  220. <section id='best-practices-to-follow-when-creating-layers'>
  221. <title>Following Best Practices When Creating Layers</title>
  222. <para>
  223. To create layers that are easier to maintain and that will
  224. not impact builds for other machines, you should consider the
  225. information in the following list:
  226. <itemizedlist>
  227. <listitem><para>
  228. <emphasis>Avoid "Overlaying" Entire Recipes from Other Layers in Your Configuration:</emphasis>
  229. In other words, do not copy an entire recipe into your
  230. layer and then modify it.
  231. Rather, use an append file
  232. (<filename>.bbappend</filename>) to override only those
  233. parts of the original recipe you need to modify.
  234. </para></listitem>
  235. <listitem><para>
  236. <emphasis>Avoid Duplicating Include Files:</emphasis>
  237. Use append files (<filename>.bbappend</filename>)
  238. for each recipe that uses an include file.
  239. Or, if you are introducing a new recipe that requires
  240. the included file, use the path relative to the
  241. original layer directory to refer to the file.
  242. For example, use
  243. <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename>
  244. instead of
  245. <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>.
  246. If you're finding you have to overlay the include file,
  247. it could indicate a deficiency in the include file in
  248. the layer to which it originally belongs.
  249. If this is the case, you should try to address that
  250. deficiency instead of overlaying the include file.
  251. For example, you could address this by getting the
  252. maintainer of the include file to add a variable or
  253. variables to make it easy to override the parts needing
  254. to be overridden.
  255. </para></listitem>
  256. <listitem><para>
  257. <emphasis>Structure Your Layers:</emphasis>
  258. Proper use of overrides within append files and
  259. placement of machine-specific files within your layer
  260. can ensure that a build is not using the wrong Metadata
  261. and negatively impacting a build for a different
  262. machine.
  263. Following are some examples:
  264. <itemizedlist>
  265. <listitem><para>
  266. <emphasis>Modify Variables to Support a
  267. Different Machine:</emphasis>
  268. Suppose you have a layer named
  269. <filename>meta-one</filename> that adds support
  270. for building machine "one".
  271. To do so, you use an append file named
  272. <filename>base-files.bbappend</filename> and
  273. create a dependency on "foo" by altering the
  274. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  275. variable:
  276. <literallayout class='monospaced'>
  277. DEPENDS = "foo"
  278. </literallayout>
  279. The dependency is created during any build that
  280. includes the layer
  281. <filename>meta-one</filename>.
  282. However, you might not want this dependency
  283. for all machines.
  284. For example, suppose you are building for
  285. machine "two" but your
  286. <filename>bblayers.conf</filename> file has the
  287. <filename>meta-one</filename> layer included.
  288. During the build, the
  289. <filename>base-files</filename> for machine
  290. "two" will also have the dependency on
  291. <filename>foo</filename>.</para>
  292. <para>To make sure your changes apply only when
  293. building machine "one", use a machine override
  294. with the <filename>DEPENDS</filename> statement:
  295. <literallayout class='monospaced'>
  296. DEPENDS_one = "foo"
  297. </literallayout>
  298. You should follow the same strategy when using
  299. <filename>_append</filename> and
  300. <filename>_prepend</filename> operations:
  301. <literallayout class='monospaced'>
  302. DEPENDS_append_one = " foo"
  303. DEPENDS_prepend_one = "foo "
  304. </literallayout>
  305. As an actual example, here's a line from the recipe
  306. for gnutls, which adds dependencies on
  307. "argp-standalone" when building with the musl C
  308. library:
  309. <literallayout class='monospaced'>
  310. DEPENDS_append_libc-musl = " argp-standalone"
  311. </literallayout>
  312. <note>
  313. Avoiding "+=" and "=+" and using
  314. machine-specific
  315. <filename>_append</filename>
  316. and <filename>_prepend</filename> operations
  317. is recommended as well.
  318. </note>
  319. </para></listitem>
  320. <listitem><para>
  321. <emphasis>Place Machine-Specific Files in
  322. Machine-Specific Locations:</emphasis>
  323. When you have a base recipe, such as
  324. <filename>base-files.bb</filename>, that
  325. contains a
  326. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  327. statement to a file, you can use an append file
  328. to cause the build to use your own version of
  329. the file.
  330. For example, an append file in your layer at
  331. <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename>
  332. could extend
  333. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  334. using
  335. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  336. as follows:
  337. <literallayout class='monospaced'>
  338. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  339. </literallayout>
  340. The build for machine "one" will pick up your
  341. machine-specific file as long as you have the
  342. file in
  343. <filename>meta-one/recipes-core/base-files/base-files/</filename>.
  344. However, if you are building for a different
  345. machine and the
  346. <filename>bblayers.conf</filename> file includes
  347. the <filename>meta-one</filename> layer and
  348. the location of your machine-specific file is
  349. the first location where that file is found
  350. according to <filename>FILESPATH</filename>,
  351. builds for all machines will also use that
  352. machine-specific file.</para>
  353. <para>You can make sure that a machine-specific
  354. file is used for a particular machine by putting
  355. the file in a subdirectory specific to the
  356. machine.
  357. For example, rather than placing the file in
  358. <filename>meta-one/recipes-core/base-files/base-files/</filename>
  359. as shown above, put it in
  360. <filename>meta-one/recipes-core/base-files/base-files/one/</filename>.
  361. Not only does this make sure the file is used
  362. only when building for machine "one", but the
  363. build process locates the file more quickly.</para>
  364. <para>In summary, you need to place all files
  365. referenced from <filename>SRC_URI</filename>
  366. in a machine-specific subdirectory within the
  367. layer in order to restrict those files to
  368. machine-specific builds.
  369. </para></listitem>
  370. </itemizedlist>
  371. </para></listitem>
  372. <listitem><para>
  373. <emphasis>Perform Steps to Apply for Yocto Project Compatibility:</emphasis>
  374. If you want permission to use the
  375. Yocto Project Compatibility logo with your layer
  376. or application that uses your layer, perform the
  377. steps to apply for compatibility.
  378. See the
  379. "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>"
  380. section for more information.
  381. </para></listitem>
  382. <listitem><para>
  383. <emphasis>Follow the Layer Naming Convention:</emphasis>
  384. Store custom layers in a Git repository that use the
  385. <filename>meta-<replaceable>layer_name</replaceable></filename>
  386. format.
  387. </para></listitem>
  388. <listitem><para>
  389. <emphasis>Group Your Layers Locally:</emphasis>
  390. Clone your repository alongside other cloned
  391. <filename>meta</filename> directories from the
  392. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  393. </para></listitem>
  394. </itemizedlist>
  395. </para>
  396. </section>
  397. <section id='making-sure-your-layer-is-compatible-with-yocto-project'>
  398. <title>Making Sure Your Layer is Compatible With Yocto Project</title>
  399. <para>
  400. When you create a layer used with the Yocto Project, it is
  401. advantageous to make sure that the layer interacts well with
  402. existing Yocto Project layers (i.e. the layer is compatible
  403. with the Yocto Project).
  404. Ensuring compatibility makes the layer easy to be consumed
  405. by others in the Yocto Project community and could allow you
  406. permission to use the Yocto Project Compatible Logo.
  407. <note>
  408. Only Yocto Project member organizations are permitted to
  409. use the Yocto Project Compatible Logo.
  410. The logo is not available for general use.
  411. For information on how to become a Yocto Project member
  412. organization, see the
  413. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>.
  414. </note>
  415. </para>
  416. <para>
  417. The Yocto Project Compatibility Program consists of a layer
  418. application process that requests permission to use the Yocto
  419. Project Compatibility Logo for your layer and application.
  420. The process consists of two parts:
  421. <orderedlist>
  422. <listitem><para>
  423. Successfully passing a script
  424. (<filename>yocto-check-layer</filename>) that
  425. when run against your layer, tests it against
  426. constraints based on experiences of how layers have
  427. worked in the real world and where pitfalls have been
  428. found.
  429. Getting a "PASS" result from the script is required for
  430. successful compatibility registration.
  431. </para></listitem>
  432. <listitem><para>
  433. Completion of an application acceptance form, which
  434. you can find at
  435. <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>.
  436. </para></listitem>
  437. </orderedlist>
  438. </para>
  439. <para>
  440. To be granted permission to use the logo, you need to satisfy
  441. the following:
  442. <itemizedlist>
  443. <listitem><para>
  444. Be able to check the box indicating that you
  445. got a "PASS" when running the script against your
  446. layer.
  447. </para></listitem>
  448. <listitem><para>
  449. Answer "Yes" to the questions on the form or have an
  450. acceptable explanation for any questions answered "No".
  451. </para></listitem>
  452. <listitem><para>
  453. Be a Yocto Project Member Organization.
  454. </para></listitem>
  455. </itemizedlist>
  456. </para>
  457. <para>
  458. The remainder of this section presents information on the
  459. registration form and on the
  460. <filename>yocto-check-layer</filename> script.
  461. </para>
  462. <section id='yocto-project-compatible-program-application'>
  463. <title>Yocto Project Compatible Program Application</title>
  464. <para>
  465. Use the form to apply for your layer's approval.
  466. Upon successful application, you can use the Yocto
  467. Project Compatibility Logo with your layer and the
  468. application that uses your layer.
  469. </para>
  470. <para>
  471. To access the form, use this link:
  472. <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>.
  473. Follow the instructions on the form to complete your
  474. application.
  475. </para>
  476. <para>
  477. The application consists of the following sections:
  478. <itemizedlist>
  479. <listitem><para>
  480. <emphasis>Contact Information:</emphasis>
  481. Provide your contact information as the fields
  482. require.
  483. Along with your information, provide the
  484. released versions of the Yocto Project for which
  485. your layer is compatible.
  486. </para></listitem>
  487. <listitem><para>
  488. <emphasis>Acceptance Criteria:</emphasis>
  489. Provide "Yes" or "No" answers for each of the
  490. items in the checklist.
  491. Space exists at the bottom of the form for any
  492. explanations for items for which you answered "No".
  493. </para></listitem>
  494. <listitem><para>
  495. <emphasis>Recommendations:</emphasis>
  496. Provide answers for the questions regarding Linux
  497. kernel use and build success.
  498. </para></listitem>
  499. </itemizedlist>
  500. </para>
  501. </section>
  502. <section id='yocto-check-layer-script'>
  503. <title><filename>yocto-check-layer</filename> Script</title>
  504. <para>
  505. The <filename>yocto-check-layer</filename> script
  506. provides you a way to assess how compatible your layer is
  507. with the Yocto Project.
  508. You should run this script prior to using the form to
  509. apply for compatibility as described in the previous
  510. section.
  511. You need to achieve a "PASS" result in order to have
  512. your application form successfully processed.
  513. </para>
  514. <para>
  515. The script divides tests into three areas: COMMON, BSP,
  516. and DISTRO.
  517. For example, given a distribution layer (DISTRO), the
  518. layer must pass both the COMMON and DISTRO related tests.
  519. Furthermore, if your layer is a BSP layer, the layer must
  520. pass the COMMON and BSP set of tests.
  521. </para>
  522. <para>
  523. To execute the script, enter the following commands from
  524. your build directory:
  525. <literallayout class='monospaced'>
  526. $ source oe-init-build-env
  527. $ yocto-check-layer <replaceable>your_layer_directory</replaceable>
  528. </literallayout>
  529. Be sure to provide the actual directory for your layer
  530. as part of the command.
  531. </para>
  532. <para>
  533. Entering the command causes the script to determine the
  534. type of layer and then to execute a set of specific
  535. tests against the layer.
  536. The following list overviews the test:
  537. <itemizedlist>
  538. <listitem><para>
  539. <filename>common.test_readme</filename>:
  540. Tests if a <filename>README</filename> file
  541. exists in the layer and the file is not empty.
  542. </para></listitem>
  543. <listitem><para>
  544. <filename>common.test_parse</filename>:
  545. Tests to make sure that BitBake can parse the
  546. files without error (i.e.
  547. <filename>bitbake -p</filename>).
  548. </para></listitem>
  549. <listitem><para>
  550. <filename>common.test_show_environment</filename>:
  551. Tests that the global or per-recipe environment
  552. is in order without errors (i.e.
  553. <filename>bitbake -e</filename>).
  554. </para></listitem>
  555. <listitem><para>
  556. <filename>common.test_signatures</filename>:
  557. Tests to be sure that BSP and DISTRO layers do not
  558. come with recipes that change signatures.
  559. </para></listitem>
  560. <listitem><para>
  561. <filename>bsp.test_bsp_defines_machines</filename>:
  562. Tests if a BSP layer has machine configurations.
  563. </para></listitem>
  564. <listitem><para>
  565. <filename>bsp.test_bsp_no_set_machine</filename>:
  566. Tests to ensure a BSP layer does not set the
  567. machine when the layer is added.
  568. </para></listitem>
  569. <listitem><para>
  570. <filename>distro.test_distro_defines_distros</filename>:
  571. Tests if a DISTRO layer has distro configurations.
  572. </para></listitem>
  573. <listitem><para>
  574. <filename>distro.test_distro_no_set_distro</filename>:
  575. Tests to ensure a DISTRO layer does not set the
  576. distribution when the layer is added.
  577. </para></listitem>
  578. </itemizedlist>
  579. </para>
  580. </section>
  581. </section>
  582. <section id='enabling-your-layer'>
  583. <title>Enabling Your Layer</title>
  584. <para>
  585. Before the OpenEmbedded build system can use your new layer,
  586. you need to enable it.
  587. To enable your layer, simply add your layer's path to the
  588. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename>
  589. variable in your <filename>conf/bblayers.conf</filename> file,
  590. which is found in the
  591. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  592. The following example shows how to enable a layer named
  593. <filename>meta-mylayer</filename>:
  594. <literallayout class='monospaced'>
  595. # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
  596. # changes incompatibly
  597. POKY_BBLAYERS_CONF_VERSION = "2"
  598. BBPATH = "${TOPDIR}"
  599. BBFILES ?= ""
  600. BBLAYERS ?= " \
  601. /home/<replaceable>user</replaceable>/poky/meta \
  602. /home/<replaceable>user</replaceable>/poky/meta-poky \
  603. /home/<replaceable>user</replaceable>/poky/meta-yocto-bsp \
  604. /home/<replaceable>user</replaceable>/poky/meta-mylayer \
  605. "
  606. </literallayout>
  607. </para>
  608. <para>
  609. BitBake parses each <filename>conf/layer.conf</filename> file
  610. from the top down as specified in the
  611. <filename>BBLAYERS</filename> variable
  612. within the <filename>conf/bblayers.conf</filename> file.
  613. During the processing of each
  614. <filename>conf/layer.conf</filename> file, BitBake adds the
  615. recipes, classes and configurations contained within the
  616. particular layer to the source directory.
  617. </para>
  618. </section>
  619. <section id='using-bbappend-files'>
  620. <title>Using .bbappend Files in Your Layer</title>
  621. <para>
  622. A recipe that appends Metadata to another recipe is called a
  623. BitBake append file.
  624. A BitBake append file uses the <filename>.bbappend</filename>
  625. file type suffix, while the corresponding recipe to which
  626. Metadata is being appended uses the <filename>.bb</filename>
  627. file type suffix.
  628. </para>
  629. <para>
  630. You can use a <filename>.bbappend</filename> file in your
  631. layer to make additions or changes to the content of another
  632. layer's recipe without having to copy the other layer's
  633. recipe into your layer.
  634. Your <filename>.bbappend</filename> file resides in your layer,
  635. while the main <filename>.bb</filename> recipe file to
  636. which you are appending Metadata resides in a different layer.
  637. </para>
  638. <para>
  639. Being able to append information to an existing recipe not only
  640. avoids duplication, but also automatically applies recipe
  641. changes from a different layer into your layer.
  642. If you were copying recipes, you would have to manually merge
  643. changes as they occur.
  644. </para>
  645. <para>
  646. When you create an append file, you must use the same root
  647. name as the corresponding recipe file.
  648. For example, the append file
  649. <filename>someapp_&DISTRO;.bbappend</filename> must apply to
  650. <filename>someapp_&DISTRO;.bb</filename>.
  651. This means the original recipe and append file names are
  652. version number-specific.
  653. If the corresponding recipe is renamed to update to a newer
  654. version, you must also rename and possibly update
  655. the corresponding <filename>.bbappend</filename> as well.
  656. During the build process, BitBake displays an error on starting
  657. if it detects a <filename>.bbappend</filename> file that does
  658. not have a corresponding recipe with a matching name.
  659. See the
  660. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink>
  661. variable for information on how to handle this error.
  662. </para>
  663. <para>
  664. As an example, consider the main formfactor recipe and a
  665. corresponding formfactor append file both from the
  666. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  667. Here is the main formfactor recipe, which is named
  668. <filename>formfactor_0.0.bb</filename> and located in the
  669. "meta" layer at
  670. <filename>meta/recipes-bsp/formfactor</filename>:
  671. <literallayout class='monospaced'>
  672. SUMMARY = "Device formfactor information"
  673. SECTION = "base"
  674. LICENSE = "MIT"
  675. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  676. PR = "r45"
  677. SRC_URI = "file://config file://machconfig"
  678. S = "${WORKDIR}"
  679. PACKAGE_ARCH = "${MACHINE_ARCH}"
  680. INHIBIT_DEFAULT_DEPS = "1"
  681. do_install() {
  682. # Install file only if it has contents
  683. install -d ${D}${sysconfdir}/formfactor/
  684. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  685. if [ -s "${S}/machconfig" ]; then
  686. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  687. fi
  688. } </literallayout>
  689. In the main recipe, note the
  690. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  691. variable, which tells the OpenEmbedded build system where to
  692. find files during the build.
  693. </para>
  694. <para>
  695. Following is the append file, which is named
  696. <filename>formfactor_0.0.bbappend</filename> and is from the
  697. Raspberry Pi BSP Layer named
  698. <filename>meta-raspberrypi</filename>.
  699. The file is in the layer at
  700. <filename>recipes-bsp/formfactor</filename>:
  701. <literallayout class='monospaced'>
  702. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  703. </literallayout>
  704. </para>
  705. <para>
  706. By default, the build system uses the
  707. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  708. variable to locate files.
  709. This append file extends the locations by setting the
  710. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  711. variable.
  712. Setting this variable in the <filename>.bbappend</filename>
  713. file is the most reliable and recommended method for adding
  714. directories to the search path used by the build system
  715. to find files.
  716. </para>
  717. <para>
  718. The statement in this example extends the directories to
  719. include
  720. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-THISDIR'><filename>THISDIR</filename></ulink><filename>}/${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>,
  721. which resolves to a directory named
  722. <filename>formfactor</filename> in the same directory
  723. in which the append file resides (i.e.
  724. <filename>meta-raspberrypi/recipes-bsp/formfactor</filename>.
  725. This implies that you must have the supporting directory
  726. structure set up that will contain any files or patches you
  727. will be including from the layer.
  728. </para>
  729. <para>
  730. Using the immediate expansion assignment operator
  731. <filename>:=</filename> is important because of the reference
  732. to <filename>THISDIR</filename>.
  733. The trailing colon character is important as it ensures that
  734. items in the list remain colon-separated.
  735. <note>
  736. <para>
  737. BitBake automatically defines the
  738. <filename>THISDIR</filename> variable.
  739. You should never set this variable yourself.
  740. Using "_prepend" as part of the
  741. <filename>FILESEXTRAPATHS</filename> ensures your path
  742. will be searched prior to other paths in the final
  743. list.
  744. </para>
  745. <para>
  746. Also, not all append files add extra files.
  747. Many append files simply exist to add build options
  748. (e.g. <filename>systemd</filename>).
  749. For these cases, your append file would not even
  750. use the <filename>FILESEXTRAPATHS</filename> statement.
  751. </para>
  752. </note>
  753. </para>
  754. </section>
  755. <section id='prioritizing-your-layer'>
  756. <title>Prioritizing Your Layer</title>
  757. <para>
  758. Each layer is assigned a priority value.
  759. Priority values control which layer takes precedence if there
  760. are recipe files with the same name in multiple layers.
  761. For these cases, the recipe file from the layer with a higher
  762. priority number takes precedence.
  763. Priority values also affect the order in which multiple
  764. <filename>.bbappend</filename> files for the same recipe are
  765. applied.
  766. You can either specify the priority manually, or allow the
  767. build system to calculate it based on the layer's dependencies.
  768. </para>
  769. <para>
  770. To specify the layer's priority manually, use the
  771. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  772. variable and append the layer's root name:
  773. <literallayout class='monospaced'>
  774. BBFILE_PRIORITY_mylayer = "1"
  775. </literallayout>
  776. </para>
  777. <note>
  778. <para>It is possible for a recipe with a lower version number
  779. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  780. in a layer that has a higher priority to take precedence.</para>
  781. <para>Also, the layer priority does not currently affect the
  782. precedence order of <filename>.conf</filename>
  783. or <filename>.bbclass</filename> files.
  784. Future versions of BitBake might address this.</para>
  785. </note>
  786. </section>
  787. <section id='managing-layers'>
  788. <title>Managing Layers</title>
  789. <para>
  790. You can use the BitBake layer management tool
  791. <filename>bitbake-layers</filename> to provide a view
  792. into the structure of recipes across a multi-layer project.
  793. Being able to generate output that reports on configured layers
  794. with their paths and priorities and on
  795. <filename>.bbappend</filename> files and their applicable
  796. recipes can help to reveal potential problems.
  797. </para>
  798. <para>
  799. For help on the BitBake layer management tool, use the
  800. following command:
  801. <literallayout class='monospaced'>
  802. $ bitbake-layers --help
  803. NOTE: Starting bitbake server...
  804. usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] &lt;subcommand&gt; ...
  805. BitBake layers utility
  806. optional arguments:
  807. -d, --debug Enable debug output
  808. -q, --quiet Print only errors
  809. -F, --force Force add without recipe parse verification
  810. --color COLOR Colorize output (where COLOR is auto, always, never)
  811. -h, --help show this help message and exit
  812. subcommands:
  813. &lt;subcommand&gt;
  814. show-layers show current configured layers.
  815. show-overlayed list overlayed recipes (where the same recipe exists
  816. in another layer)
  817. show-recipes list available recipes, showing the layer they are
  818. provided by
  819. show-appends list bbappend files and recipe files they apply to
  820. show-cross-depends Show dependencies between recipes that cross layer
  821. boundaries.
  822. add-layer Add one or more layers to bblayers.conf.
  823. remove-layer Remove one or more layers from bblayers.conf.
  824. flatten flatten layer configuration into a separate output
  825. directory.
  826. layerindex-fetch Fetches a layer from a layer index along with its
  827. dependent layers, and adds them to conf/bblayers.conf.
  828. layerindex-show-depends
  829. Find layer dependencies from layer index.
  830. create-layer Create a basic layer
  831. Use bitbake-layers &lt;subcommand&gt; --help to get help on a specific command
  832. </literallayout>
  833. </para>
  834. <para>
  835. The following list describes the available commands:
  836. <itemizedlist>
  837. <listitem><para>
  838. <emphasis><filename>help:</filename></emphasis>
  839. Displays general help or help on a specified command.
  840. </para></listitem>
  841. <listitem><para>
  842. <emphasis><filename>show-layers:</filename></emphasis>
  843. Shows the current configured layers.
  844. </para></listitem>
  845. <listitem><para>
  846. <emphasis><filename>show-overlayed:</filename></emphasis>
  847. Lists overlayed recipes.
  848. A recipe is overlayed when a recipe with the same name
  849. exists in another layer that has a higher layer
  850. priority.
  851. </para></listitem>
  852. <listitem><para>
  853. <emphasis><filename>show-recipes:</filename></emphasis>
  854. Lists available recipes and the layers that provide them.
  855. </para></listitem>
  856. <listitem><para>
  857. <emphasis><filename>show-appends:</filename></emphasis>
  858. Lists <filename>.bbappend</filename> files and the
  859. recipe files to which they apply.
  860. </para></listitem>
  861. <listitem><para>
  862. <emphasis><filename>show-cross-depends:</filename></emphasis>
  863. Lists dependency relationships between recipes that
  864. cross layer boundaries.
  865. </para></listitem>
  866. <listitem><para>
  867. <emphasis><filename>add-layer:</filename></emphasis>
  868. Adds a layer to <filename>bblayers.conf</filename>.
  869. </para></listitem>
  870. <listitem><para>
  871. <emphasis><filename>remove-layer:</filename></emphasis>
  872. Removes a layer from <filename>bblayers.conf</filename>
  873. </para></listitem>
  874. <listitem><para>
  875. <emphasis><filename>flatten:</filename></emphasis>
  876. Flattens the layer configuration into a separate output
  877. directory.
  878. Flattening your layer configuration builds a "flattened"
  879. directory that contains the contents of all layers,
  880. with any overlayed recipes removed and any
  881. <filename>.bbappend</filename> files appended to the
  882. corresponding recipes.
  883. You might have to perform some manual cleanup of the
  884. flattened layer as follows:
  885. <itemizedlist>
  886. <listitem><para>
  887. Non-recipe files (such as patches)
  888. are overwritten.
  889. The flatten command shows a warning for these
  890. files.
  891. </para></listitem>
  892. <listitem><para>
  893. Anything beyond the normal layer
  894. setup has been added to the
  895. <filename>layer.conf</filename> file.
  896. Only the lowest priority layer's
  897. <filename>layer.conf</filename> is used.
  898. </para></listitem>
  899. <listitem><para>
  900. Overridden and appended items from
  901. <filename>.bbappend</filename> files need to be
  902. cleaned up.
  903. The contents of each
  904. <filename>.bbappend</filename> end up in the
  905. flattened recipe.
  906. However, if there are appended or changed
  907. variable values, you need to tidy these up
  908. yourself.
  909. Consider the following example.
  910. Here, the <filename>bitbake-layers</filename>
  911. command adds the line
  912. <filename>#### bbappended ...</filename> so that
  913. you know where the following lines originate:
  914. <literallayout class='monospaced'>
  915. ...
  916. DESCRIPTION = "A useful utility"
  917. ...
  918. EXTRA_OECONF = "--enable-something"
  919. ...
  920. #### bbappended from meta-anotherlayer ####
  921. DESCRIPTION = "Customized utility"
  922. EXTRA_OECONF += "--enable-somethingelse"
  923. </literallayout>
  924. Ideally, you would tidy up these utilities as
  925. follows:
  926. <literallayout class='monospaced'>
  927. ...
  928. DESCRIPTION = "Customized utility"
  929. ...
  930. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  931. ...
  932. </literallayout>
  933. </para></listitem>
  934. </itemizedlist>
  935. </para></listitem>
  936. <listitem><para>
  937. <emphasis><filename>layerindex-fetch</filename>:</emphasis>
  938. Fetches a layer from a layer index, along with its
  939. dependent layers, and adds the layers to the
  940. <filename>conf/bblayers.conf</filename> file.
  941. </para></listitem>
  942. <listitem><para>
  943. <emphasis><filename>layerindex-show-depends</filename>:</emphasis>
  944. Finds layer dependencies from the layer index.
  945. </para></listitem>
  946. <listitem><para>
  947. <emphasis><filename>create-layer</filename>:</emphasis>
  948. Creates a basic layer.
  949. </para></listitem>
  950. </itemizedlist>
  951. </para>
  952. </section>
  953. <section id='creating-a-general-layer-using-the-bitbake-layers-script'>
  954. <title>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</title>
  955. <para>
  956. The <filename>bitbake-layers</filename> script with the
  957. <filename>create-layer</filename> subcommand simplifies
  958. creating a new general layer.
  959. <note><title>Notes</title>
  960. <itemizedlist>
  961. <listitem><para>
  962. For information on BSP layers, see the
  963. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  964. section in the Yocto Project Board Specific (BSP)
  965. Developer's Guide.
  966. </para></listitem>
  967. <listitem><para>
  968. In order to use a layer with the OpenEmbedded
  969. build system, you need to add the layer to your
  970. <filename>bblayers.conf</filename> configuration
  971. file.
  972. See the
  973. "<link linkend='adding-a-layer-using-the-bitbake-layers-script'>Adding a Layer Using the <filename>bitbake-layers</filename> Script</link>"
  974. section for more information.
  975. </para></listitem>
  976. </itemizedlist>
  977. </note>
  978. The default mode of the script's operation with this
  979. subcommand is to create a layer with the following:
  980. <itemizedlist>
  981. <listitem><para>A layer priority of 6.
  982. </para></listitem>
  983. <listitem><para>A <filename>conf</filename>
  984. subdirectory that contains a
  985. <filename>layer.conf</filename> file.
  986. </para></listitem>
  987. <listitem><para>
  988. A <filename>recipes-example</filename> subdirectory
  989. that contains a further subdirectory named
  990. <filename>example</filename>, which contains
  991. an <filename>example.bb</filename> recipe file.
  992. </para></listitem>
  993. <listitem><para>A <filename >COPYING.MIT</filename>,
  994. which is the license statement for the layer.
  995. The script assumes you want to use the MIT license,
  996. which is typical for most layers, for the contents of
  997. the layer itself.
  998. </para></listitem>
  999. <listitem><para>
  1000. A <filename>README</filename> file, which is a file
  1001. describing the contents of your new layer.
  1002. </para></listitem>
  1003. </itemizedlist>
  1004. </para>
  1005. <para>
  1006. In its simplest form, you can use the following command form
  1007. to create a layer.
  1008. The command creates a layer whose name corresponds to
  1009. <replaceable>your_layer_name</replaceable> in the current
  1010. directory:
  1011. <literallayout class='monospaced'>
  1012. $ bitbake-layers create-layer <replaceable>your_layer_name</replaceable>
  1013. </literallayout>
  1014. As an example, the following command creates a layer named
  1015. <filename>meta-scottrif</filename> in your home directory:
  1016. <literallayout class='monospaced'>
  1017. $ cd /usr/home
  1018. $ bitbake-layers create-layer meta-scottrif
  1019. NOTE: Starting bitbake server...
  1020. Add your new layer with 'bitbake-layers add-layer meta-scottrif'
  1021. </literallayout>
  1022. </para>
  1023. <para>
  1024. If you want to set the priority of the layer to other than the
  1025. default value of "6", you can either use the
  1026. <filename>&dash;&dash;priority</filename> option or you can
  1027. edit the
  1028. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  1029. value in the <filename>conf/layer.conf</filename> after the
  1030. script creates it.
  1031. Furthermore, if you want to give the example recipe file
  1032. some name other than the default, you can
  1033. use the
  1034. <filename>&dash;&dash;example-recipe-name</filename> option.
  1035. </para>
  1036. <para>
  1037. The easiest way to see how the
  1038. <filename>bitbake-layers create-layer</filename> command
  1039. works is to experiment with the script.
  1040. You can also read the usage information by entering the
  1041. following:
  1042. <literallayout class='monospaced'>
  1043. $ bitbake-layers create-layer --help
  1044. NOTE: Starting bitbake server...
  1045. usage: bitbake-layers create-layer [-h] [--priority PRIORITY]
  1046. [--example-recipe-name EXAMPLERECIPE]
  1047. layerdir
  1048. Create a basic layer
  1049. positional arguments:
  1050. layerdir Layer directory to create
  1051. optional arguments:
  1052. -h, --help show this help message and exit
  1053. --priority PRIORITY, -p PRIORITY
  1054. Layer directory to create
  1055. --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE
  1056. Filename of the example recipe
  1057. </literallayout>
  1058. </para>
  1059. </section>
  1060. <section id='adding-a-layer-using-the-bitbake-layers-script'>
  1061. <title>Adding a Layer Using the <filename>bitbake-layers</filename> Script</title>
  1062. <para>
  1063. Once you create your general layer, you must add it to your
  1064. <filename>bblayers.conf</filename> file.
  1065. Adding the layer to this configuration file makes the
  1066. OpenEmbedded build system aware of your layer so that it can
  1067. search it for metadata.
  1068. </para>
  1069. <para>
  1070. Add your layer by using the
  1071. <filename>bitbake-layers add-layer</filename> command:
  1072. <literallayout class='monospaced'>
  1073. $ bitbake-layers add-layer <replaceable>your_layer_name</replaceable>
  1074. </literallayout>
  1075. Here is an example that adds a layer named
  1076. <filename>meta-scottrif</filename> to the configuration file.
  1077. Following the command that adds the layer is another
  1078. <filename>bitbake-layers</filename> command that shows the
  1079. layers that are in your <filename>bblayers.conf</filename>
  1080. file:
  1081. <literallayout class='monospaced'>
  1082. $ bitbake-layers add-layer meta-scottrif
  1083. NOTE: Starting bitbake server...
  1084. Parsing recipes: 100% |##########################################################| Time: 0:00:49
  1085. Parsing of 1441 .bb files complete (0 cached, 1441 parsed). 2055 targets, 56 skipped, 0 masked, 0 errors.
  1086. $ bitbake-layers show-layers
  1087. NOTE: Starting bitbake server...
  1088. layer path priority
  1089. ==========================================================================
  1090. meta /home/scottrif/poky/meta 5
  1091. meta-poky /home/scottrif/poky/meta-poky 5
  1092. meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5
  1093. workspace /home/scottrif/poky/build/workspace 99
  1094. meta-scottrif /home/scottrif/poky/build/meta-scottrif 6
  1095. </literallayout>
  1096. Adding the layer to this file enables the build system to
  1097. locate the layer during the build.
  1098. <note>
  1099. During a build, the OpenEmbedded build system looks in
  1100. the layers from the top of the list down to the bottom
  1101. in that order.
  1102. </note>
  1103. </para>
  1104. </section>
  1105. </section>
  1106. <section id='usingpoky-extend-customimage'>
  1107. <title>Customizing Images</title>
  1108. <para>
  1109. You can customize images to satisfy particular requirements.
  1110. This section describes several methods and provides guidelines for each.
  1111. </para>
  1112. <section id='usingpoky-extend-customimage-localconf'>
  1113. <title>Customizing Images Using <filename>local.conf</filename></title>
  1114. <para>
  1115. Probably the easiest way to customize an image is to add a
  1116. package by way of the <filename>local.conf</filename>
  1117. configuration file.
  1118. Because it is limited to local use, this method generally only
  1119. allows you to add packages and is not as flexible as creating
  1120. your own customized image.
  1121. When you add packages using local variables this way, you need
  1122. to realize that these variable changes are in effect for every
  1123. build and consequently affect all images, which might not
  1124. be what you require.
  1125. </para>
  1126. <para>
  1127. To add a package to your image using the local configuration
  1128. file, use the
  1129. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1130. variable with the <filename>_append</filename> operator:
  1131. <literallayout class='monospaced'>
  1132. IMAGE_INSTALL_append = " strace"
  1133. </literallayout>
  1134. Use of the syntax is important - specifically, the space between
  1135. the quote and the package name, which is
  1136. <filename>strace</filename> in this example.
  1137. This space is required since the <filename>_append</filename>
  1138. operator does not add the space.
  1139. </para>
  1140. <para>
  1141. Furthermore, you must use <filename>_append</filename> instead
  1142. of the <filename>+=</filename> operator if you want to avoid
  1143. ordering issues.
  1144. The reason for this is because doing so unconditionally appends
  1145. to the variable and avoids ordering problems due to the
  1146. variable being set in image recipes and
  1147. <filename>.bbclass</filename> files with operators like
  1148. <filename>?=</filename>.
  1149. Using <filename>_append</filename> ensures the operation takes
  1150. affect.
  1151. </para>
  1152. <para>
  1153. As shown in its simplest use,
  1154. <filename>IMAGE_INSTALL_append</filename> affects all images.
  1155. It is possible to extend the syntax so that the variable
  1156. applies to a specific image only.
  1157. Here is an example:
  1158. <literallayout class='monospaced'>
  1159. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  1160. </literallayout>
  1161. This example adds <filename>strace</filename> to the
  1162. <filename>core-image-minimal</filename> image only.
  1163. </para>
  1164. <para>
  1165. You can add packages using a similar approach through the
  1166. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename>
  1167. variable.
  1168. If you use this variable, only
  1169. <filename>core-image-*</filename> images are affected.
  1170. </para>
  1171. </section>
  1172. <section id='usingpoky-extend-customimage-imagefeatures'>
  1173. <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and
  1174. <filename>EXTRA_IMAGE_FEATURES</filename></title>
  1175. <para>
  1176. Another method for customizing your image is to enable or
  1177. disable high-level image features by using the
  1178. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  1179. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  1180. variables.
  1181. Although the functions for both variables are nearly equivalent,
  1182. best practices dictate using <filename>IMAGE_FEATURES</filename>
  1183. from within a recipe and using
  1184. <filename>EXTRA_IMAGE_FEATURES</filename> from within
  1185. your <filename>local.conf</filename> file, which is found in the
  1186. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1187. </para>
  1188. <para>
  1189. To understand how these features work, the best reference is
  1190. <filename>meta/classes/core-image.bbclass</filename>.
  1191. This class lists out the available
  1192. <filename>IMAGE_FEATURES</filename> of which most map to
  1193. package groups while some, such as
  1194. <filename>debug-tweaks</filename> and
  1195. <filename>read-only-rootfs</filename>, resolve as general
  1196. configuration settings.
  1197. </para>
  1198. <para>
  1199. In summary, the file looks at the contents of the
  1200. <filename>IMAGE_FEATURES</filename> variable and then maps
  1201. or configures the feature accordingly.
  1202. Based on this information, the build system automatically
  1203. adds the appropriate packages or configurations to the
  1204. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  1205. variable.
  1206. Effectively, you are enabling extra features by extending the
  1207. class or creating a custom class for use with specialized image
  1208. <filename>.bb</filename> files.
  1209. </para>
  1210. <para>
  1211. Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable
  1212. from within your local configuration file.
  1213. Using a separate area from which to enable features with
  1214. this variable helps you avoid overwriting the features in the
  1215. image recipe that are enabled with
  1216. <filename>IMAGE_FEATURES</filename>.
  1217. The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added
  1218. to <filename>IMAGE_FEATURES</filename> within
  1219. <filename>meta/conf/bitbake.conf</filename>.
  1220. </para>
  1221. <para>
  1222. To illustrate how you can use these variables to modify your
  1223. image, consider an example that selects the SSH server.
  1224. The Yocto Project ships with two SSH servers you can use
  1225. with your images: Dropbear and OpenSSH.
  1226. Dropbear is a minimal SSH server appropriate for
  1227. resource-constrained environments, while OpenSSH is a
  1228. well-known standard SSH server implementation.
  1229. By default, the <filename>core-image-sato</filename> image
  1230. is configured to use Dropbear.
  1231. The <filename>core-image-full-cmdline</filename> and
  1232. <filename>core-image-lsb</filename> images both
  1233. include OpenSSH.
  1234. The <filename>core-image-minimal</filename> image does not
  1235. contain an SSH server.
  1236. </para>
  1237. <para>
  1238. You can customize your image and change these defaults.
  1239. Edit the <filename>IMAGE_FEATURES</filename> variable
  1240. in your recipe or use the
  1241. <filename>EXTRA_IMAGE_FEATURES</filename> in your
  1242. <filename>local.conf</filename> file so that it configures the
  1243. image you are working with to include
  1244. <filename>ssh-server-dropbear</filename> or
  1245. <filename>ssh-server-openssh</filename>.
  1246. </para>
  1247. <note>
  1248. See the
  1249. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  1250. section in the Yocto Project Reference Manual for a complete
  1251. list of image features that ship with the Yocto Project.
  1252. </note>
  1253. </section>
  1254. <section id='usingpoky-extend-customimage-custombb'>
  1255. <title>Customizing Images Using Custom .bb Files</title>
  1256. <para>
  1257. You can also customize an image by creating a custom recipe
  1258. that defines additional software as part of the image.
  1259. The following example shows the form for the two lines you need:
  1260. <literallayout class='monospaced'>
  1261. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  1262. inherit core-image
  1263. </literallayout>
  1264. </para>
  1265. <para>
  1266. Defining the software using a custom recipe gives you total
  1267. control over the contents of the image.
  1268. It is important to use the correct names of packages in the
  1269. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1270. variable.
  1271. You must use the OpenEmbedded notation and not the Debian notation for the names
  1272. (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>).
  1273. </para>
  1274. <para>
  1275. The other method for creating a custom image is to base it on an existing image.
  1276. For example, if you want to create an image based on <filename>core-image-sato</filename>
  1277. but add the additional package <filename>strace</filename> to the image,
  1278. copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a
  1279. new <filename>.bb</filename> and add the following line to the end of the copy:
  1280. <literallayout class='monospaced'>
  1281. IMAGE_INSTALL += "strace"
  1282. </literallayout>
  1283. </para>
  1284. </section>
  1285. <section id='usingpoky-extend-customimage-customtasks'>
  1286. <title>Customizing Images Using Custom Package Groups</title>
  1287. <para>
  1288. For complex custom images, the best approach for customizing
  1289. an image is to create a custom package group recipe that is
  1290. used to build the image or images.
  1291. A good example of a package group recipe is
  1292. <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>.
  1293. </para>
  1294. <para>
  1295. If you examine that recipe, you see that the
  1296. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename>
  1297. variable lists the package group packages to produce.
  1298. The <filename>inherit packagegroup</filename> statement
  1299. sets appropriate default values and automatically adds
  1300. <filename>-dev</filename>, <filename>-dbg</filename>, and
  1301. <filename>-ptest</filename> complementary packages for each
  1302. package specified in the <filename>PACKAGES</filename>
  1303. statement.
  1304. <note>
  1305. The <filename>inherit packages</filename> should be
  1306. located near the top of the recipe, certainly before
  1307. the <filename>PACKAGES</filename> statement.
  1308. </note>
  1309. </para>
  1310. <para>
  1311. For each package you specify in <filename>PACKAGES</filename>,
  1312. you can use
  1313. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename>
  1314. and
  1315. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename>
  1316. entries to provide a list of packages the parent task package
  1317. should contain.
  1318. You can see examples of these further down in the
  1319. <filename>packagegroup-base.bb</filename> recipe.
  1320. </para>
  1321. <para>
  1322. Here is a short, fabricated example showing the same basic
  1323. pieces:
  1324. <literallayout class='monospaced'>
  1325. DESCRIPTION = "My Custom Package Groups"
  1326. inherit packagegroup
  1327. PACKAGES = "\
  1328. packagegroup-custom-apps \
  1329. packagegroup-custom-tools \
  1330. "
  1331. RDEPENDS_packagegroup-custom-apps = "\
  1332. dropbear \
  1333. portmap \
  1334. psplash"
  1335. RDEPENDS_packagegroup-custom-tools = "\
  1336. oprofile \
  1337. oprofileui-server \
  1338. lttng-tools"
  1339. RRECOMMENDS_packagegroup-custom-tools = "\
  1340. kernel-module-oprofile"
  1341. </literallayout>
  1342. </para>
  1343. <para>
  1344. In the previous example, two package group packages are created with their dependencies and their
  1345. recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and
  1346. <filename>packagegroup-custom-tools</filename>.
  1347. To build an image using these package group packages, you need to add
  1348. <filename>packagegroup-custom-apps</filename> and/or
  1349. <filename>packagegroup-custom-tools</filename> to
  1350. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>.
  1351. For other forms of image dependencies see the other areas of this section.
  1352. </para>
  1353. </section>
  1354. <section id='usingpoky-extend-customimage-image-name'>
  1355. <title>Customizing an Image Hostname</title>
  1356. <para>
  1357. By default, the configured hostname (i.e.
  1358. <filename>/etc/hostname</filename>) in an image is the
  1359. same as the machine name.
  1360. For example, if
  1361. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  1362. equals "qemux86", the configured hostname written to
  1363. <filename>/etc/hostname</filename> is "qemux86".
  1364. </para>
  1365. <para>
  1366. You can customize this name by altering the value of the
  1367. "hostname" variable in the
  1368. <filename>base-files</filename> recipe using either
  1369. an append file or a configuration file.
  1370. Use the following in an append file:
  1371. <literallayout class='monospaced'>
  1372. hostname="myhostname"
  1373. </literallayout>
  1374. Use the following in a configuration file:
  1375. <literallayout class='monospaced'>
  1376. hostname_pn-base-files = "myhostname"
  1377. </literallayout>
  1378. </para>
  1379. <para>
  1380. Changing the default value of the variable "hostname" can be
  1381. useful in certain situations.
  1382. For example, suppose you need to do extensive testing on an
  1383. image and you would like to easily identify the image
  1384. under test from existing images with typical default
  1385. hostnames.
  1386. In this situation, you could change the default hostname to
  1387. "testme", which results in all the images using the name
  1388. "testme".
  1389. Once testing is complete and you do not need to rebuild the
  1390. image for test any longer, you can easily reset the default
  1391. hostname.
  1392. </para>
  1393. <para>
  1394. Another point of interest is that if you unset the variable,
  1395. the image will have no default hostname in the filesystem.
  1396. Here is an example that unsets the variable in a
  1397. configuration file:
  1398. <literallayout class='monospaced'>
  1399. hostname_pn-base-files = ""
  1400. </literallayout>
  1401. Having no default hostname in the filesystem is suitable for
  1402. environments that use dynamic hostnames such as virtual
  1403. machines.
  1404. </para>
  1405. </section>
  1406. </section>
  1407. <section id='new-recipe-writing-a-new-recipe'>
  1408. <title>Writing a New Recipe</title>
  1409. <para>
  1410. Recipes (<filename>.bb</filename> files) are fundamental components
  1411. in the Yocto Project environment.
  1412. Each software component built by the OpenEmbedded build system
  1413. requires a recipe to define the component.
  1414. This section describes how to create, write, and test a new
  1415. recipe.
  1416. <note>
  1417. For information on variables that are useful for recipes and
  1418. for information about recipe naming issues, see the
  1419. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>"
  1420. section of the Yocto Project Reference Manual.
  1421. </note>
  1422. </para>
  1423. <section id='new-recipe-overview'>
  1424. <title>Overview</title>
  1425. <para>
  1426. The following figure shows the basic process for creating a
  1427. new recipe.
  1428. The remainder of the section provides details for the steps.
  1429. <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" />
  1430. </para>
  1431. </section>
  1432. <section id='new-recipe-locate-or-automatically-create-a-base-recipe'>
  1433. <title>Locate or Automatically Create a Base Recipe</title>
  1434. <para>
  1435. You can always write a recipe from scratch.
  1436. However, three choices exist that can help you quickly get a
  1437. start on a new recipe:
  1438. <itemizedlist>
  1439. <listitem><para>
  1440. <emphasis><filename>devtool add</filename>:</emphasis>
  1441. A command that assists in creating a recipe and
  1442. an environment conducive to development.
  1443. </para></listitem>
  1444. <listitem><para>
  1445. <emphasis><filename>recipetool create</filename>:</emphasis>
  1446. A command provided by the Yocto Project that automates
  1447. creation of a base recipe based on the source
  1448. files.
  1449. </para></listitem>
  1450. <listitem><para>
  1451. <emphasis>Existing Recipes:</emphasis>
  1452. Location and modification of an existing recipe that is
  1453. similar in function to the recipe you need.
  1454. </para></listitem>
  1455. </itemizedlist>
  1456. <note>
  1457. For information on recipe syntax, see the
  1458. "<link linkend='recipe-syntax'>Recipe Syntax</link>"
  1459. section.
  1460. </note>
  1461. </para>
  1462. <section id='new-recipe-creating-the-base-recipe-using-devtool'>
  1463. <title>Creating the Base Recipe Using <filename>devtool add</filename></title>
  1464. <para>
  1465. The <filename>devtool add</filename> command uses the same
  1466. logic for auto-creating the recipe as
  1467. <filename>recipetool create</filename>, which is listed
  1468. below.
  1469. Additionally, however, <filename>devtool add</filename>
  1470. sets up an environment that makes it easy for you to
  1471. patch the source and to make changes to the recipe as
  1472. is often necessary when adding a recipe to build a new
  1473. piece of software to be included in a build.
  1474. </para>
  1475. <para>
  1476. You can find a complete description of the
  1477. <filename>devtool add</filename> command in the
  1478. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-a-closer-look-at-devtool-add'>A Closer Look at <filename>devtool</filename> add</ulink>"
  1479. section in the Yocto Project Application Development
  1480. and the Extensible Software Development Kit (eSDK) manual.
  1481. </para>
  1482. </section>
  1483. <section id='new-recipe-creating-the-base-recipe-using-recipetool'>
  1484. <title>Creating the Base Recipe Using <filename>recipetool create</filename></title>
  1485. <para>
  1486. <filename>recipetool create</filename> automates creation
  1487. of a base recipe given a set of source code files.
  1488. As long as you can extract or point to the source files,
  1489. the tool will construct a recipe and automatically
  1490. configure all pre-build information into the recipe.
  1491. For example, suppose you have an application that builds
  1492. using Autotools.
  1493. Creating the base recipe using
  1494. <filename>recipetool</filename> results in a recipe
  1495. that has the pre-build dependencies, license requirements,
  1496. and checksums configured.
  1497. </para>
  1498. <para>
  1499. To run the tool, you just need to be in your
  1500. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1501. and have sourced the build environment setup script
  1502. (i.e.
  1503. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>).
  1504. To get help on the tool, use the following command:
  1505. <literallayout class='monospaced'>
  1506. $ recipetool -h
  1507. NOTE: Starting bitbake server...
  1508. usage: recipetool [-d] [-q] [--color COLOR] [-h] &lt;subcommand&gt; ...
  1509. OpenEmbedded recipe tool
  1510. options:
  1511. -d, --debug Enable debug output
  1512. -q, --quiet Print only errors
  1513. --color COLOR Colorize output (where COLOR is auto, always, never)
  1514. -h, --help show this help message and exit
  1515. subcommands:
  1516. create Create a new recipe
  1517. newappend Create a bbappend for the specified target in the specified
  1518. layer
  1519. setvar Set a variable within a recipe
  1520. appendfile Create/update a bbappend to replace a target file
  1521. appendsrcfiles Create/update a bbappend to add or replace source files
  1522. appendsrcfile Create/update a bbappend to add or replace a source file
  1523. Use recipetool &lt;subcommand&gt; --help to get help on a specific command
  1524. </literallayout>
  1525. </para>
  1526. <para>
  1527. Running
  1528. <filename>recipetool create -o</filename>&nbsp;<replaceable>OUTFILE</replaceable>
  1529. creates the base recipe and locates it properly in the
  1530. layer that contains your source files.
  1531. Following are some syntax examples:
  1532. </para>
  1533. <para>
  1534. Use this syntax to generate a recipe based on
  1535. <replaceable>source</replaceable>.
  1536. Once generated, the recipe resides in the existing source
  1537. code layer:
  1538. <literallayout class='monospaced'>
  1539. recipetool create -o <replaceable>OUTFILE</replaceable>&nbsp;<replaceable>source</replaceable>
  1540. </literallayout>
  1541. Use this syntax to generate a recipe using code that you
  1542. extract from <replaceable>source</replaceable>.
  1543. The extracted code is placed in its own layer defined
  1544. by <replaceable>EXTERNALSRC</replaceable>.
  1545. <literallayout class='monospaced'>
  1546. recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable>
  1547. </literallayout>
  1548. Use this syntax to generate a recipe based on
  1549. <replaceable>source</replaceable>.
  1550. The options direct <filename>recipetool</filename> to
  1551. generate debugging information.
  1552. Once generated, the recipe resides in the existing source
  1553. code layer:
  1554. <literallayout class='monospaced'>
  1555. recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable>
  1556. </literallayout>
  1557. </para>
  1558. </section>
  1559. <section id='new-recipe-locating-and-using-a-similar-recipe'>
  1560. <title>Locating and Using a Similar Recipe</title>
  1561. <para>
  1562. Before writing a recipe from scratch, it is often useful to
  1563. discover whether someone else has already written one that
  1564. meets (or comes close to meeting) your needs.
  1565. The Yocto Project and OpenEmbedded communities maintain many
  1566. recipes that might be candidates for what you are doing.
  1567. You can find a good central index of these recipes in the
  1568. <ulink url='http://layers.openembedded.org'>OpenEmbedded Layer Index</ulink>.
  1569. </para>
  1570. <para>
  1571. Working from an existing recipe or a skeleton recipe is the
  1572. best way to get started.
  1573. Here are some points on both methods:
  1574. <itemizedlist>
  1575. <listitem><para><emphasis>Locate and modify a recipe that
  1576. is close to what you want to do:</emphasis>
  1577. This method works when you are familiar with the
  1578. current recipe space.
  1579. The method does not work so well for those new to
  1580. the Yocto Project or writing recipes.</para>
  1581. <para>Some risks associated with this method are
  1582. using a recipe that has areas totally unrelated to
  1583. what you are trying to accomplish with your recipe,
  1584. not recognizing areas of the recipe that you might
  1585. have to add from scratch, and so forth.
  1586. All these risks stem from unfamiliarity with the
  1587. existing recipe space.</para></listitem>
  1588. <listitem><para><emphasis>Use and modify the following
  1589. skeleton recipe:</emphasis>
  1590. If for some reason you do not want to use
  1591. <filename>recipetool</filename> and you cannot
  1592. find an existing recipe that is close to meeting
  1593. your needs, you can use the following structure to
  1594. provide the fundamental areas of a new recipe.
  1595. <literallayout class='monospaced'>
  1596. DESCRIPTION = ""
  1597. HOMEPAGE = ""
  1598. LICENSE = ""
  1599. SECTION = ""
  1600. DEPENDS = ""
  1601. LIC_FILES_CHKSUM = ""
  1602. SRC_URI = ""
  1603. </literallayout>
  1604. </para></listitem>
  1605. </itemizedlist>
  1606. </para>
  1607. </section>
  1608. </section>
  1609. <section id='new-recipe-storing-and-naming-the-recipe'>
  1610. <title>Storing and Naming the Recipe</title>
  1611. <para>
  1612. Once you have your base recipe, you should put it in your
  1613. own layer and name it appropriately.
  1614. Locating it correctly ensures that the OpenEmbedded build
  1615. system can find it when you use BitBake to process the
  1616. recipe.
  1617. </para>
  1618. <itemizedlist>
  1619. <listitem><para><emphasis>Storing Your Recipe:</emphasis>
  1620. The OpenEmbedded build system locates your recipe
  1621. through the layer's <filename>conf/layer.conf</filename>
  1622. file and the
  1623. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>
  1624. variable.
  1625. This variable sets up a path from which the build system can
  1626. locate recipes.
  1627. Here is the typical use:
  1628. <literallayout class='monospaced'>
  1629. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  1630. ${LAYERDIR}/recipes-*/*/*.bbappend"
  1631. </literallayout>
  1632. Consequently, you need to be sure you locate your new recipe
  1633. inside your layer such that it can be found.</para>
  1634. <para>You can find more information on how layers are
  1635. structured in the
  1636. "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
  1637. section.</para></listitem>
  1638. <listitem><para><emphasis>Naming Your Recipe:</emphasis>
  1639. When you name your recipe, you need to follow this naming
  1640. convention:
  1641. <literallayout class='monospaced'>
  1642. <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb
  1643. </literallayout>
  1644. Use lower-cased characters and do not include the reserved
  1645. suffixes <filename>-native</filename>,
  1646. <filename>-cross</filename>, <filename>-initial</filename>,
  1647. or <filename>-dev</filename> casually (i.e. do not use them
  1648. as part of your recipe name unless the string applies).
  1649. Here are some examples:
  1650. <literallayout class='monospaced'>
  1651. cups_1.7.0.bb
  1652. gawk_4.0.2.bb
  1653. irssi_0.8.16-rc1.bb
  1654. </literallayout></para></listitem>
  1655. </itemizedlist>
  1656. </section>
  1657. <section id='new-recipe-running-a-build-on-the-recipe'>
  1658. <title>Running a Build on the Recipe</title>
  1659. <para>
  1660. Creating a new recipe is usually an iterative process that
  1661. requires using BitBake to process the recipe multiple times in
  1662. order to progressively discover and add information to the
  1663. recipe file.
  1664. </para>
  1665. <para>
  1666. Assuming you have sourced the build environment setup script (i.e.
  1667. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  1668. and you are in the
  1669. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  1670. use BitBake to process your recipe.
  1671. All you need to provide is the
  1672. <filename><replaceable>basename</replaceable></filename> of the recipe as described
  1673. in the previous section:
  1674. <literallayout class='monospaced'>
  1675. $ bitbake <replaceable>basename</replaceable>
  1676. </literallayout>
  1677. </para>
  1678. <para>
  1679. During the build, the OpenEmbedded build system creates a
  1680. temporary work directory for each recipe
  1681. (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>)
  1682. where it keeps extracted source files, log files, intermediate
  1683. compilation and packaging files, and so forth.
  1684. </para>
  1685. <para>
  1686. The path to the per-recipe temporary work directory depends
  1687. on the context in which it is being built.
  1688. The quickest way to find this path is to have BitBake return it
  1689. by running the following:
  1690. <literallayout class='monospaced'>
  1691. $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR=
  1692. </literallayout>
  1693. As an example, assume a Source Directory top-level folder named
  1694. <filename>poky</filename>, a default Build Directory at
  1695. <filename>poky/build</filename>, and a
  1696. <filename>qemux86-poky-linux</filename> machine target system.
  1697. Furthermore, suppose your recipe is named
  1698. <filename>foo_1.3.0.bb</filename>.
  1699. In this case, the work directory the build system uses to
  1700. build the package would be as follows:
  1701. <literallayout class='monospaced'>
  1702. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1703. </literallayout>
  1704. Inside this directory you can find sub-directories such as
  1705. <filename>image</filename>, <filename>packages-split</filename>,
  1706. and <filename>temp</filename>.
  1707. After the build, you can examine these to determine how well
  1708. the build went.
  1709. <note>
  1710. You can find log files for each task in the recipe's
  1711. <filename>temp</filename> directory (e.g.
  1712. <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>).
  1713. Log files are named <filename>log.<replaceable>taskname</replaceable></filename>
  1714. (e.g. <filename>log.do_configure</filename>,
  1715. <filename>log.do_fetch</filename>, and
  1716. <filename>log.do_compile</filename>).
  1717. </note>
  1718. </para>
  1719. <para>
  1720. You can find more information about the build process in
  1721. "<ulink url='&YOCTO_DOCS_OM_URL;#overview-development-environment'>The Yocto Project Development Environment</ulink>"
  1722. chapter of the Yocto Project Overview and Concepts Manual.
  1723. </para>
  1724. </section>
  1725. <section id='new-recipe-fetching-code'>
  1726. <title>Fetching Code</title>
  1727. <para>
  1728. The first thing your recipe must do is specify how to fetch
  1729. the source files.
  1730. Fetching is controlled mainly through the
  1731. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1732. variable.
  1733. Your recipe must have a <filename>SRC_URI</filename> variable
  1734. that points to where the source is located.
  1735. For a graphical representation of source locations, see the
  1736. "<ulink url='&YOCTO_DOCS_OM_URL;#sources-dev-environment'>Sources</ulink>"
  1737. section in the Yocto Project Overview and Concepts Manual.
  1738. </para>
  1739. <para>
  1740. The
  1741. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1742. task uses the prefix of each entry in the
  1743. <filename>SRC_URI</filename> variable value to determine which
  1744. fetcher to use to get your source files.
  1745. It is the <filename>SRC_URI</filename> variable that triggers
  1746. the fetcher.
  1747. The
  1748. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1749. task uses the variable after source is fetched to apply
  1750. patches.
  1751. The OpenEmbedded build system uses
  1752. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink>
  1753. for scanning directory locations for local files in
  1754. <filename>SRC_URI</filename>.
  1755. </para>
  1756. <para>
  1757. The <filename>SRC_URI</filename> variable in your recipe must
  1758. define each unique location for your source files.
  1759. It is good practice to not hard-code pathnames in an URL used
  1760. in <filename>SRC_URI</filename>.
  1761. Rather than hard-code these paths, use
  1762. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1763. which causes the fetch process to use the version specified in
  1764. the recipe filename.
  1765. Specifying the version in this manner means that upgrading the
  1766. recipe to a future version is as simple as renaming the recipe
  1767. to match the new version.
  1768. </para>
  1769. <para>
  1770. Here is a simple example from the
  1771. <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename>
  1772. recipe where the source comes from a single tarball.
  1773. Notice the use of the
  1774. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1775. variable:
  1776. <literallayout class='monospaced'>
  1777. SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2"
  1778. </literallayout>
  1779. </para>
  1780. <para>
  1781. Files mentioned in <filename>SRC_URI</filename> whose names end
  1782. in a typical archive extension (e.g. <filename>.tar</filename>,
  1783. <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>,
  1784. <filename>.zip</filename>, and so forth), are automatically
  1785. extracted during the
  1786. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1787. task.
  1788. For another example that specifies these types of files, see
  1789. the
  1790. "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>"
  1791. section.
  1792. </para>
  1793. <para>
  1794. Another way of specifying source is from an SCM.
  1795. For Git repositories, you must specify
  1796. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  1797. and you should specify
  1798. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1799. to include the revision with
  1800. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  1801. Here is an example from the recipe
  1802. <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>:
  1803. <literallayout class='monospaced'>
  1804. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1805. PR = "r6"
  1806. PV = "1.0.5+git${SRCPV}"
  1807. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1808. file://ldflags.patch"
  1809. </literallayout>
  1810. </para>
  1811. <para>
  1812. If your <filename>SRC_URI</filename> statement includes
  1813. URLs pointing to individual files fetched from a remote server
  1814. other than a version control system, BitBake attempts to
  1815. verify the files against checksums defined in your recipe to
  1816. ensure they have not been tampered with or otherwise modified
  1817. since the recipe was written.
  1818. Two checksums are used:
  1819. <filename>SRC_URI[md5sum]</filename> and
  1820. <filename>SRC_URI[sha256sum]</filename>.
  1821. </para>
  1822. <para>
  1823. If your <filename>SRC_URI</filename> variable points to
  1824. more than a single URL (excluding SCM URLs), you need to
  1825. provide the <filename>md5</filename> and
  1826. <filename>sha256</filename> checksums for each URL.
  1827. For these cases, you provide a name for each URL as part of
  1828. the <filename>SRC_URI</filename> and then reference that name
  1829. in the subsequent checksum statements.
  1830. Here is an example:
  1831. <literallayout class='monospaced'>
  1832. SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \
  1833. ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch"
  1834. SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
  1835. SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
  1836. SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92"
  1837. SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
  1838. </literallayout>
  1839. </para>
  1840. <para>
  1841. Proper values for <filename>md5</filename> and
  1842. <filename>sha256</filename> checksums might be available
  1843. with other signatures on the download page for the upstream
  1844. source (e.g. <filename>md5</filename>,
  1845. <filename>sha1</filename>, <filename>sha256</filename>,
  1846. <filename>GPG</filename>, and so forth).
  1847. Because the OpenEmbedded build system only deals with
  1848. <filename>sha256sum</filename> and <filename>md5sum</filename>,
  1849. you should verify all the signatures you find by hand.
  1850. </para>
  1851. <para>
  1852. If no <filename>SRC_URI</filename> checksums are specified
  1853. when you attempt to build the recipe, or you provide an
  1854. incorrect checksum, the build will produce an error for each
  1855. missing or incorrect checksum.
  1856. As part of the error message, the build system provides
  1857. the checksum string corresponding to the fetched file.
  1858. Once you have the correct checksums, you can copy and paste
  1859. them into your recipe and then run the build again to continue.
  1860. <note>
  1861. As mentioned, if the upstream source provides signatures
  1862. for verifying the downloaded source code, you should
  1863. verify those manually before setting the checksum values
  1864. in the recipe and continuing with the build.
  1865. </note>
  1866. </para>
  1867. <para>
  1868. This final example is a bit more complicated and is from the
  1869. <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename>
  1870. recipe.
  1871. The example's <filename>SRC_URI</filename> statement identifies
  1872. multiple files as the source files for the recipe: a tarball, a
  1873. patch file, a desktop file, and an icon.
  1874. <literallayout class='monospaced'>
  1875. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1876. file://xwc.patch \
  1877. file://rxvt.desktop \
  1878. file://rxvt.png"
  1879. </literallayout>
  1880. </para>
  1881. <para>
  1882. When you specify local files using the
  1883. <filename>file://</filename> URI protocol, the build system
  1884. fetches files from the local machine.
  1885. The path is relative to the
  1886. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1887. variable and searches specific directories in a certain order:
  1888. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>,
  1889. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>,
  1890. and <filename>files</filename>.
  1891. The directories are assumed to be subdirectories of the
  1892. directory in which the recipe or append file resides.
  1893. For another example that specifies these types of files, see the
  1894. "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>"
  1895. section.
  1896. </para>
  1897. <para>
  1898. The previous example also specifies a patch file.
  1899. Patch files are files whose names usually end in
  1900. <filename>.patch</filename> or <filename>.diff</filename> but
  1901. can end with compressed suffixes such as
  1902. <filename>diff.gz</filename> and
  1903. <filename>patch.bz2</filename>, for example.
  1904. The build system automatically applies patches as described
  1905. in the
  1906. "<link linkend='new-recipe-patching-code'>Patching Code</link>" section.
  1907. </para>
  1908. </section>
  1909. <section id='new-recipe-unpacking-code'>
  1910. <title>Unpacking Code</title>
  1911. <para>
  1912. During the build, the
  1913. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1914. task unpacks the source with
  1915. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>
  1916. pointing to where it is unpacked.
  1917. </para>
  1918. <para>
  1919. If you are fetching your source files from an upstream source
  1920. archived tarball and the tarball's internal structure matches
  1921. the common convention of a top-level subdirectory named
  1922. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}-${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1923. then you do not need to set <filename>S</filename>.
  1924. However, if <filename>SRC_URI</filename> specifies to fetch
  1925. source from an archive that does not use this convention,
  1926. or from an SCM like Git or Subversion, your recipe needs to
  1927. define <filename>S</filename>.
  1928. </para>
  1929. <para>
  1930. If processing your recipe using BitBake successfully unpacks
  1931. the source files, you need to be sure that the directory
  1932. pointed to by <filename>${S}</filename> matches the structure
  1933. of the source.
  1934. </para>
  1935. </section>
  1936. <section id='new-recipe-patching-code'>
  1937. <title>Patching Code</title>
  1938. <para>
  1939. Sometimes it is necessary to patch code after it has been
  1940. fetched.
  1941. Any files mentioned in <filename>SRC_URI</filename> whose
  1942. names end in <filename>.patch</filename> or
  1943. <filename>.diff</filename> or compressed versions of these
  1944. suffixes (e.g. <filename>diff.gz</filename> are treated as
  1945. patches.
  1946. The
  1947. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1948. task automatically applies these patches.
  1949. </para>
  1950. <para>
  1951. The build system should be able to apply patches with the "-p1"
  1952. option (i.e. one directory level in the path will be stripped
  1953. off).
  1954. If your patch needs to have more directory levels stripped off,
  1955. specify the number of levels using the "striplevel" option in
  1956. the <filename>SRC_URI</filename> entry for the patch.
  1957. Alternatively, if your patch needs to be applied in a specific
  1958. subdirectory that is not specified in the patch file, use the
  1959. "patchdir" option in the entry.
  1960. </para>
  1961. <para>
  1962. As with all local files referenced in
  1963. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1964. using <filename>file://</filename>, you should place
  1965. patch files in a directory next to the recipe either
  1966. named the same as the base name of the recipe
  1967. (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  1968. and
  1969. <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>)
  1970. or "files".
  1971. </para>
  1972. </section>
  1973. <section id='new-recipe-licensing'>
  1974. <title>Licensing</title>
  1975. <para>
  1976. Your recipe needs to have both the
  1977. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  1978. and
  1979. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  1980. variables:
  1981. <itemizedlist>
  1982. <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis>
  1983. This variable specifies the license for the software.
  1984. If you do not know the license under which the software
  1985. you are building is distributed, you should go to the
  1986. source code and look for that information.
  1987. Typical files containing this information include
  1988. <filename>COPYING</filename>,
  1989. <filename>LICENSE</filename>, and
  1990. <filename>README</filename> files.
  1991. You could also find the information near the top of
  1992. a source file.
  1993. For example, given a piece of software licensed under
  1994. the GNU General Public License version 2, you would
  1995. set <filename>LICENSE</filename> as follows:
  1996. <literallayout class='monospaced'>
  1997. LICENSE = "GPLv2"
  1998. </literallayout></para>
  1999. <para>The licenses you specify within
  2000. <filename>LICENSE</filename> can have any name as long
  2001. as you do not use spaces, since spaces are used as
  2002. separators between license names.
  2003. For standard licenses, use the names of the files in
  2004. <filename>meta/files/common-licenses/</filename>
  2005. or the <filename>SPDXLICENSEMAP</filename> flag names
  2006. defined in <filename>meta/conf/licenses.conf</filename>.
  2007. </para></listitem>
  2008. <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis>
  2009. The OpenEmbedded build system uses this variable to
  2010. make sure the license text has not changed.
  2011. If it has, the build produces an error and it affords
  2012. you the chance to figure it out and correct the problem.
  2013. </para>
  2014. <para>You need to specify all applicable licensing
  2015. files for the software.
  2016. At the end of the configuration step, the build process
  2017. will compare the checksums of the files to be sure
  2018. the text has not changed.
  2019. Any differences result in an error with the message
  2020. containing the current checksum.
  2021. For more explanation and examples of how to set the
  2022. <filename>LIC_FILES_CHKSUM</filename> variable, see the
  2023. "<link link='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>"
  2024. section.</para>
  2025. <para>To determine the correct checksum string, you
  2026. can list the appropriate files in the
  2027. <filename>LIC_FILES_CHKSUM</filename> variable with
  2028. incorrect md5 strings, attempt to build the software,
  2029. and then note the resulting error messages that will
  2030. report the correct md5 strings.
  2031. See the
  2032. "<link linkend='new-recipe-fetching-code'>Fetching Code</link>"
  2033. section for additional information.
  2034. </para>
  2035. <para>
  2036. Here is an example that assumes the software has a
  2037. <filename>COPYING</filename> file:
  2038. <literallayout class='monospaced'>
  2039. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  2040. </literallayout>
  2041. When you try to build the software, the build system
  2042. will produce an error and give you the correct string
  2043. that you can substitute into the recipe file for a
  2044. subsequent build.
  2045. </para></listitem>
  2046. </itemizedlist>
  2047. </para>
  2048. <!--
  2049. <para>
  2050. For trying this out I created a new recipe named
  2051. <filename>htop_1.0.2.bb</filename> and put it in
  2052. <filename>poky/meta/recipes-extended/htop</filename>.
  2053. There are two license type statements in my very simple
  2054. recipe:
  2055. <literallayout class='monospaced'>
  2056. LICENSE = ""
  2057. LIC_FILES_CHKSUM = ""
  2058. SRC_URI[md5sum] = ""
  2059. SRC_URI[sha256sum] = ""
  2060. </literallayout>
  2061. Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>.
  2062. Next, you delete or comment out the two <filename>SRC_URI</filename>
  2063. lines at the end and then attempt to build the software with
  2064. <filename>bitbake htop</filename>.
  2065. Doing so causes BitBake to report some errors and and give
  2066. you the actual strings you need for the last two
  2067. <filename>SRC_URI</filename> lines.
  2068. Prior to this, you have to dig around in the home page of the
  2069. source for <filename>htop</filename> and determine that the
  2070. software is released under GPLv2.
  2071. You can provide that in the <filename>LICENSE</filename>
  2072. statement.
  2073. Now you edit your recipe to have those two strings for
  2074. the <filename>SRC_URI</filename> statements:
  2075. <literallayout class='monospaced'>
  2076. LICENSE = "GPLv2"
  2077. LIC_FILES_CHKSUM = ""
  2078. SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz"
  2079. SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e"
  2080. SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1"
  2081. </literallayout>
  2082. At this point, you can build the software again using the
  2083. <filename>bitbake htop</filename> command.
  2084. There is just a set of errors now associated with the
  2085. empty <filename>LIC_FILES_CHKSUM</filename> variable now.
  2086. </para>
  2087. -->
  2088. </section>
  2089. <section id='new-dependencies'>
  2090. <title>Dependencies</title>
  2091. <para>
  2092. Most software packages have a short list of other packages
  2093. that they require, which are called dependencies.
  2094. These dependencies fall into two main categories: build-time
  2095. dependencies, which are required when the software is built;
  2096. and runtime dependencies, which are required to be installed
  2097. on the target in order for the software to run.
  2098. </para>
  2099. <para>
  2100. Within a recipe, you specify build-time dependencies using the
  2101. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2102. variable.
  2103. Although nuances exist, items specified in
  2104. <filename>DEPENDS</filename> should be names of other recipes.
  2105. It is important that you specify all build-time dependencies
  2106. explicitly.
  2107. If you do not, due to the parallel nature of BitBake's
  2108. execution, you can end up with a race condition where the
  2109. dependency is present for one task of a recipe (e.g.
  2110. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>)
  2111. and then gone when the next task runs (e.g.
  2112. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>).
  2113. </para>
  2114. <para>
  2115. Another consideration is that configure scripts might
  2116. automatically check for optional dependencies and enable
  2117. corresponding functionality if those dependencies are found.
  2118. This behavior means that to ensure deterministic results and
  2119. thus avoid more race conditions, you need to either explicitly
  2120. specify these dependencies as well, or tell the configure
  2121. script explicitly to disable the functionality.
  2122. If you wish to make a recipe that is more generally useful
  2123. (e.g. publish the recipe in a layer for others to use),
  2124. instead of hard-disabling the functionality, you can use the
  2125. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink>
  2126. variable to allow functionality and the corresponding
  2127. dependencies to be enabled and disabled easily by other
  2128. users of the recipe.
  2129. </para>
  2130. <para>
  2131. Similar to build-time dependencies, you specify runtime
  2132. dependencies through a variable -
  2133. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  2134. which is package-specific.
  2135. All variables that are package-specific need to have the name
  2136. of the package added to the end as an override.
  2137. Since the main package for a recipe has the same name as the
  2138. recipe, and the recipe's name can be found through the
  2139. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2140. variable, then you specify the dependencies for the main
  2141. package by setting <filename>RDEPENDS_${PN}</filename>.
  2142. If the package were named <filename>${PN}-tools</filename>,
  2143. then you would set <filename>RDEPENDS_${PN}-tools</filename>,
  2144. and so forth.
  2145. </para>
  2146. <para>
  2147. Some runtime dependencies will be set automatically at
  2148. packaging time.
  2149. These dependencies include any shared library dependencies
  2150. (i.e. if a package "example" contains "libexample" and
  2151. another package "mypackage" contains a binary that links to
  2152. "libexample" then the OpenEmbedded build system will
  2153. automatically add a runtime dependency to "mypackage" on
  2154. "example").
  2155. See the
  2156. "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  2157. section in the Yocto Project Overview and Concepts Manual for
  2158. further details.
  2159. </para>
  2160. </section>
  2161. <section id='new-recipe-configuring-the-recipe'>
  2162. <title>Configuring the Recipe</title>
  2163. <para>
  2164. Most software provides some means of setting build-time
  2165. configuration options before compilation.
  2166. Typically, setting these options is accomplished by running a
  2167. configure script with some options, or by modifying a build
  2168. configuration file.
  2169. <note>
  2170. As of Yocto Project Release 1.7, some of the core recipes
  2171. that package binary configuration scripts now disable the
  2172. scripts due to the scripts previously requiring error-prone
  2173. path substitution.
  2174. The OpenEmbedded build system uses
  2175. <filename>pkg-config</filename> now, which is much more
  2176. robust.
  2177. You can find a list of the <filename>*-config</filename>
  2178. scripts that are disabled list in the
  2179. "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>"
  2180. section in the Yocto Project Reference Manual.
  2181. </note>
  2182. </para>
  2183. <para>
  2184. A major part of build-time configuration is about checking for
  2185. build-time dependencies and possibly enabling optional
  2186. functionality as a result.
  2187. You need to specify any build-time dependencies for the
  2188. software you are building in your recipe's
  2189. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2190. value, in terms of other recipes that satisfy those
  2191. dependencies.
  2192. You can often find build-time or runtime
  2193. dependencies described in the software's documentation.
  2194. </para>
  2195. <para>
  2196. The following list provides configuration items of note based
  2197. on how your software is built:
  2198. <itemizedlist>
  2199. <listitem><para><emphasis>Autotools:</emphasis>
  2200. If your source files have a
  2201. <filename>configure.ac</filename> file, then your
  2202. software is built using Autotools.
  2203. If this is the case, you just need to worry about
  2204. modifying the configuration.</para>
  2205. <para>When using Autotools, your recipe needs to inherit
  2206. the
  2207. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2208. class and your recipe does not have to contain a
  2209. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2210. task.
  2211. However, you might still want to make some adjustments.
  2212. For example, you can set
  2213. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  2214. or
  2215. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2216. to pass any needed configure options that are specific
  2217. to the recipe.</para></listitem>
  2218. <listitem><para><emphasis>CMake:</emphasis>
  2219. If your source files have a
  2220. <filename>CMakeLists.txt</filename> file, then your
  2221. software is built using CMake.
  2222. If this is the case, you just need to worry about
  2223. modifying the configuration.</para>
  2224. <para>When you use CMake, your recipe needs to inherit
  2225. the
  2226. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2227. class and your recipe does not have to contain a
  2228. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2229. task.
  2230. You can make some adjustments by setting
  2231. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
  2232. to pass any needed configure options that are specific
  2233. to the recipe.</para></listitem>
  2234. <listitem><para><emphasis>Other:</emphasis>
  2235. If your source files do not have a
  2236. <filename>configure.ac</filename> or
  2237. <filename>CMakeLists.txt</filename> file, then your
  2238. software is built using some method other than Autotools
  2239. or CMake.
  2240. If this is the case, you normally need to provide a
  2241. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2242. task in your recipe
  2243. unless, of course, there is nothing to configure.
  2244. </para>
  2245. <para>Even if your software is not being built by
  2246. Autotools or CMake, you still might not need to deal
  2247. with any configuration issues.
  2248. You need to determine if configuration is even a required step.
  2249. You might need to modify a Makefile or some configuration file
  2250. used for the build to specify necessary build options.
  2251. Or, perhaps you might need to run a provided, custom
  2252. configure script with the appropriate options.</para>
  2253. <para>For the case involving a custom configure
  2254. script, you would run
  2255. <filename>./configure --help</filename> and look for
  2256. the options you need to set.</para></listitem>
  2257. </itemizedlist>
  2258. </para>
  2259. <para>
  2260. Once configuration succeeds, it is always good practice to
  2261. look at the <filename>log.do_configure</filename> file to
  2262. ensure that the appropriate options have been enabled and no
  2263. additional build-time dependencies need to be added to
  2264. <filename>DEPENDS</filename>.
  2265. For example, if the configure script reports that it found
  2266. something not mentioned in <filename>DEPENDS</filename>, or
  2267. that it did not find something that it needed for some
  2268. desired optional functionality, then you would need to add
  2269. those to <filename>DEPENDS</filename>.
  2270. Looking at the log might also reveal items being checked for,
  2271. enabled, or both that you do not want, or items not being found
  2272. that are in <filename>DEPENDS</filename>, in which case
  2273. you would need to look at passing extra options to the
  2274. configure script as needed.
  2275. For reference information on configure options specific to the
  2276. software you are building, you can consult the output of the
  2277. <filename>./configure --help</filename> command within
  2278. <filename>${S}</filename> or consult the software's upstream
  2279. documentation.
  2280. </para>
  2281. </section>
  2282. <section id='new-recipe-using-headers-to-interface-with-devices'>
  2283. <title>Using Headers to Interface with Devices</title>
  2284. <para>
  2285. If your recipe builds an application that needs to
  2286. communicate with some device or needs an API into a custom
  2287. kernel, you will need to provide appropriate header files.
  2288. Under no circumstances should you ever modify the existing
  2289. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>
  2290. file.
  2291. These headers are used to build <filename>libc</filename> and
  2292. must not be compromised with custom or machine-specific
  2293. header information.
  2294. If you customize <filename>libc</filename> through modified
  2295. headers all other applications that use
  2296. <filename>libc</filename> thus become affected.
  2297. <note><title>Warning</title>
  2298. Never copy and customize the <filename>libc</filename>
  2299. header file (i.e.
  2300. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>).
  2301. </note>
  2302. The correct way to interface to a device or custom kernel is
  2303. to use a separate package that provides the additional headers
  2304. for the driver or other unique interfaces.
  2305. When doing so, your application also becomes responsible for
  2306. creating a dependency on that specific provider.
  2307. </para>
  2308. <para>
  2309. Consider the following:
  2310. <itemizedlist>
  2311. <listitem><para>
  2312. Never modify
  2313. <filename>linux-libc-headers.inc</filename>.
  2314. Consider that file to be part of the
  2315. <filename>libc</filename> system, and not something
  2316. you use to access the kernel directly.
  2317. You should access <filename>libc</filename> through
  2318. specific <filename>libc</filename> calls.
  2319. </para></listitem>
  2320. <listitem><para>
  2321. Applications that must talk directly to devices
  2322. should either provide necessary headers themselves,
  2323. or establish a dependency on a special headers package
  2324. that is specific to that driver.
  2325. </para></listitem>
  2326. </itemizedlist>
  2327. </para>
  2328. <para>
  2329. For example, suppose you want to modify an existing header
  2330. that adds I/O control or network support.
  2331. If the modifications are used by a small number programs,
  2332. providing a unique version of a header is easy and has little
  2333. impact.
  2334. When doing so, bear in mind the guidelines in the previous
  2335. list.
  2336. <note>
  2337. If for some reason your changes need to modify the behavior
  2338. of the <filename>libc</filename>, and subsequently all
  2339. other applications on the system, use a
  2340. <filename>.bbappend</filename> to modify the
  2341. <filename>linux-kernel-headers.inc</filename> file.
  2342. However, take care to not make the changes
  2343. machine specific.
  2344. </note>
  2345. </para>
  2346. <para>
  2347. Consider a case where your kernel is older and you need
  2348. an older <filename>libc</filename> ABI.
  2349. The headers installed by your recipe should still be a
  2350. standard mainline kernel, not your own custom one.
  2351. </para>
  2352. <para>
  2353. When you use custom kernel headers you need to get them from
  2354. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>,
  2355. which is the directory with kernel headers that are
  2356. required to build out-of-tree modules.
  2357. Your recipe will also need the following:
  2358. <literallayout class='monospaced'>
  2359. do_configure[depends] += "virtual/kernel:do_shared_workdir"
  2360. </literallayout>
  2361. </para>
  2362. </section>
  2363. <section id='new-recipe-compilation'>
  2364. <title>Compilation</title>
  2365. <para>
  2366. During a build, the <filename>do_compile</filename> task
  2367. happens after source is fetched, unpacked, and configured.
  2368. If the recipe passes through <filename>do_compile</filename>
  2369. successfully, nothing needs to be done.
  2370. </para>
  2371. <para>
  2372. However, if the compile step fails, you need to diagnose the
  2373. failure.
  2374. Here are some common issues that cause failures.
  2375. <note>
  2376. For cases where improper paths are detected for
  2377. configuration files or for when libraries/headers cannot
  2378. be found, be sure you are using the more robust
  2379. <filename>pkg-config</filename>.
  2380. See the note in section
  2381. "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>"
  2382. for additional information.
  2383. </note>
  2384. <itemizedlist>
  2385. <listitem><para><emphasis>Parallel build failures:</emphasis>
  2386. These failures manifest themselves as intermittent
  2387. errors, or errors reporting that a file or directory
  2388. that should be created by some other part of the build
  2389. process could not be found.
  2390. This type of failure can occur even if, upon inspection,
  2391. the file or directory does exist after the build has
  2392. failed, because that part of the build process happened
  2393. in the wrong order.</para>
  2394. <para>To fix the problem, you need to either satisfy
  2395. the missing dependency in the Makefile or whatever
  2396. script produced the Makefile, or (as a workaround)
  2397. set
  2398. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  2399. to an empty string:
  2400. <literallayout class='monospaced'>
  2401. PARALLEL_MAKE = ""
  2402. </literallayout></para>
  2403. <para>
  2404. For information on parallel Makefile issues, see the
  2405. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  2406. section.
  2407. </para></listitem>
  2408. <listitem><para><emphasis>Improper host path usage:</emphasis>
  2409. This failure applies to recipes building for the target
  2410. or <filename>nativesdk</filename> only.
  2411. The failure occurs when the compilation process uses
  2412. improper headers, libraries, or other files from the
  2413. host system when cross-compiling for the target.
  2414. </para>
  2415. <para>To fix the problem, examine the
  2416. <filename>log.do_compile</filename> file to identify
  2417. the host paths being used (e.g.
  2418. <filename>/usr/include</filename>,
  2419. <filename>/usr/lib</filename>, and so forth) and then
  2420. either add configure options, apply a patch, or do both.
  2421. </para></listitem>
  2422. <listitem><para><emphasis>Failure to find required
  2423. libraries/headers:</emphasis>
  2424. If a build-time dependency is missing because it has
  2425. not been declared in
  2426. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  2427. or because the dependency exists but the path used by
  2428. the build process to find the file is incorrect and the
  2429. configure step did not detect it, the compilation
  2430. process could fail.
  2431. For either of these failures, the compilation process
  2432. notes that files could not be found.
  2433. In these cases, you need to go back and add additional
  2434. options to the configure script as well as possibly
  2435. add additional build-time dependencies to
  2436. <filename>DEPENDS</filename>.</para>
  2437. <para>Occasionally, it is necessary to apply a patch
  2438. to the source to ensure the correct paths are used.
  2439. If you need to specify paths to find files staged
  2440. into the sysroot from other recipes, use the variables
  2441. that the OpenEmbedded build system provides
  2442. (e.g.
  2443. <filename>STAGING_BINDIR</filename>,
  2444. <filename>STAGING_INCDIR</filename>,
  2445. <filename>STAGING_DATADIR</filename>, and so forth).
  2446. <!--
  2447. (e.g.
  2448. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>,
  2449. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>,
  2450. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>,
  2451. and so forth).
  2452. -->
  2453. </para></listitem>
  2454. </itemizedlist>
  2455. </para>
  2456. </section>
  2457. <section id='new-recipe-installing'>
  2458. <title>Installing</title>
  2459. <para>
  2460. During <filename>do_install</filename>, the task copies the
  2461. built files along with their hierarchy to locations that
  2462. would mirror their locations on the target device.
  2463. The installation process copies files from the
  2464. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  2465. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>,
  2466. and
  2467. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  2468. directories to the
  2469. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2470. directory to create the structure as it should appear on the
  2471. target system.
  2472. </para>
  2473. <para>
  2474. How your software is built affects what you must do to be
  2475. sure your software is installed correctly.
  2476. The following list describes what you must do for installation
  2477. depending on the type of build system used by the software
  2478. being built:
  2479. <itemizedlist>
  2480. <listitem><para><emphasis>Autotools and CMake:</emphasis>
  2481. If the software your recipe is building uses Autotools
  2482. or CMake, the OpenEmbedded build
  2483. system understands how to install the software.
  2484. Consequently, you do not have to have a
  2485. <filename>do_install</filename> task as part of your
  2486. recipe.
  2487. You just need to make sure the install portion of the
  2488. build completes with no issues.
  2489. However, if you wish to install additional files not
  2490. already being installed by
  2491. <filename>make install</filename>, you should do this
  2492. using a <filename>do_install_append</filename> function
  2493. using the install command as described in
  2494. the "Manual" bulleted item later in this list.
  2495. </para></listitem>
  2496. <listitem><para><emphasis>Other (using
  2497. <filename>make install</filename>):</emphasis>
  2498. You need to define a
  2499. <filename>do_install</filename> function in your
  2500. recipe.
  2501. The function should call
  2502. <filename>oe_runmake install</filename> and will likely
  2503. need to pass in the destination directory as well.
  2504. How you pass that path is dependent on how the
  2505. <filename>Makefile</filename> being run is written
  2506. (e.g. <filename>DESTDIR=${D}</filename>,
  2507. <filename>PREFIX=${D}</filename>,
  2508. <filename>INSTALLROOT=${D}</filename>, and so forth).
  2509. </para>
  2510. <para>For an example recipe using
  2511. <filename>make install</filename>, see the
  2512. "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>"
  2513. section.</para></listitem>
  2514. <listitem><para><emphasis>Manual:</emphasis>
  2515. You need to define a
  2516. <filename>do_install</filename> function in your
  2517. recipe.
  2518. The function must first use
  2519. <filename>install -d</filename> to create the
  2520. directories under
  2521. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
  2522. Once the directories exist, your function can use
  2523. <filename>install</filename> to manually install the
  2524. built software into the directories.</para>
  2525. <para>You can find more information on
  2526. <filename>install</filename> at
  2527. <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>.
  2528. </para></listitem>
  2529. </itemizedlist>
  2530. </para>
  2531. <para>
  2532. For the scenarios that do not use Autotools or
  2533. CMake, you need to track the installation
  2534. and diagnose and fix any issues until everything installs
  2535. correctly.
  2536. You need to look in the default location of
  2537. <filename>${D}</filename>, which is
  2538. <filename>${WORKDIR}/image</filename>, to be sure your
  2539. files have been installed correctly.
  2540. </para>
  2541. <note><title>Notes</title>
  2542. <itemizedlist>
  2543. <listitem><para>
  2544. During the installation process, you might need to
  2545. modify some of the installed files to suit the target
  2546. layout.
  2547. For example, you might need to replace hard-coded paths
  2548. in an initscript with values of variables provided by
  2549. the build system, such as replacing
  2550. <filename>/usr/bin/</filename> with
  2551. <filename>${bindir}</filename>.
  2552. If you do perform such modifications during
  2553. <filename>do_install</filename>, be sure to modify the
  2554. destination file after copying rather than before
  2555. copying.
  2556. Modifying after copying ensures that the build system
  2557. can re-execute <filename>do_install</filename> if
  2558. needed.
  2559. </para></listitem>
  2560. <listitem><para>
  2561. <filename>oe_runmake install</filename>, which can be
  2562. run directly or can be run indirectly by the
  2563. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2564. and
  2565. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2566. classes, runs <filename>make install</filename> in
  2567. parallel.
  2568. Sometimes, a Makefile can have missing dependencies
  2569. between targets that can result in race conditions.
  2570. If you experience intermittent failures during
  2571. <filename>do_install</filename>, you might be able to
  2572. work around them by disabling parallel Makefile
  2573. installs by adding the following to the recipe:
  2574. <literallayout class='monospaced'>
  2575. PARALLEL_MAKEINST = ""
  2576. </literallayout>
  2577. See
  2578. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  2579. for additional information.
  2580. </para></listitem>
  2581. </itemizedlist>
  2582. </note>
  2583. </section>
  2584. <section id='new-recipe-enabling-system-services'>
  2585. <title>Enabling System Services</title>
  2586. <para>
  2587. If you want to install a service, which is a process that
  2588. usually starts on boot and runs in the background, then
  2589. you must include some additional definitions in your recipe.
  2590. </para>
  2591. <para>
  2592. If you are adding services and the service initialization
  2593. script or the service file itself is not installed, you must
  2594. provide for that installation in your recipe using a
  2595. <filename>do_install_append</filename> function.
  2596. If your recipe already has a <filename>do_install</filename>
  2597. function, update the function near its end rather than
  2598. adding an additional <filename>do_install_append</filename>
  2599. function.
  2600. </para>
  2601. <para>
  2602. When you create the installation for your services, you need
  2603. to accomplish what is normally done by
  2604. <filename>make install</filename>.
  2605. In other words, make sure your installation arranges the output
  2606. similar to how it is arranged on the target system.
  2607. </para>
  2608. <para>
  2609. The OpenEmbedded build system provides support for starting
  2610. services two different ways:
  2611. <itemizedlist>
  2612. <listitem><para><emphasis>SysVinit:</emphasis>
  2613. SysVinit is a system and service manager that
  2614. manages the init system used to control the very basic
  2615. functions of your system.
  2616. The init program is the first program
  2617. started by the Linux kernel when the system boots.
  2618. Init then controls the startup, running and shutdown
  2619. of all other programs.</para>
  2620. <para>To enable a service using SysVinit, your recipe
  2621. needs to inherit the
  2622. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink>
  2623. class.
  2624. The class helps facilitate safely installing the
  2625. package on the target.</para>
  2626. <para>You will need to set the
  2627. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>,
  2628. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>,
  2629. and
  2630. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink>
  2631. variables within your recipe.</para></listitem>
  2632. <listitem><para><emphasis>systemd:</emphasis>
  2633. System Management Daemon (systemd) was designed to
  2634. replace SysVinit and to provide
  2635. enhanced management of services.
  2636. For more information on systemd, see the systemd
  2637. homepage at
  2638. <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>.
  2639. </para>
  2640. <para>To enable a service using systemd, your recipe
  2641. needs to inherit the
  2642. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink>
  2643. class.
  2644. See the <filename>systemd.bbclass</filename> file
  2645. located in your
  2646. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  2647. section for more information.
  2648. </para></listitem>
  2649. </itemizedlist>
  2650. </para>
  2651. </section>
  2652. <section id='new-recipe-packaging'>
  2653. <title>Packaging</title>
  2654. <para>
  2655. Successful packaging is a combination of automated processes
  2656. performed by the OpenEmbedded build system and some
  2657. specific steps you need to take.
  2658. The following list describes the process:
  2659. <itemizedlist>
  2660. <listitem><para><emphasis>Splitting Files</emphasis>:
  2661. The <filename>do_package</filename> task splits the
  2662. files produced by the recipe into logical components.
  2663. Even software that produces a single binary might
  2664. still have debug symbols, documentation, and other
  2665. logical components that should be split out.
  2666. The <filename>do_package</filename> task ensures
  2667. that files are split up and packaged correctly.
  2668. </para></listitem>
  2669. <listitem><para><emphasis>Running QA Checks</emphasis>:
  2670. The
  2671. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2672. class adds a step to
  2673. the package generation process so that output quality
  2674. assurance checks are generated by the OpenEmbedded
  2675. build system.
  2676. This step performs a range of checks to be sure the
  2677. build's output is free of common problems that show
  2678. up during runtime.
  2679. For information on these checks, see the
  2680. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2681. class and the
  2682. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>"
  2683. chapter in the Yocto Project Reference Manual.
  2684. </para></listitem>
  2685. <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>:
  2686. After you build your software, you need to be sure
  2687. your packages are correct.
  2688. Examine the
  2689. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  2690. directory and make sure files are where you expect
  2691. them to be.
  2692. If you discover problems, you can set
  2693. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>,
  2694. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2695. <filename>do_install(_append)</filename>, and so forth as
  2696. needed.
  2697. </para></listitem>
  2698. <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>:
  2699. If you need to split an application into several
  2700. packages, see the
  2701. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2702. section for an example.
  2703. </para></listitem>
  2704. <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>:
  2705. For an example showing how to install a
  2706. post-installation script, see the
  2707. "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>"
  2708. section.
  2709. </para></listitem>
  2710. <listitem><para><emphasis>Marking Package Architecture</emphasis>:
  2711. Depending on what your recipe is building and how it
  2712. is configured, it might be important to mark the
  2713. packages produced as being specific to a particular
  2714. machine, or to mark them as not being specific to
  2715. a particular machine or architecture at all.</para>
  2716. <para>By default, packages apply to any machine with the
  2717. same architecture as the target machine.
  2718. When a recipe produces packages that are
  2719. machine-specific (e.g. the
  2720. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  2721. value is passed into the configure script or a patch
  2722. is applied only for a particular machine), you should
  2723. mark them as such by adding the following to the
  2724. recipe:
  2725. <literallayout class='monospaced'>
  2726. PACKAGE_ARCH = "${MACHINE_ARCH}"
  2727. </literallayout></para>
  2728. <para>On the other hand, if the recipe produces packages
  2729. that do not contain anything specific to the target
  2730. machine or architecture at all (e.g. recipes
  2731. that simply package script files or configuration
  2732. files), you should use the
  2733. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  2734. class to do this for you by adding this to your
  2735. recipe:
  2736. <literallayout class='monospaced'>
  2737. inherit allarch
  2738. </literallayout>
  2739. Ensuring that the package architecture is correct is
  2740. not critical while you are doing the first few builds
  2741. of your recipe.
  2742. However, it is important in order
  2743. to ensure that your recipe rebuilds (or does not
  2744. rebuild) appropriately in response to changes in
  2745. configuration, and to ensure that you get the
  2746. appropriate packages installed on the target machine,
  2747. particularly if you run separate builds for more
  2748. than one target machine.
  2749. </para></listitem>
  2750. </itemizedlist>
  2751. </para>
  2752. </section>
  2753. <section id='new-sharing-files-between-recipes'>
  2754. <title>Sharing Files Between Recipes</title>
  2755. <para>
  2756. Recipes often need to use files provided by other recipes on
  2757. the build host.
  2758. For example, an application linking to a common library needs
  2759. access to the library itself and its associated headers.
  2760. The way this access is accomplished is by populating a sysroot
  2761. with files.
  2762. Each recipe has two sysroots in its work directory, one for
  2763. target files
  2764. (<filename>recipe-sysroot</filename>) and one for files that
  2765. are native to the build host
  2766. (<filename>recipe-sysroot-native</filename>).
  2767. <note>
  2768. You could find the term "staging" used within the Yocto
  2769. project regarding files populating sysroots (e.g. the
  2770. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink>
  2771. variable).
  2772. </note>
  2773. </para>
  2774. <para>
  2775. Recipes should never populate the sysroot directly (i.e. write
  2776. files into sysroot).
  2777. Instead, files should be installed into standard locations
  2778. during the
  2779. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2780. task within the
  2781. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2782. directory.
  2783. The reason for this limitation is that almost all files that
  2784. populate the sysroot are cataloged in manifests in order to
  2785. ensure the files can be removed later when a recipe is either
  2786. modified or removed.
  2787. Thus, the sysroot is able to remain free from stale files.
  2788. </para>
  2789. <para>
  2790. A subset of the files installed by the
  2791. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2792. task are used by the
  2793. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  2794. task as defined by the the
  2795. <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink>
  2796. variable to automatically populate the sysroot.
  2797. It is possible to modify the list of directories that populate
  2798. the sysroot.
  2799. The following example shows how you could add the
  2800. <filename>/opt</filename> directory to the list of
  2801. directories within a recipe:
  2802. <literallayout class='monospaced'>
  2803. SYSROOT_DIRS += "/opt"
  2804. </literallayout>
  2805. </para>
  2806. <para>
  2807. For a more complete description of the
  2808. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  2809. task and its associated functions, see the
  2810. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-staging'><filename>staging</filename></ulink>
  2811. class.
  2812. </para>
  2813. </section>
  2814. <section id='metadata-virtual-providers'>
  2815. <title>Using Virtual Providers</title>
  2816. <para>
  2817. Prior to a build, if you know that several different recipes
  2818. provide the same functionality, you can use a virtual provider
  2819. (i.e. <filename>virtual/*</filename>) as a placeholder for the
  2820. actual provider.
  2821. The actual provider is determined at build-time.
  2822. </para>
  2823. <para>
  2824. A common scenario where a virtual provider is used would be
  2825. for the kernel recipe.
  2826. Suppose you have three kernel recipes whose
  2827. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  2828. values map to <filename>kernel-big</filename>,
  2829. <filename>kernel-mid</filename>, and
  2830. <filename>kernel-small</filename>.
  2831. Furthermore, each of these recipes in some way uses a
  2832. <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink>
  2833. statement that essentially identifies itself as being able
  2834. to provide <filename>virtual/kernel</filename>.
  2835. Here is one way through the
  2836. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-kernel'><filename>kernel</filename></ulink>
  2837. class:
  2838. <literallayout class='monospaced'>
  2839. PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }"
  2840. </literallayout>
  2841. Any recipe that inherits the <filename>kernel</filename> class
  2842. is going to utilize a <filename>PROVIDES</filename> statement
  2843. that identifies that recipe as being able to provide the
  2844. <filename>virtual/kernel</filename> item.
  2845. </para>
  2846. <para>
  2847. Now comes the time to actually build an image and you need a
  2848. kernel recipe, but which one?
  2849. You can configure your build to call out the kernel recipe
  2850. you want by using the
  2851. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'><filename>PREFERRED_PROVIDER</filename></ulink>
  2852. variable.
  2853. As an example, consider the
  2854. <ulink url='https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/x86-base.inc'><filename>x86-base.inc</filename></ulink>
  2855. include file, which is a machine
  2856. (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>)
  2857. configuration file.
  2858. This include file is the reason all x86-based machines use the
  2859. <filename>linux-yocto</filename> kernel.
  2860. Here are the relevant lines from the include file:
  2861. <literallayout class='monospaced'>
  2862. PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto"
  2863. PREFERRED_VERSION_linux-yocto ??= "4.15%"
  2864. </literallayout>
  2865. </para>
  2866. <para>
  2867. When you use a virtual provider, you do not have to
  2868. "hard code" a recipe name as a build dependency.
  2869. You can use the
  2870. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2871. variable to state the build is dependent on
  2872. <filename>virtual/kernel</filename> for example:
  2873. <literallayout class='monospaced'>
  2874. DEPENDS = "virtual/kernel"
  2875. </literallayout>
  2876. During the build, the OpenEmbedded build system picks
  2877. the correct recipe needed for the
  2878. <filename>virtual/kernel</filename> dependency based on the
  2879. <filename>PREFERRED_PROVIDER</filename> variable.
  2880. If you want to use the small kernel mentioned at the beginning
  2881. of this section, configure your build as follows:
  2882. <literallayout class='monospaced'>
  2883. PREFERRED_PROVIDER_virtual/kernel ??= "kernel-small"
  2884. </literallayout>
  2885. <note>
  2886. Any recipe that
  2887. <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink>
  2888. a <filename>virtual/*</filename> item that is ultimately
  2889. not selected through
  2890. <filename>PREFERRED_PROVIDER</filename> does not get built.
  2891. Preventing these recipes from building is usually the
  2892. desired behavior since this mechanism's purpose is to
  2893. select between mutually exclusive alternative providers.
  2894. </note>
  2895. </para>
  2896. <para>
  2897. The following lists specific examples of virtual providers:
  2898. <itemizedlist>
  2899. <listitem><para>
  2900. <filename>virtual/kernel</filename>:
  2901. Provides the name of the kernel recipe to use when
  2902. building a kernel image.
  2903. </para></listitem>
  2904. <listitem><para>
  2905. <filename>virtual/bootloader</filename>:
  2906. Provides the name of the bootloader to use when
  2907. building an image.
  2908. </para></listitem>
  2909. <listitem><para>
  2910. <filename>virtual/mesa</filename>:
  2911. Provides <filename>gbm.pc</filename>.
  2912. </para></listitem>
  2913. <listitem><para>
  2914. <filename>virtual/egl</filename>:
  2915. Provides <filename>egl.pc</filename> and possibly
  2916. <filename>wayland-egl.pc</filename>.
  2917. </para></listitem>
  2918. <listitem><para>
  2919. <filename>virtual/libgl</filename>:
  2920. Provides <filename>gl.pc</filename> (i.e. libGL).
  2921. </para></listitem>
  2922. <listitem><para>
  2923. <filename>virtual/libgles1</filename>:
  2924. Provides <filename>glesv1_cm.pc</filename>
  2925. (i.e. libGLESv1_CM).
  2926. </para></listitem>
  2927. <listitem><para>
  2928. <filename>virtual/libgles2</filename>:
  2929. Provides <filename>glesv2.pc</filename>
  2930. (i.e. libGLESv2).
  2931. </para></listitem>
  2932. </itemizedlist>
  2933. </para>
  2934. </section>
  2935. <section id='properly-versioning-pre-release-recipes'>
  2936. <title>Properly Versioning Pre-Release Recipes</title>
  2937. <para>
  2938. Sometimes the name of a recipe can lead to versioning
  2939. problems when the recipe is upgraded to a final release.
  2940. For example, consider the
  2941. <filename>irssi_0.8.16-rc1.bb</filename> recipe file in
  2942. the list of example recipes in the
  2943. "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>"
  2944. section.
  2945. This recipe is at a release candidate stage (i.e.
  2946. "rc1").
  2947. When the recipe is released, the recipe filename becomes
  2948. <filename>irssi_0.8.16.bb</filename>.
  2949. The version change from <filename>0.8.16-rc1</filename>
  2950. to <filename>0.8.16</filename> is seen as a decrease by the
  2951. build system and package managers, so the resulting packages
  2952. will not correctly trigger an upgrade.
  2953. </para>
  2954. <para>
  2955. In order to ensure the versions compare properly, the
  2956. recommended convention is to set
  2957. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2958. within the recipe to
  2959. "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>".
  2960. You can use an additional variable so that you can use the
  2961. current version elsewhere.
  2962. Here is an example:
  2963. <literallayout class='monospaced'>
  2964. REALPV = "0.8.16-rc1"
  2965. PV = "0.8.15+${REALPV}"
  2966. </literallayout>
  2967. </para>
  2968. </section>
  2969. <section id='new-recipe-post-installation-scripts'>
  2970. <title>Post-Installation Scripts</title>
  2971. <para>
  2972. Post-installation scripts run immediately after installing
  2973. a package on the target or during image creation when a
  2974. package is included in an image.
  2975. To add a post-installation script to a package, add a
  2976. <filename>pkg_postinst_</filename><replaceable>PACKAGENAME</replaceable><filename>()</filename> function to
  2977. the recipe file (<filename>.bb</filename>) and replace
  2978. <replaceable>PACKAGENAME</replaceable> with the name of the package
  2979. you want to attach to the <filename>postinst</filename>
  2980. script.
  2981. To apply the post-installation script to the main package
  2982. for the recipe, which is usually what is required, specify
  2983. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2984. in place of <replaceable>PACKAGENAME</replaceable>.
  2985. </para>
  2986. <para>
  2987. A post-installation function has the following structure:
  2988. <literallayout class='monospaced'>
  2989. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  2990. # Commands to carry out
  2991. }
  2992. </literallayout>
  2993. </para>
  2994. <para>
  2995. The script defined in the post-installation function is
  2996. called when the root filesystem is created.
  2997. If the script succeeds, the package is marked as installed.
  2998. If the script fails, the package is marked as unpacked and
  2999. the script is executed when the image boots again.
  3000. <note>
  3001. Any RPM post-installation script that runs on the target
  3002. should return a 0 exit code.
  3003. RPM does not allow non-zero exit codes for these scripts,
  3004. and the RPM package manager will cause the package to fail
  3005. installation on the target.
  3006. </note>
  3007. </para>
  3008. <para>
  3009. Sometimes it is necessary for the execution of a
  3010. post-installation script to be delayed until the first boot.
  3011. For example, the script might need to be executed on the
  3012. device itself.
  3013. To delay script execution until boot time, you must explicitly
  3014. mark post installs to defer to the target.
  3015. You can use <filename>pkg_postinst_ontarget()</filename> or
  3016. call
  3017. <filename>postinst-intercepts defer_to_first_boot</filename>
  3018. from <filename>pkg_postinst()</filename>.
  3019. Any failure of a <filename>pkg_postinst()</filename> script
  3020. (including exit 1) triggers an error during the
  3021. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>
  3022. task.
  3023. </para>
  3024. <para>
  3025. If you have recipes that use
  3026. <filename>pkg_postinst</filename> function
  3027. and they require the use of non-standard native
  3028. tools that have dependencies during rootfs construction, you
  3029. need to use the
  3030. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink>
  3031. variable in your recipe to list these tools.
  3032. If you do not use this variable, the tools might be missing and
  3033. execution of the post-installation script is deferred until
  3034. first boot.
  3035. Deferring the script to first boot is undesirable and for
  3036. read-only rootfs impossible.
  3037. </para>
  3038. <note>
  3039. Equivalent support for pre-install, pre-uninstall, and
  3040. post-uninstall scripts exist by way of
  3041. <filename>pkg_preinst</filename>,
  3042. <filename>pkg_prerm</filename>, and
  3043. <filename>pkg_postrm</filename>, respectively.
  3044. These scrips work in exactly the same way as does
  3045. <filename>pkg_postinst</filename> with the exception
  3046. that they run at different times.
  3047. Also, because of when they run, they are not applicable to
  3048. being run at image creation time like
  3049. <filename>pkg_postinst</filename>.
  3050. </note>
  3051. </section>
  3052. <section id='new-recipe-testing'>
  3053. <title>Testing</title>
  3054. <para>
  3055. The final step for completing your recipe is to be sure that
  3056. the software you built runs correctly.
  3057. To accomplish runtime testing, add the build's output
  3058. packages to your image and test them on the target.
  3059. </para>
  3060. <para>
  3061. For information on how to customize your image by adding
  3062. specific packages, see the
  3063. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  3064. section.
  3065. </para>
  3066. </section>
  3067. <section id='new-recipe-testing-examples'>
  3068. <title>Examples</title>
  3069. <para>
  3070. To help summarize how to write a recipe, this section provides
  3071. some examples given various scenarios:
  3072. <itemizedlist>
  3073. <listitem><para>Recipes that use local files</para></listitem>
  3074. <listitem><para>Using an Autotooled package</para></listitem>
  3075. <listitem><para>Using a Makefile-based package</para></listitem>
  3076. <listitem><para>Splitting an application into multiple packages</para></listitem>
  3077. <listitem><para>Adding binaries to an image</para></listitem>
  3078. </itemizedlist>
  3079. </para>
  3080. <section id='new-recipe-single-c-file-package-hello-world'>
  3081. <title>Single .c File Package (Hello World!)</title>
  3082. <para>
  3083. Building an application from a single file that is stored
  3084. locally (e.g. under <filename>files</filename>) requires
  3085. a recipe that has the file listed in the
  3086. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  3087. variable.
  3088. Additionally, you need to manually write the
  3089. <filename>do_compile</filename> and
  3090. <filename>do_install</filename> tasks.
  3091. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3092. variable defines the directory containing the source code,
  3093. which is set to
  3094. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  3095. in this case - the directory BitBake uses for the build.
  3096. <literallayout class='monospaced'>
  3097. SUMMARY = "Simple helloworld application"
  3098. SECTION = "examples"
  3099. LICENSE = "MIT"
  3100. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  3101. SRC_URI = "file://helloworld.c"
  3102. S = "${WORKDIR}"
  3103. do_compile() {
  3104. ${CC} helloworld.c -o helloworld
  3105. }
  3106. do_install() {
  3107. install -d ${D}${bindir}
  3108. install -m 0755 helloworld ${D}${bindir}
  3109. }
  3110. </literallayout>
  3111. </para>
  3112. <para>
  3113. By default, the <filename>helloworld</filename>,
  3114. <filename>helloworld-dbg</filename>, and
  3115. <filename>helloworld-dev</filename> packages are built.
  3116. For information on how to customize the packaging process,
  3117. see the
  3118. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  3119. section.
  3120. </para>
  3121. </section>
  3122. <section id='new-recipe-autotooled-package'>
  3123. <title>Autotooled Package</title>
  3124. <para>
  3125. Applications that use Autotools such as <filename>autoconf</filename> and
  3126. <filename>automake</filename> require a recipe that has a source archive listed in
  3127. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  3128. also inherit the
  3129. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  3130. class, which contains the definitions of all the steps
  3131. needed to build an Autotool-based application.
  3132. The result of the build is automatically packaged.
  3133. And, if the application uses NLS for localization, packages with local information are
  3134. generated (one package per language).
  3135. Following is one example: (<filename>hello_2.3.bb</filename>)
  3136. <literallayout class='monospaced'>
  3137. SUMMARY = "GNU Helloworld application"
  3138. SECTION = "examples"
  3139. LICENSE = "GPLv2+"
  3140. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  3141. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  3142. inherit autotools gettext
  3143. </literallayout>
  3144. </para>
  3145. <para>
  3146. The variable
  3147. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  3148. is used to track source license changes as described in the
  3149. "<link linkend='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>"
  3150. section in the Yocto Project Overview and Concepts Manual.
  3151. You can quickly create Autotool-based recipes in a manner
  3152. similar to the previous example.
  3153. </para>
  3154. </section>
  3155. <section id='new-recipe-makefile-based-package'>
  3156. <title>Makefile-Based Package</title>
  3157. <para>
  3158. Applications that use GNU <filename>make</filename> also require a recipe that has
  3159. the source archive listed in
  3160. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3161. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  3162. starts the <filename>make</filename> command to compile the application.
  3163. If you need additional <filename>make</filename> options, you should store them in the
  3164. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
  3165. or
  3166. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  3167. variables.
  3168. BitBake passes these options into the GNU <filename>make</filename> invocation.
  3169. Note that a <filename>do_install</filename> task is still required.
  3170. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  3171. </para>
  3172. <para>
  3173. Some applications might require extra parameters to be passed to the compiler.
  3174. For example, the application might need an additional header path.
  3175. You can accomplish this by adding to the
  3176. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  3177. The following example shows this:
  3178. <literallayout class='monospaced'>
  3179. CFLAGS_prepend = "-I ${S}/include "
  3180. </literallayout>
  3181. </para>
  3182. <para>
  3183. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  3184. <literallayout class='monospaced'>
  3185. SUMMARY = "Tools for managing memory technology devices"
  3186. SECTION = "base"
  3187. DEPENDS = "zlib lzo e2fsprogs util-linux"
  3188. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  3189. LICENSE = "GPLv2+"
  3190. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  3191. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  3192. # Use the latest version at 26 Oct, 2013
  3193. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  3194. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  3195. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  3196. "
  3197. PV = "1.5.1+git${SRCPV}"
  3198. S = "${WORKDIR}/git"
  3199. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  3200. do_install () {
  3201. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  3202. }
  3203. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  3204. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  3205. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  3206. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  3207. PARALLEL_MAKE = ""
  3208. BBCLASSEXTEND = "native"
  3209. </literallayout>
  3210. </para>
  3211. </section>
  3212. <section id='splitting-an-application-into-multiple-packages'>
  3213. <title>Splitting an Application into Multiple Packages</title>
  3214. <para>
  3215. You can use the variables
  3216. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  3217. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  3218. to split an application into multiple packages.
  3219. </para>
  3220. <para>
  3221. Following is an example that uses the <filename>libxpm</filename> recipe.
  3222. By default, this recipe generates a single package that contains the library along
  3223. with a few binaries.
  3224. You can modify the recipe to split the binaries into separate packages:
  3225. <literallayout class='monospaced'>
  3226. require xorg-lib-common.inc
  3227. SUMMARY = "Xpm: X Pixmap extension library"
  3228. LICENSE = "BSD"
  3229. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  3230. DEPENDS += "libxext libsm libxt"
  3231. PE = "1"
  3232. XORG_PN = "libXpm"
  3233. PACKAGES =+ "sxpm cxpm"
  3234. FILES_cxpm = "${bindir}/cxpm"
  3235. FILES_sxpm = "${bindir}/sxpm"
  3236. </literallayout>
  3237. </para>
  3238. <para>
  3239. In the previous example, we want to ship the <filename>sxpm</filename>
  3240. and <filename>cxpm</filename> binaries in separate packages.
  3241. Since <filename>bindir</filename> would be packaged into the main
  3242. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  3243. package by default, we prepend the <filename>PACKAGES</filename>
  3244. variable so additional package names are added to the start of list.
  3245. This results in the extra <filename>FILES_*</filename>
  3246. variables then containing information that define which files and
  3247. directories go into which packages.
  3248. Files included by earlier packages are skipped by latter packages.
  3249. Thus, the main <filename>PN</filename> package
  3250. does not include the above listed files.
  3251. </para>
  3252. </section>
  3253. <section id='packaging-externally-produced-binaries'>
  3254. <title>Packaging Externally Produced Binaries</title>
  3255. <para>
  3256. Sometimes, you need to add pre-compiled binaries to an
  3257. image.
  3258. For example, suppose that binaries for proprietary code
  3259. exist, which are created by a particular division of a
  3260. company.
  3261. Your part of the company needs to use those binaries as
  3262. part of an image that you are building using the
  3263. OpenEmbedded build system.
  3264. Since you only have the binaries and not the source code,
  3265. you cannot use a typical recipe that expects to fetch the
  3266. source specified in
  3267. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  3268. and then compile it.
  3269. </para>
  3270. <para>
  3271. One method is to package the binaries and then install them
  3272. as part of the image.
  3273. Generally, it is not a good idea to package binaries
  3274. since, among other things, it can hinder the ability to
  3275. reproduce builds and could lead to compatibility problems
  3276. with ABI in the future.
  3277. However, sometimes you have no choice.
  3278. </para>
  3279. <para>
  3280. The easiest solution is to create a recipe that uses
  3281. the
  3282. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  3283. class and to be sure that you are using default locations
  3284. for build artifacts.
  3285. In most cases, the <filename>bin_package</filename> class
  3286. handles "skipping" the configure and compile steps as well
  3287. as sets things up to grab packages from the appropriate
  3288. area.
  3289. In particular, this class sets <filename>noexec</filename>
  3290. on both the
  3291. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3292. and
  3293. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3294. tasks, sets
  3295. <filename>FILES_${PN}</filename> to "/" so that it picks
  3296. up all files, and sets up a
  3297. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3298. task, which effectively copies all files from
  3299. <filename>${S}</filename> to <filename>${D}</filename>.
  3300. The <filename>bin_package</filename> class works well when
  3301. the files extracted into <filename>${S}</filename> are
  3302. already laid out in the way they should be laid out
  3303. on the target.
  3304. For more information on these variables, see the
  3305. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  3306. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  3307. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  3308. and
  3309. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  3310. variables in the Yocto Project Reference Manual's variable
  3311. glossary.
  3312. <note><title>Notes</title>
  3313. <itemizedlist>
  3314. <listitem><para>
  3315. Using
  3316. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3317. is a good idea even for components distributed
  3318. in binary form, and is often necessary for
  3319. shared libraries.
  3320. For a shared library, listing the library
  3321. dependencies in
  3322. <filename>DEPENDS</filename> makes sure that
  3323. the libraries are available in the staging
  3324. sysroot when other recipes link against the
  3325. library, which might be necessary for
  3326. successful linking.
  3327. </para></listitem>
  3328. <listitem><para>
  3329. Using <filename>DEPENDS</filename> also
  3330. allows runtime dependencies between packages
  3331. to be added automatically.
  3332. See the
  3333. "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  3334. section in the Yocto Project Overview and
  3335. Concepts Manual for more information.
  3336. </para></listitem>
  3337. </itemizedlist>
  3338. </note>
  3339. </para>
  3340. <para>
  3341. If you cannot use the <filename>bin_package</filename>
  3342. class, you need to be sure you are doing the following:
  3343. <itemizedlist>
  3344. <listitem><para>
  3345. Create a recipe where the
  3346. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3347. and
  3348. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3349. tasks do nothing:
  3350. It is usually sufficient to just not define these
  3351. tasks in the recipe, because the default
  3352. implementations do nothing unless a Makefile is
  3353. found in
  3354. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>.
  3355. </para>
  3356. <para>If
  3357. <filename>${S}</filename> might contain a Makefile,
  3358. or if you inherit some class that replaces
  3359. <filename>do_configure</filename> and
  3360. <filename>do_compile</filename> with custom
  3361. versions, then you can use the
  3362. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename>
  3363. flag to turn the tasks into no-ops, as follows:
  3364. <literallayout class='monospaced'>
  3365. do_configure[noexec] = "1"
  3366. do_compile[noexec] = "1"
  3367. </literallayout>
  3368. Unlike
  3369. <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>,
  3370. using the flag preserves the dependency chain from
  3371. the
  3372. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>, <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>,
  3373. and
  3374. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3375. tasks to the
  3376. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3377. task.
  3378. </para></listitem>
  3379. <listitem><para>Make sure your
  3380. <filename>do_install</filename> task installs the
  3381. binaries appropriately.
  3382. </para></listitem>
  3383. <listitem><para>Ensure that you set up
  3384. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3385. (usually
  3386. <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>)
  3387. to point to the files you have installed, which of
  3388. course depends on where you have installed them
  3389. and whether those files are in different locations
  3390. than the defaults.
  3391. </para></listitem>
  3392. </itemizedlist>
  3393. </para>
  3394. </section>
  3395. </section>
  3396. <section id="following-recipe-style-guidelines">
  3397. <title>Following Recipe Style Guidelines</title>
  3398. <para>
  3399. When writing recipes, it is good to conform to existing
  3400. style guidelines.
  3401. The
  3402. <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink>
  3403. wiki page provides rough guidelines for preferred recipe style.
  3404. </para>
  3405. <para>
  3406. It is common for existing recipes to deviate a bit from this
  3407. style.
  3408. However, aiming for at least a consistent style is a good idea.
  3409. Some practices, such as omitting spaces around
  3410. <filename>=</filename> operators in assignments or ordering
  3411. recipe components in an erratic way, are widely seen as poor
  3412. style.
  3413. </para>
  3414. </section>
  3415. <section id='recipe-syntax'>
  3416. <title>Recipe Syntax</title>
  3417. <para>
  3418. Understanding recipe file syntax is important for writing
  3419. recipes.
  3420. The following list overviews the basic items that make up a
  3421. BitBake recipe file.
  3422. For more complete BitBake syntax descriptions, see the
  3423. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  3424. chapter of the BitBake User Manual.
  3425. <itemizedlist>
  3426. <listitem><para>
  3427. <emphasis>Variable Assignments and Manipulations:</emphasis>
  3428. Variable assignments allow a value to be assigned to a
  3429. variable.
  3430. The assignment can be static text or might include
  3431. the contents of other variables.
  3432. In addition to the assignment, appending and prepending
  3433. operations are also supported.</para>
  3434. <para>The following example shows some of the ways
  3435. you can use variables in recipes:
  3436. <literallayout class='monospaced'>
  3437. S = "${WORKDIR}/postfix-${PV}"
  3438. CFLAGS += "-DNO_ASM"
  3439. SRC_URI_append = " file://fixup.patch"
  3440. </literallayout>
  3441. </para></listitem>
  3442. <listitem><para>
  3443. <emphasis>Functions:</emphasis>
  3444. Functions provide a series of actions to be performed.
  3445. You usually use functions to override the default
  3446. implementation of a task function or to complement
  3447. a default function (i.e. append or prepend to an
  3448. existing function).
  3449. Standard functions use <filename>sh</filename> shell
  3450. syntax, although access to OpenEmbedded variables and
  3451. internal methods are also available.</para>
  3452. <para>The following is an example function from the
  3453. <filename>sed</filename> recipe:
  3454. <literallayout class='monospaced'>
  3455. do_install () {
  3456. autotools_do_install
  3457. install -d ${D}${base_bindir}
  3458. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  3459. rmdir ${D}${bindir}/
  3460. }
  3461. </literallayout>
  3462. It is also possible to implement new functions that
  3463. are called between existing tasks as long as the
  3464. new functions are not replacing or complementing the
  3465. default functions.
  3466. You can implement functions in Python
  3467. instead of shell.
  3468. Both of these options are not seen in the majority of
  3469. recipes.
  3470. </para></listitem>
  3471. <listitem><para><emphasis>Keywords:</emphasis>
  3472. BitBake recipes use only a few keywords.
  3473. You use keywords to include common
  3474. functions (<filename>inherit</filename>), load parts
  3475. of a recipe from other files
  3476. (<filename>include</filename> and
  3477. <filename>require</filename>) and export variables
  3478. to the environment (<filename>export</filename>).
  3479. </para>
  3480. <para>The following example shows the use of some of
  3481. these keywords:
  3482. <literallayout class='monospaced'>
  3483. export POSTCONF = "${STAGING_BINDIR}/postconf"
  3484. inherit autoconf
  3485. require otherfile.inc
  3486. </literallayout>
  3487. </para></listitem>
  3488. <listitem><para>
  3489. <emphasis>Comments (#):</emphasis>
  3490. Any lines that begin with the hash character
  3491. (<filename>#</filename>) are treated as comment lines
  3492. and are ignored:
  3493. <literallayout class='monospaced'>
  3494. # This is a comment
  3495. </literallayout>
  3496. </para></listitem>
  3497. </itemizedlist>
  3498. </para>
  3499. <para>
  3500. This next list summarizes the most important and most commonly
  3501. used parts of the recipe syntax.
  3502. For more information on these parts of the syntax, you can
  3503. reference the
  3504. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>
  3505. chapter in the BitBake User Manual.
  3506. <itemizedlist>
  3507. <listitem><para>
  3508. <emphasis>Line Continuation (\):</emphasis>
  3509. Use the backward slash (<filename>\</filename>)
  3510. character to split a statement over multiple lines.
  3511. Place the slash character at the end of the line that
  3512. is to be continued on the next line:
  3513. <literallayout class='monospaced'>
  3514. VAR = "A really long \
  3515. line"
  3516. </literallayout>
  3517. <note>
  3518. You cannot have any characters including spaces
  3519. or tabs after the slash character.
  3520. </note>
  3521. </para></listitem>
  3522. <listitem><para>
  3523. <emphasis>Using Variables (${<replaceable>VARNAME</replaceable>}):</emphasis>
  3524. Use the <filename>${<replaceable>VARNAME</replaceable>}</filename>
  3525. syntax to access the contents of a variable:
  3526. <literallayout class='monospaced'>
  3527. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  3528. </literallayout>
  3529. <note>
  3530. It is important to understand that the value of a
  3531. variable expressed in this form does not get
  3532. substituted automatically.
  3533. The expansion of these expressions happens
  3534. on-demand later (e.g. usually when a function that
  3535. makes reference to the variable executes).
  3536. This behavior ensures that the values are most
  3537. appropriate for the context in which they are
  3538. finally used.
  3539. On the rare occasion that you do need the variable
  3540. expression to be expanded immediately, you can use
  3541. the <filename>:=</filename> operator instead of
  3542. <filename>=</filename> when you make the
  3543. assignment, but this is not generally needed.
  3544. </note>
  3545. </para></listitem>
  3546. <listitem><para>
  3547. <emphasis>Quote All Assignments ("<replaceable>value</replaceable>"):</emphasis>
  3548. Use double quotes around values in all variable
  3549. assignments (e.g.
  3550. <filename>"<replaceable>value</replaceable>"</filename>).
  3551. Following is an example:
  3552. <literallayout class='monospaced'>
  3553. VAR1 = "${OTHERVAR}"
  3554. VAR2 = "The version is ${PV}"
  3555. </literallayout>
  3556. </para></listitem>
  3557. <listitem><para>
  3558. <emphasis>Conditional Assignment (?=):</emphasis>
  3559. Conditional assignment is used to assign a
  3560. value to a variable, but only when the variable is
  3561. currently unset.
  3562. Use the question mark followed by the equal sign
  3563. (<filename>?=</filename>) to make a "soft" assignment
  3564. used for conditional assignment.
  3565. Typically, "soft" assignments are used in the
  3566. <filename>local.conf</filename> file for variables
  3567. that are allowed to come through from the external
  3568. environment.
  3569. </para>
  3570. <para>Here is an example where
  3571. <filename>VAR1</filename> is set to "New value" if
  3572. it is currently empty.
  3573. However, if <filename>VAR1</filename> has already been
  3574. set, it remains unchanged:
  3575. <literallayout class='monospaced'>
  3576. VAR1 ?= "New value"
  3577. </literallayout>
  3578. In this next example, <filename>VAR1</filename>
  3579. is left with the value "Original value":
  3580. <literallayout class='monospaced'>
  3581. VAR1 = "Original value"
  3582. VAR1 ?= "New value"
  3583. </literallayout>
  3584. </para></listitem>
  3585. <listitem><para>
  3586. <emphasis>Appending (+=):</emphasis>
  3587. Use the plus character followed by the equals sign
  3588. (<filename>+=</filename>) to append values to existing
  3589. variables.
  3590. <note>
  3591. This operator adds a space between the existing
  3592. content of the variable and the new content.
  3593. </note></para>
  3594. <para>Here is an example:
  3595. <literallayout class='monospaced'>
  3596. SRC_URI += "file://fix-makefile.patch"
  3597. </literallayout>
  3598. </para></listitem>
  3599. <listitem><para>
  3600. <emphasis>Prepending (=+):</emphasis>
  3601. Use the equals sign followed by the plus character
  3602. (<filename>=+</filename>) to prepend values to existing
  3603. variables.
  3604. <note>
  3605. This operator adds a space between the new content
  3606. and the existing content of the variable.
  3607. </note></para>
  3608. <para>Here is an example:
  3609. <literallayout class='monospaced'>
  3610. VAR =+ "Starts"
  3611. </literallayout>
  3612. </para></listitem>
  3613. <listitem><para>
  3614. <emphasis>Appending (_append):</emphasis>
  3615. Use the <filename>_append</filename> operator to
  3616. append values to existing variables.
  3617. This operator does not add any additional space.
  3618. Also, the operator is applied after all the
  3619. <filename>+=</filename>, and
  3620. <filename>=+</filename> operators have been applied and
  3621. after all <filename>=</filename> assignments have
  3622. occurred.
  3623. </para>
  3624. <para>The following example shows the space being
  3625. explicitly added to the start to ensure the appended
  3626. value is not merged with the existing value:
  3627. <literallayout class='monospaced'>
  3628. SRC_URI_append = " file://fix-makefile.patch"
  3629. </literallayout>
  3630. You can also use the <filename>_append</filename>
  3631. operator with overrides, which results in the actions
  3632. only being performed for the specified target or
  3633. machine:
  3634. <literallayout class='monospaced'>
  3635. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  3636. </literallayout>
  3637. </para></listitem>
  3638. <listitem><para>
  3639. <emphasis>Prepending (_prepend):</emphasis>
  3640. Use the <filename>_prepend</filename> operator to
  3641. prepend values to existing variables.
  3642. This operator does not add any additional space.
  3643. Also, the operator is applied after all the
  3644. <filename>+=</filename>, and
  3645. <filename>=+</filename> operators have been applied and
  3646. after all <filename>=</filename> assignments have
  3647. occurred.
  3648. </para>
  3649. <para>The following example shows the space being
  3650. explicitly added to the end to ensure the prepended
  3651. value is not merged with the existing value:
  3652. <literallayout class='monospaced'>
  3653. CFLAGS_prepend = "-I${S}/myincludes "
  3654. </literallayout>
  3655. You can also use the <filename>_prepend</filename>
  3656. operator with overrides, which results in the actions
  3657. only being performed for the specified target or
  3658. machine:
  3659. <literallayout class='monospaced'>
  3660. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  3661. </literallayout>
  3662. </para></listitem>
  3663. <listitem><para>
  3664. <emphasis>Overrides:</emphasis>
  3665. You can use overrides to set a value conditionally,
  3666. typically based on how the recipe is being built.
  3667. For example, to set the
  3668. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  3669. variable's value to "standard/base" for any target
  3670. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  3671. except for qemuarm where it should be set to
  3672. "standard/arm-versatile-926ejs", you would do the
  3673. following:
  3674. <literallayout class='monospaced'>
  3675. KBRANCH = "standard/base"
  3676. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  3677. </literallayout>
  3678. Overrides are also used to separate alternate values
  3679. of a variable in other situations.
  3680. For example, when setting variables such as
  3681. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3682. and
  3683. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  3684. that are specific to individual packages produced by
  3685. a recipe, you should always use an override that
  3686. specifies the name of the package.
  3687. </para></listitem>
  3688. <listitem><para>
  3689. <emphasis>Indentation:</emphasis>
  3690. Use spaces for indentation rather than than tabs.
  3691. For shell functions, both currently work.
  3692. However, it is a policy decision of the Yocto Project
  3693. to use tabs in shell functions.
  3694. Realize that some layers have a policy to use spaces
  3695. for all indentation.
  3696. </para></listitem>
  3697. <listitem><para>
  3698. <emphasis>Using Python for Complex Operations:</emphasis>
  3699. For more advanced processing, it is possible to use
  3700. Python code during variable assignments (e.g.
  3701. search and replacement on a variable).</para>
  3702. <para>You indicate Python code using the
  3703. <filename>${@<replaceable>python_code</replaceable>}</filename>
  3704. syntax for the variable assignment:
  3705. <literallayout class='monospaced'>
  3706. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  3707. </literallayout>
  3708. </para></listitem>
  3709. <listitem><para>
  3710. <emphasis>Shell Function Syntax:</emphasis>
  3711. Write shell functions as if you were writing a shell
  3712. script when you describe a list of actions to take.
  3713. You should ensure that your script works with a generic
  3714. <filename>sh</filename> and that it does not require
  3715. any <filename>bash</filename> or other shell-specific
  3716. functionality.
  3717. The same considerations apply to various system
  3718. utilities (e.g. <filename>sed</filename>,
  3719. <filename>grep</filename>, <filename>awk</filename>,
  3720. and so forth) that you might wish to use.
  3721. If in doubt, you should check with multiple
  3722. implementations - including those from BusyBox.
  3723. </para></listitem>
  3724. </itemizedlist>
  3725. </para>
  3726. </section>
  3727. </section>
  3728. <section id="platdev-newmachine">
  3729. <title>Adding a New Machine</title>
  3730. <para>
  3731. Adding a new machine to the Yocto Project is a straightforward
  3732. process.
  3733. This section describes how to add machines that are similar
  3734. to those that the Yocto Project already supports.
  3735. <note>
  3736. Although well within the capabilities of the Yocto Project,
  3737. adding a totally new architecture might require
  3738. changes to <filename>gcc/glibc</filename> and to the site
  3739. information, which is beyond the scope of this manual.
  3740. </note>
  3741. </para>
  3742. <para>
  3743. For a complete example that shows how to add a new machine,
  3744. see the
  3745. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'>Creating a New BSP Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  3746. section in the Yocto Project Board Support Package (BSP)
  3747. Developer's Guide.
  3748. </para>
  3749. <section id="platdev-newmachine-conffile">
  3750. <title>Adding the Machine Configuration File</title>
  3751. <para>
  3752. To add a new machine, you need to add a new machine
  3753. configuration file to the layer's
  3754. <filename>conf/machine</filename> directory.
  3755. This configuration file provides details about the device
  3756. you are adding.
  3757. </para>
  3758. <para>
  3759. The OpenEmbedded build system uses the root name of the
  3760. machine configuration file to reference the new machine.
  3761. For example, given a machine configuration file named
  3762. <filename>crownbay.conf</filename>, the build system
  3763. recognizes the machine as "crownbay".
  3764. </para>
  3765. <para>
  3766. The most important variables you must set in your machine
  3767. configuration file or include from a lower-level configuration
  3768. file are as follows:
  3769. <itemizedlist>
  3770. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  3771. (e.g. "arm")</para></listitem>
  3772. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  3773. </para></listitem>
  3774. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  3775. (e.g. "apm screen wifi")</para></listitem>
  3776. </itemizedlist>
  3777. </para>
  3778. <para>
  3779. You might also need these variables:
  3780. <itemizedlist>
  3781. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  3782. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  3783. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  3784. (e.g. "zImage")</para></listitem>
  3785. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  3786. (e.g. "tar.gz jffs2")</para></listitem>
  3787. </itemizedlist>
  3788. </para>
  3789. <para>
  3790. You can find full details on these variables in the reference
  3791. section.
  3792. You can leverage existing machine <filename>.conf</filename>
  3793. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  3794. </para>
  3795. </section>
  3796. <section id="platdev-newmachine-kernel">
  3797. <title>Adding a Kernel for the Machine</title>
  3798. <para>
  3799. The OpenEmbedded build system needs to be able to build a kernel
  3800. for the machine.
  3801. You need to either create a new kernel recipe for this machine,
  3802. or extend an existing kernel recipe.
  3803. You can find several kernel recipe examples in the
  3804. Source Directory at
  3805. <filename>meta/recipes-kernel/linux</filename>
  3806. that you can use as references.
  3807. </para>
  3808. <para>
  3809. If you are creating a new kernel recipe, normal recipe-writing
  3810. rules apply for setting up a
  3811. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3812. Thus, you need to specify any necessary patches and set
  3813. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3814. to point at the source code.
  3815. You need to create a <filename>do_configure</filename> task that
  3816. configures the unpacked kernel with a
  3817. <filename>defconfig</filename> file.
  3818. You can do this by using a <filename>make defconfig</filename>
  3819. command or, more commonly, by copying in a suitable
  3820. <filename>defconfig</filename> file and then running
  3821. <filename>make oldconfig</filename>.
  3822. By making use of <filename>inherit kernel</filename> and
  3823. potentially some of the <filename>linux-*.inc</filename> files,
  3824. most other functionality is centralized and the defaults of the
  3825. class normally work well.
  3826. </para>
  3827. <para>
  3828. If you are extending an existing kernel recipe, it is usually
  3829. a matter of adding a suitable <filename>defconfig</filename>
  3830. file.
  3831. The file needs to be added into a location similar to
  3832. <filename>defconfig</filename> files used for other machines
  3833. in a given kernel recipe.
  3834. A possible way to do this is by listing the file in the
  3835. <filename>SRC_URI</filename> and adding the machine to the
  3836. expression in
  3837. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  3838. <literallayout class='monospaced'>
  3839. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  3840. </literallayout>
  3841. For more information on <filename>defconfig</filename> files,
  3842. see the
  3843. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  3844. section in the Yocto Project Linux Kernel Development Manual.
  3845. </para>
  3846. </section>
  3847. <section id="platdev-newmachine-formfactor">
  3848. <title>Adding a Formfactor Configuration File</title>
  3849. <para>
  3850. A formfactor configuration file provides information about the
  3851. target hardware for which the image is being built and information that
  3852. the build system cannot obtain from other sources such as the kernel.
  3853. Some examples of information contained in a formfactor configuration file include
  3854. framebuffer orientation, whether or not the system has a keyboard,
  3855. the positioning of the keyboard in relation to the screen, and
  3856. the screen resolution.
  3857. </para>
  3858. <para>
  3859. The build system uses reasonable defaults in most cases.
  3860. However, if customization is
  3861. necessary, you need to create a <filename>machconfig</filename> file
  3862. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  3863. directory.
  3864. This directory contains directories for specific machines such as
  3865. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  3866. For information about the settings available and the defaults, see the
  3867. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  3868. same area.
  3869. </para>
  3870. <para>
  3871. Following is an example for "qemuarm" machine:
  3872. <literallayout class='monospaced'>
  3873. HAVE_TOUCHSCREEN=1
  3874. HAVE_KEYBOARD=1
  3875. DISPLAY_CAN_ROTATE=0
  3876. DISPLAY_ORIENTATION=0
  3877. #DISPLAY_WIDTH_PIXELS=640
  3878. #DISPLAY_HEIGHT_PIXELS=480
  3879. #DISPLAY_BPP=16
  3880. DISPLAY_DPI=150
  3881. DISPLAY_SUBPIXEL_ORDER=vrgb
  3882. </literallayout>
  3883. </para>
  3884. </section>
  3885. </section>
  3886. <section id='gs-upgrading-recipes'>
  3887. <title>Upgrading Recipes</title>
  3888. <para>
  3889. Over time, upstream developers publish new versions for software
  3890. built by layer recipes.
  3891. It is recommended to keep recipes up-to-date with upstream
  3892. version releases.
  3893. You can use the Automated Upgrade Helper (AUH) to set up
  3894. automatic version upgrades.
  3895. Alternatively, you can use <filename>devtool upgrade</filename>
  3896. to set up semi-automatic version upgrades.
  3897. Finally, you can even manually upgrade a recipe by editing the
  3898. recipe itself.
  3899. </para>
  3900. <section id='gs-using-the-auto-upgrade-helper'>
  3901. <title>Using the Auto Upgrade Helper (AUH)</title>
  3902. <para>
  3903. The AUH utility works in conjunction with the
  3904. OpenEmbedded build system in order to automatically generate
  3905. upgrades for recipes based on new versions being
  3906. published upstream.
  3907. Use AUH when you want to create a service that performs the
  3908. upgrades automatically and optionally sends you an email with
  3909. the results.
  3910. </para>
  3911. <para>
  3912. AUH allows you to update several recipes with a single use.
  3913. You can also optionally perform build and integration tests
  3914. using images with the results saved to your hard drive and
  3915. emails of results optionally sent to recipe maintainers.
  3916. Finally, AUH creates Git commits with appropriate commit
  3917. messages in the layer's tree for the changes made to recipes.
  3918. <note>
  3919. Conditions do exist when you should not use AUH to upgrade
  3920. recipes and you should instead use either
  3921. <filename>devtool upgrade</filename> or upgrade your
  3922. recipes manually:
  3923. <itemizedlist>
  3924. <listitem><para>
  3925. When AUH cannot complete the upgrade sequence.
  3926. This situation usually results because custom
  3927. patches carried by the recipe cannot be
  3928. automatically rebased to the new version.
  3929. In this case, <filename>devtool upgrade</filename>
  3930. allows you to manually resolve conflicts.
  3931. </para></listitem>
  3932. <listitem><para>
  3933. When for any reason you want fuller control over
  3934. the upgrade process.
  3935. For example, when you want special arrangements
  3936. for testing.
  3937. </para></listitem>
  3938. </itemizedlist>
  3939. </note>
  3940. </para>
  3941. <para>
  3942. The following steps describe how to set up the AUH utility:
  3943. <orderedlist>
  3944. <listitem><para>
  3945. <emphasis>Be Sure the Development Host is Set Up:</emphasis>
  3946. You need to be sure that your development host is
  3947. set up to use the Yocto Project.
  3948. For information on how to set up your host, see the
  3949. "<link linkend='dev-preparing-the-build-host'>Preparing the Build Host</link>"
  3950. section.
  3951. </para></listitem>
  3952. <listitem><para>
  3953. <emphasis>Make Sure Git is Configured:</emphasis>
  3954. The AUH utility requires Git to be configured because
  3955. AUH uses Git to save upgrades.
  3956. Thus, you must have Git user and email configured.
  3957. The following command shows your configurations:
  3958. <literallayout class='monospaced'>
  3959. $ git config --list
  3960. </literallayout>
  3961. If you do not have the user and email configured, you
  3962. can use the following commands to do so:
  3963. <literallayout class='monospaced'>
  3964. $ git config --global user.name <replaceable>some_name</replaceable>
  3965. $ git config --global user.email <replaceable>username</replaceable>@<replaceable>domain</replaceable>.com
  3966. </literallayout>
  3967. </para></listitem>
  3968. <listitem><para>
  3969. <emphasis>Clone the AUH Repository:</emphasis>
  3970. To use AUH, you must clone the repository onto your
  3971. development host.
  3972. The following command uses Git to create a local
  3973. copy of the repository on your system:
  3974. <literallayout class='monospaced'>
  3975. $ git clone git://git.yoctoproject.org/auto-upgrade-helper
  3976. Cloning into 'auto-upgrade-helper'...
  3977. remote: Counting objects: 768, done.
  3978. remote: Compressing objects: 100% (300/300), done.
  3979. remote: Total 768 (delta 499), reused 703 (delta 434)
  3980. Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done.
  3981. Resolving deltas: 100% (499/499), done.
  3982. Checking connectivity... done.
  3983. </literallayout>
  3984. AUH is not part of the
  3985. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core (OE-Core)</ulink>
  3986. or
  3987. <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink>
  3988. repositories.
  3989. </para></listitem>
  3990. <listitem><para>
  3991. <emphasis>Create a Dedicated Build Directory:</emphasis>
  3992. Run the
  3993. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
  3994. script to create a fresh build directory that you
  3995. use exclusively for running the AUH utility:
  3996. <literallayout class='monospaced'>
  3997. $ cd ~/poky
  3998. $ source oe-init-build-env <replaceable>your_AUH_build_directory</replaceable>
  3999. </literallayout>
  4000. Re-using an existing build directory and its
  4001. configurations is not recommended as existing settings
  4002. could cause AUH to fail or behave undesirably.
  4003. </para></listitem>
  4004. <listitem><para>
  4005. <emphasis>Make Configurations in Your Local Configuration File:</emphasis>
  4006. Several settings need to exist in the
  4007. <filename>local.conf</filename> file in the build
  4008. directory you just created for AUH.
  4009. Make these following configurations:
  4010. <itemizedlist>
  4011. <listitem><para>
  4012. Enable "distrodata" as follows:
  4013. <literallayout class='monospaced'>
  4014. INHERIT =+ "distrodata"
  4015. </literallayout>
  4016. </para></listitem>
  4017. <listitem><para>
  4018. If you want to enable
  4019. <ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-build-output-quality'>Build History</ulink>,
  4020. which is optional, you need the following
  4021. lines in the
  4022. <filename>conf/local.conf</filename> file:
  4023. <literallayout class='monospaced'>
  4024. INHERIT =+ "buildhistory"
  4025. BUILDHISTORY_COMMIT = "1"
  4026. </literallayout>
  4027. With this configuration and a successful
  4028. upgrade, a build history "diff" file appears in
  4029. the
  4030. <filename>upgrade-helper/work/recipe/buildhistory-diff.txt</filename>
  4031. file found in your build directory.
  4032. </para></listitem>
  4033. <listitem><para>
  4034. If you want to enable testing through the
  4035. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  4036. class, which is optional, you need to have the
  4037. following set in your
  4038. <filename>conf/local.conf</filename> file:
  4039. <literallayout class='monospaced'>
  4040. INHERIT += "testimage"
  4041. </literallayout>
  4042. <note>
  4043. If your distro does not enable by default
  4044. ptest, which Poky does, you need the
  4045. following in your
  4046. <filename>local.conf</filename> file:
  4047. <literallayout class='monospaced'>
  4048. DISTRO_FEATURES_append = " ptest"
  4049. </literallayout>
  4050. </note>
  4051. </para></listitem>
  4052. </itemizedlist>
  4053. </para></listitem>
  4054. <listitem><para>
  4055. <emphasis>Optionally Start a vncserver:</emphasis>
  4056. If you are running in a server without an X11 session,
  4057. you need to start a vncserver:
  4058. <literallayout class='monospaced'>
  4059. $ vncserver :1
  4060. $ export DISPLAY=:1
  4061. </literallayout>
  4062. </para></listitem>
  4063. <listitem><para>
  4064. <emphasis>Create and Edit an AUH Configuration File:</emphasis>
  4065. You need to have the
  4066. <filename>upgrade-helper/upgrade-helper.conf</filename>
  4067. configuration file in your build directory.
  4068. You can find a sample configuration file in the
  4069. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/'>AUH source repository</ulink>.
  4070. </para>
  4071. <para>Read through the sample file and make
  4072. configurations as needed.
  4073. For example, if you enabled build history in your
  4074. <filename>local.conf</filename> as described earlier,
  4075. you must enable it in
  4076. <filename>upgrade-helper.conf</filename>.</para>
  4077. <para>Also, if you are using the default
  4078. <filename>maintainers.inc</filename> file supplied
  4079. with Poky and located in
  4080. <filename>meta-yocto</filename> and you do not set a
  4081. "maintainers_whitelist" or "global_maintainer_override"
  4082. in the <filename>upgrade-helper.conf</filename>
  4083. configuration, and you specify "-e all" on the
  4084. AUH command-line, the utility automatically sends out
  4085. emails to all the default maintainers.
  4086. Please avoid this.
  4087. </para></listitem>
  4088. </orderedlist>
  4089. </para>
  4090. <para>
  4091. This next set of examples describes how to use the AUH:
  4092. <itemizedlist>
  4093. <listitem><para>
  4094. <emphasis>Upgrading a Specific Recipe:</emphasis>
  4095. To upgrade a specific recipe, use the following
  4096. form:
  4097. <literallayout class='monospaced'>
  4098. $ upgrade-helper.py <replaceable>recipe_name</replaceable>
  4099. </literallayout>
  4100. For example, this command upgrades the
  4101. <filename>xmodmap</filename> recipe:
  4102. <literallayout class='monospaced'>
  4103. $ upgrade-helper.py xmodmap
  4104. </literallayout>
  4105. </para></listitem>
  4106. <listitem><para>
  4107. <emphasis>Upgrading a Specific Recipe to a Particular Version:</emphasis>
  4108. To upgrade a specific recipe to a particular version,
  4109. use the following form:
  4110. <literallayout class='monospaced'>
  4111. $ upgrade-helper.py <replaceable>recipe_name</replaceable> -t <replaceable>version</replaceable>
  4112. </literallayout>
  4113. For example, this command upgrades the
  4114. <filename>xmodmap</filename> recipe to version
  4115. 1.2.3:
  4116. <literallayout class='monospaced'>
  4117. $ upgrade-helper.py xmodmap -t 1.2.3
  4118. </literallayout>
  4119. </para></listitem>
  4120. <listitem><para>
  4121. <emphasis>Upgrading all Recipes to the Latest Versions and Suppressing Email Notifications:</emphasis>
  4122. To upgrade all recipes to their most recent versions
  4123. and suppress the email notifications, use the following
  4124. command:
  4125. <literallayout class='monospaced'>
  4126. $ upgrade-helper.py all
  4127. </literallayout>
  4128. </para></listitem>
  4129. <listitem><para>
  4130. <emphasis>Upgrading all Recipes to the Latest Versions and Send Email Notifications:</emphasis>
  4131. To upgrade all recipes to their most recent versions
  4132. and send email messages to maintainers for each
  4133. attempted recipe as well as a status email, use the
  4134. following command:
  4135. <literallayout class='monospaced'>
  4136. $ upgrade-helper.py -e all
  4137. </literallayout>
  4138. </para></listitem>
  4139. </itemizedlist>
  4140. </para>
  4141. <para>
  4142. Once you have run the AUH utility, you can find the results
  4143. in the AUH build directory:
  4144. <literallayout class='monospaced'>
  4145. ${BUILDDIR}/upgrade-helper/<replaceable>timestamp</replaceable>
  4146. </literallayout>
  4147. The AUH utility also creates recipe update commits from
  4148. successful upgrade attempts in the layer tree.
  4149. </para>
  4150. <para>
  4151. You can easily set up to run the AUH utility on a regular
  4152. basis by using a cron job.
  4153. See the
  4154. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/weeklyjob.sh'><filename>weeklyjob.sh</filename></ulink>
  4155. file distributed with the utility for an example.
  4156. </para>
  4157. </section>
  4158. <section id='gs-using-devtool-upgrade'>
  4159. <title>Using <filename>devtool upgrade</filename></title>
  4160. <para>
  4161. As mentioned earlier, an alternative method for upgrading
  4162. recipes to newer versions is to use
  4163. <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool upgrade</filename></ulink>.
  4164. You can read about <filename>devtool upgrade</filename> in
  4165. general in the
  4166. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-devtool-use-devtool-upgrade-to-create-a-version-of-the-recipe-that-supports-a-newer-version-of-the-software'>Use <filename>devtool upgrade</filename> to Create a Version of the Recipe that Supports a Newer Version of the Software</ulink>"
  4167. section in the Yocto Project Application Development and the
  4168. Extensible Software Development Kit (eSDK) Manual.
  4169. </para>
  4170. <para>
  4171. To see all the command-line options available with
  4172. <filename>devtool upgrade</filename>, use the following help
  4173. command:
  4174. <literallayout class='monospaced'>
  4175. $ devtool upgrade -h
  4176. </literallayout>
  4177. </para>
  4178. <para>
  4179. If you want to find out what version a recipe is currently at
  4180. upstream without any attempt to upgrade your local version of
  4181. the recipe, you can use the following command:
  4182. <literallayout class='monospaced'>
  4183. $ devtool latest-version <replaceable>recipe_name</replaceable>
  4184. </literallayout>
  4185. </para>
  4186. <para>
  4187. As mentioned in the previous section describing AUH,
  4188. <filename>devtool upgrade</filename> works in a
  4189. less-automated manner than AUH.
  4190. Specifically, <filename>devtool upgrade</filename> only
  4191. works on a single recipe that you name on the command line,
  4192. cannot perform build and integration testing using images,
  4193. and does not automatically generate commits for changes in
  4194. the source tree.
  4195. Despite all these "limitations",
  4196. <filename>devtool upgrade</filename> updates the recipe file
  4197. to the new upstream version and attempts to rebase custom
  4198. patches contained by the recipe as needed.
  4199. <note>
  4200. AUH uses much of <filename>devtool upgrade</filename>
  4201. behind the scenes making AUH somewhat of a "wrapper"
  4202. application for <filename>devtool upgrade</filename>.
  4203. </note>
  4204. </para>
  4205. <para>
  4206. A typical scenario involves having used Git to clone an
  4207. upstream repository that you use during build operations.
  4208. Because you are (or have) built the recipe in the past, the
  4209. layer is likely added to your configuration already.
  4210. If for some reason, the layer is not added, you could add
  4211. it easily using the
  4212. <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'><filename>bitbake-layers</filename></ulink>
  4213. script.
  4214. For example, suppose you use the <filename>nano.bb</filename>
  4215. recipe from the <filename>meta-oe</filename> layer in the
  4216. <filename>meta-openembedded</filename> repository.
  4217. For this example, assume that the layer has been cloned into
  4218. following area:
  4219. <literallayout class='monospaced'>
  4220. /home/scottrif/meta-openembedded
  4221. </literallayout>
  4222. The following command from your
  4223. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  4224. adds the layer to your build configuration (i.e.
  4225. <filename>${BUILDDIR}/conf/bblayers.conf</filename>):
  4226. <literallayout class='monospaced'>
  4227. $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe
  4228. NOTE: Starting bitbake server...
  4229. Parsing recipes: 100% |##########################################| Time: 0:00:55
  4230. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  4231. Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00
  4232. Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00
  4233. Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00
  4234. Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00
  4235. </literallayout>
  4236. For this example, assume that the <filename>nano.bb</filename>
  4237. recipe that is upstream has a 2.9.3 version number.
  4238. However, the version in the local repository is 2.7.4.
  4239. The following command from your build directory automatically
  4240. upgrades the recipe for you:
  4241. <note>
  4242. Using the <filename>-V</filename> option is not necessary.
  4243. Omitting the version number causes
  4244. <filename>devtool upgrade</filename> to upgrade the recipe
  4245. to the most recent version.
  4246. </note>
  4247. <literallayout class='monospaced'>
  4248. $ devtool upgrade nano -V 2.9.3
  4249. NOTE: Starting bitbake server...
  4250. NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace
  4251. Parsing recipes: 100% |##########################################| Time: 0:00:46
  4252. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  4253. NOTE: Extracting current version source...
  4254. NOTE: Resolving any missing task queue dependencies
  4255. .
  4256. .
  4257. .
  4258. NOTE: Executing SetScene Tasks
  4259. NOTE: Executing RunQueue Tasks
  4260. NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded.
  4261. Adding changed files: 100% |#####################################| Time: 0:00:00
  4262. NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano
  4263. NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb
  4264. </literallayout>
  4265. Continuing with this example, you can use
  4266. <filename>devtool build</filename> to build the newly upgraded
  4267. recipe:
  4268. <literallayout class='monospaced'>
  4269. $ devtool build nano
  4270. NOTE: Starting bitbake server...
  4271. Loading cache: 100% |################################################################################################| Time: 0:00:01
  4272. Loaded 2040 entries from dependency cache.
  4273. Parsing recipes: 100% |##############################################################################################| Time: 0:00:00
  4274. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  4275. NOTE: Resolving any missing task queue dependencies
  4276. .
  4277. .
  4278. .
  4279. NOTE: Executing SetScene Tasks
  4280. NOTE: Executing RunQueue Tasks
  4281. NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano
  4282. NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded.
  4283. </literallayout>
  4284. Within the <filename>devtool upgrade</filename> workflow,
  4285. opportunity exists to deploy and test your rebuilt software.
  4286. For this example, however, running
  4287. <filename>devtool finish</filename> cleans up the workspace
  4288. once the source in your workspace is clean.
  4289. This usually means using Git to stage and submit commits
  4290. for the changes generated by the upgrade process.
  4291. </para>
  4292. <para>
  4293. Once the tree is clean, you can clean things up in this
  4294. example with the following command from the
  4295. <filename>${BUILDDIR}/workspace/sources/nano</filename>
  4296. directory:
  4297. <literallayout class='monospaced'>
  4298. $ devtool finish nano meta-oe
  4299. NOTE: Starting bitbake server...
  4300. Loading cache: 100% |################################################################################################| Time: 0:00:00
  4301. Loaded 2040 entries from dependency cache.
  4302. Parsing recipes: 100% |##############################################################################################| Time: 0:00:01
  4303. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  4304. NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch
  4305. NOTE: Updating recipe nano_2.9.3.bb
  4306. NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb
  4307. NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano
  4308. NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually
  4309. </literallayout>
  4310. Using the <filename>devtool finish</filename> command cleans
  4311. up the workspace and creates a patch file based on your
  4312. commits.
  4313. The tool puts all patch files back into the source directory
  4314. in a sub-directory named <filename>nano</filename> in this
  4315. case.
  4316. </para>
  4317. </section>
  4318. <section id='dev-manually-upgrading-a-recipe'>
  4319. <title>Manually Upgrading a Recipe</title>
  4320. <para>
  4321. If for some reason you choose not to upgrade recipes using the
  4322. <link linkend='gs-using-the-auto-upgrade-helper'>Auto Upgrade Helper (AUH)</link>
  4323. or by using
  4324. <link linkend='gs-using-devtool-upgrade'><filename>devtool upgrade</filename></link>,
  4325. you can manually edit the recipe files to upgrade the versions.
  4326. <note><title>Caution</title>
  4327. Manually updating multiple recipes scales poorly and
  4328. involves many steps.
  4329. The recommendation to upgrade recipe versions is through
  4330. AUH or <filename>devtool upgrade</filename>, both of which
  4331. automate some steps and provide guidance for others needed
  4332. for the manual process.
  4333. </note>
  4334. </para>
  4335. <para>
  4336. To manually upgrade recipe versions, follow these general steps:
  4337. <orderedlist>
  4338. <listitem><para>
  4339. <emphasis>Change the Version:</emphasis>
  4340. Rename the recipe such that the version (i.e. the
  4341. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  4342. part of the recipe name) changes appropriately.
  4343. If the version is not part of the recipe name, change
  4344. the value as it is set for <filename>PV</filename>
  4345. within the recipe itself.
  4346. </para></listitem>
  4347. <listitem><para>
  4348. <emphasis>Update <filename>SRCREV</filename> if Needed:</emphasis>
  4349. If the source code your recipe builds is fetched from
  4350. Git or some other version control system, update
  4351. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  4352. to point to the commit hash that matches the new
  4353. version.
  4354. </para></listitem>
  4355. <listitem><para>
  4356. <emphasis>Build the Software:</emphasis>
  4357. Try to build the recipe using BitBake.
  4358. Typical build failures include the following:
  4359. <itemizedlist>
  4360. <listitem><para>
  4361. License statements were updated for the new
  4362. version.
  4363. For this case, you need to review any changes
  4364. to the license and update the values of
  4365. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  4366. and
  4367. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  4368. as needed.
  4369. <note>
  4370. License changes are often inconsequential.
  4371. For example, the license text's copyright
  4372. year might have changed.
  4373. </note>
  4374. </para></listitem>
  4375. <listitem><para>
  4376. Custom patches carried by the older version of
  4377. the recipe might fail to apply to the new
  4378. version.
  4379. For these cases, you need to review the
  4380. failures.
  4381. Patches might not be necessary for the new
  4382. version of the software if the upgraded version
  4383. has fixed those issues.
  4384. If a patch is necessary and failing, you need
  4385. to rebase it into the new version.
  4386. </para></listitem>
  4387. </itemizedlist>
  4388. </para></listitem>
  4389. <listitem><para>
  4390. <emphasis>Optionally Attempt to Build for Several Architectures:</emphasis>
  4391. Once you successfully build the new software for a
  4392. given architecture, you could test the build for
  4393. other architectures by changing the
  4394. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4395. variable and rebuilding the software.
  4396. This optional step is especially important if the
  4397. recipe is to be released publicly.
  4398. </para></listitem>
  4399. <listitem><para>
  4400. <emphasis>Check the Upstream Change Log or Release Notes:</emphasis>
  4401. Checking both these reveals if new features exist that
  4402. could break backwards-compatibility.
  4403. If so, you need to take steps to mitigate or eliminate
  4404. that situation.
  4405. </para></listitem>
  4406. <listitem><para>
  4407. <emphasis>Optionally Create a Bootable Image and Test:</emphasis>
  4408. If you want, you can test the new software by booting
  4409. it onto actual hardware.
  4410. </para></listitem>
  4411. <listitem><para>
  4412. <emphasis>Create a Commit with the Change in the Layer Repository:</emphasis>
  4413. After all builds work and any testing is successful,
  4414. you can create commits for any changes in the layer
  4415. holding your upgraded recipe.
  4416. </para></listitem>
  4417. </orderedlist>
  4418. </para>
  4419. </section>
  4420. </section>
  4421. <section id='finding-the-temporary-source-code'>
  4422. <title>Finding Temporary Source Code</title>
  4423. <para>
  4424. You might find it helpful during development to modify the
  4425. temporary source code used by recipes to build packages.
  4426. For example, suppose you are developing a patch and you need to
  4427. experiment a bit to figure out your solution.
  4428. After you have initially built the package, you can iteratively
  4429. tweak the source code, which is located in the
  4430. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  4431. and then you can force a re-compile and quickly test your altered
  4432. code.
  4433. Once you settle on a solution, you can then preserve your changes
  4434. in the form of patches.
  4435. </para>
  4436. <para>
  4437. During a build, the unpacked temporary source code used by recipes
  4438. to build packages is available in the Build Directory as
  4439. defined by the
  4440. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  4441. variable.
  4442. Below is the default value for the <filename>S</filename> variable
  4443. as defined in the
  4444. <filename>meta/conf/bitbake.conf</filename> configuration file
  4445. in the
  4446. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  4447. <literallayout class='monospaced'>
  4448. S = "${WORKDIR}/${BP}"
  4449. </literallayout>
  4450. You should be aware that many recipes override the
  4451. <filename>S</filename> variable.
  4452. For example, recipes that fetch their source from Git usually set
  4453. <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
  4454. <note>
  4455. The
  4456. <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  4457. represents the base recipe name, which consists of the name
  4458. and version:
  4459. <literallayout class='monospaced'>
  4460. BP = "${BPN}-${PV}"
  4461. </literallayout>
  4462. </note>
  4463. </para>
  4464. <para>
  4465. The path to the work directory for the recipe
  4466. (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
  4467. is defined as follows:
  4468. <literallayout class='monospaced'>
  4469. ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
  4470. </literallayout>
  4471. The actual directory depends on several things:
  4472. <itemizedlist>
  4473. <listitem><para>
  4474. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  4475. The top-level build output directory.
  4476. </para></listitem>
  4477. <listitem><para>
  4478. <ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
  4479. The target system identifier.
  4480. </para></listitem>
  4481. <listitem><para>
  4482. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  4483. The recipe name.
  4484. </para></listitem>
  4485. <listitem><para>
  4486. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
  4487. The epoch - (if
  4488. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
  4489. is not specified, which is usually the case for most
  4490. recipes, then <filename>EXTENDPE</filename> is blank).
  4491. </para></listitem>
  4492. <listitem><para>
  4493. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  4494. The recipe version.
  4495. </para></listitem>
  4496. <listitem><para>
  4497. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  4498. The recipe revision.
  4499. </para></listitem>
  4500. </itemizedlist>
  4501. </para>
  4502. <para>
  4503. As an example, assume a Source Directory top-level folder
  4504. named <filename>poky</filename>, a default Build Directory at
  4505. <filename>poky/build</filename>, and a
  4506. <filename>qemux86-poky-linux</filename> machine target
  4507. system.
  4508. Furthermore, suppose your recipe is named
  4509. <filename>foo_1.3.0.bb</filename>.
  4510. In this case, the work directory the build system uses to
  4511. build the package would be as follows:
  4512. <literallayout class='monospaced'>
  4513. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  4514. </literallayout>
  4515. </para>
  4516. </section>
  4517. <section id="using-a-quilt-workflow">
  4518. <title>Using Quilt in Your Workflow</title>
  4519. <para>
  4520. <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
  4521. is a powerful tool that allows you to capture source code changes
  4522. without having a clean source tree.
  4523. This section outlines the typical workflow you can use to modify
  4524. source code, test changes, and then preserve the changes in the
  4525. form of a patch all using Quilt.
  4526. <note><title>Tip</title>
  4527. With regard to preserving changes to source files, if you
  4528. clean a recipe or have <filename>rm_work</filename> enabled,
  4529. the
  4530. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink>
  4531. as described in the Yocto Project Application Development
  4532. and the Extensible Software Development Kit (eSDK) manual
  4533. is a safer development flow than the flow that uses Quilt.
  4534. </note>
  4535. </para>
  4536. <para>
  4537. Follow these general steps:
  4538. <orderedlist>
  4539. <listitem><para>
  4540. <emphasis>Find the Source Code:</emphasis>
  4541. Temporary source code used by the OpenEmbedded build system
  4542. is kept in the
  4543. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4544. See the
  4545. "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
  4546. section to learn how to locate the directory that has the
  4547. temporary source code for a particular package.
  4548. </para></listitem>
  4549. <listitem><para>
  4550. <emphasis>Change Your Working Directory:</emphasis>
  4551. You need to be in the directory that has the temporary
  4552. source code.
  4553. That directory is defined by the
  4554. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  4555. variable.</para></listitem>
  4556. <listitem><para>
  4557. <emphasis>Create a New Patch:</emphasis>
  4558. Before modifying source code, you need to create a new
  4559. patch.
  4560. To create a new patch file, use
  4561. <filename>quilt new</filename> as below:
  4562. <literallayout class='monospaced'>
  4563. $ quilt new my_changes.patch
  4564. </literallayout>
  4565. </para></listitem>
  4566. <listitem><para>
  4567. <emphasis>Notify Quilt and Add Files:</emphasis>
  4568. After creating the patch, you need to notify Quilt about
  4569. the files you plan to edit.
  4570. You notify Quilt by adding the files to the patch you
  4571. just created:
  4572. <literallayout class='monospaced'>
  4573. $ quilt add file1.c file2.c file3.c
  4574. </literallayout>
  4575. </para></listitem>
  4576. <listitem><para>
  4577. <emphasis>Edit the Files:</emphasis>
  4578. Make your changes in the source code to the files you added
  4579. to the patch.
  4580. </para></listitem>
  4581. <listitem><para>
  4582. <emphasis>Test Your Changes:</emphasis>
  4583. Once you have modified the source code, the easiest way to
  4584. test your changes is by calling the
  4585. <filename>do_compile</filename> task as shown in the
  4586. following example:
  4587. <literallayout class='monospaced'>
  4588. $ bitbake -c compile -f <replaceable>package</replaceable>
  4589. </literallayout>
  4590. The <filename>-f</filename> or <filename>--force</filename>
  4591. option forces the specified task to execute.
  4592. If you find problems with your code, you can just keep
  4593. editing and re-testing iteratively until things work
  4594. as expected.
  4595. <note>
  4596. All the modifications you make to the temporary
  4597. source code disappear once you run the
  4598. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
  4599. or
  4600. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
  4601. tasks using BitBake (i.e.
  4602. <filename>bitbake -c clean <replaceable>package</replaceable></filename>
  4603. and
  4604. <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
  4605. Modifications will also disappear if you use the
  4606. <filename>rm_work</filename> feature as described
  4607. in the
  4608. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-saving-memory-during-a-build'>Conserving Disk Space During Builds</ulink>"
  4609. section.
  4610. </note>
  4611. </para></listitem>
  4612. <listitem><para>
  4613. <emphasis>Generate the Patch:</emphasis>
  4614. Once your changes work as expected, you need to use Quilt
  4615. to generate the final patch that contains all your
  4616. modifications.
  4617. <literallayout class='monospaced'>
  4618. $ quilt refresh
  4619. </literallayout>
  4620. At this point, the <filename>my_changes.patch</filename>
  4621. file has all your edits made to the
  4622. <filename>file1.c</filename>, <filename>file2.c</filename>,
  4623. and <filename>file3.c</filename> files.</para>
  4624. <para>You can find the resulting patch file in the
  4625. <filename>patches/</filename> subdirectory of the source
  4626. (<filename>S</filename>) directory.
  4627. </para></listitem>
  4628. <listitem><para>
  4629. <emphasis>Copy the Patch File:</emphasis>
  4630. For simplicity, copy the patch file into a directory
  4631. named <filename>files</filename>, which you can create
  4632. in the same directory that holds the recipe
  4633. (<filename>.bb</filename>) file or the append
  4634. (<filename>.bbappend</filename>) file.
  4635. Placing the patch here guarantees that the OpenEmbedded
  4636. build system will find the patch.
  4637. Next, add the patch into the
  4638. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  4639. of the recipe.
  4640. Here is an example:
  4641. <literallayout class='monospaced'>
  4642. SRC_URI += "file://my_changes.patch"
  4643. </literallayout>
  4644. </para></listitem>
  4645. </orderedlist>
  4646. </para>
  4647. </section>
  4648. <section id="platdev-appdev-devshell">
  4649. <title>Using a Development Shell</title>
  4650. <para>
  4651. When debugging certain commands or even when just editing packages,
  4652. <filename>devshell</filename> can be a useful tool.
  4653. When you invoke <filename>devshell</filename>, all tasks up to and
  4654. including
  4655. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  4656. are run for the specified target.
  4657. Then, a new terminal is opened and you are placed in
  4658. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  4659. the source directory.
  4660. In the new terminal, all the OpenEmbedded build-related environment variables are
  4661. still defined so you can use commands such as <filename>configure</filename> and
  4662. <filename>make</filename>.
  4663. The commands execute just as if the OpenEmbedded build system were executing them.
  4664. Consequently, working this way can be helpful when debugging a build or preparing
  4665. software to be used with the OpenEmbedded build system.
  4666. </para>
  4667. <para>
  4668. Following is an example that uses <filename>devshell</filename> on a target named
  4669. <filename>matchbox-desktop</filename>:
  4670. <literallayout class='monospaced'>
  4671. $ bitbake matchbox-desktop -c devshell
  4672. </literallayout>
  4673. </para>
  4674. <para>
  4675. This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
  4676. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  4677. variable controls what type of shell is opened.
  4678. </para>
  4679. <para>
  4680. For spawned terminals, the following occurs:
  4681. <itemizedlist>
  4682. <listitem><para>The <filename>PATH</filename> variable includes the
  4683. cross-toolchain.</para></listitem>
  4684. <listitem><para>The <filename>pkgconfig</filename> variables find the correct
  4685. <filename>.pc</filename> files.</para></listitem>
  4686. <listitem><para>The <filename>configure</filename> command finds the
  4687. Yocto Project site files as well as any other necessary files.</para></listitem>
  4688. </itemizedlist>
  4689. </para>
  4690. <para>
  4691. Within this environment, you can run configure or compile
  4692. commands as if they were being run by
  4693. the OpenEmbedded build system itself.
  4694. As noted earlier, the working directory also automatically changes to the
  4695. Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
  4696. </para>
  4697. <para>
  4698. To manually run a specific task using <filename>devshell</filename>,
  4699. run the corresponding <filename>run.*</filename> script in
  4700. the
  4701. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename>
  4702. directory (e.g.,
  4703. <filename>run.do_configure.</filename><replaceable>pid</replaceable>).
  4704. If a task's script does not exist, which would be the case if the task was
  4705. skipped by way of the sstate cache, you can create the task by first running
  4706. it outside of the <filename>devshell</filename>:
  4707. <literallayout class='monospaced'>
  4708. $ bitbake -c <replaceable>task</replaceable>
  4709. </literallayout>
  4710. <note><title>Notes</title>
  4711. <itemizedlist>
  4712. <listitem><para>Execution of a task's <filename>run.*</filename>
  4713. script and BitBake's execution of a task are identical.
  4714. In other words, running the script re-runs the task
  4715. just as it would be run using the
  4716. <filename>bitbake -c</filename> command.
  4717. </para></listitem>
  4718. <listitem><para>Any <filename>run.*</filename> file that does not
  4719. have a <filename>.pid</filename> extension is a
  4720. symbolic link (symlink) to the most recent version of that
  4721. file.
  4722. </para></listitem>
  4723. </itemizedlist>
  4724. </note>
  4725. </para>
  4726. <para>
  4727. Remember, that the <filename>devshell</filename> is a mechanism that allows
  4728. you to get into the BitBake task execution environment.
  4729. And as such, all commands must be called just as BitBake would call them.
  4730. That means you need to provide the appropriate options for
  4731. cross-compilation and so forth as applicable.
  4732. </para>
  4733. <para>
  4734. When you are finished using <filename>devshell</filename>, exit the shell
  4735. or close the terminal window.
  4736. </para>
  4737. <note><title>Notes</title>
  4738. <itemizedlist>
  4739. <listitem><para>
  4740. It is worth remembering that when using <filename>devshell</filename>
  4741. you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
  4742. instead of just using <filename>gcc</filename>.
  4743. The same applies to other applications such as <filename>binutils</filename>,
  4744. <filename>libtool</filename> and so forth.
  4745. BitBake sets up environment variables such as <filename>CC</filename>
  4746. to assist applications, such as <filename>make</filename> to find the correct tools.
  4747. </para></listitem>
  4748. <listitem><para>
  4749. It is also worth noting that <filename>devshell</filename> still works over
  4750. X11 forwarding and similar situations.
  4751. </para></listitem>
  4752. </itemizedlist>
  4753. </note>
  4754. </section>
  4755. <section id="platdev-appdev-devpyshell">
  4756. <title>Using a Development Python Shell</title>
  4757. <para>
  4758. Similar to working within a development shell as described in
  4759. the previous section, you can also spawn and work within an
  4760. interactive Python development shell.
  4761. When debugging certain commands or even when just editing packages,
  4762. <filename>devpyshell</filename> can be a useful tool.
  4763. When you invoke <filename>devpyshell</filename>, all tasks up to and
  4764. including
  4765. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  4766. are run for the specified target.
  4767. Then a new terminal is opened.
  4768. Additionally, key Python objects and code are available in the same
  4769. way they are to BitBake tasks, in particular, the data store 'd'.
  4770. So, commands such as the following are useful when exploring the data
  4771. store and running functions:
  4772. <literallayout class='monospaced'>
  4773. pydevshell> d.getVar("STAGING_DIR", True)
  4774. '/media/build1/poky/build/tmp/sysroots'
  4775. pydevshell> d.getVar("STAGING_DIR", False)
  4776. '${TMPDIR}/sysroots'
  4777. pydevshell> d.setVar("FOO", "bar")
  4778. pydevshell> d.getVar("FOO", True)
  4779. 'bar'
  4780. pydevshell> d.delVar("FOO")
  4781. pydevshell> d.getVar("FOO", True)
  4782. pydevshell> bb.build.exec_func("do_unpack", d)
  4783. pydevshell>
  4784. </literallayout>
  4785. The commands execute just as if the OpenEmbedded build system were executing them.
  4786. Consequently, working this way can be helpful when debugging a build or preparing
  4787. software to be used with the OpenEmbedded build system.
  4788. </para>
  4789. <para>
  4790. Following is an example that uses <filename>devpyshell</filename> on a target named
  4791. <filename>matchbox-desktop</filename>:
  4792. <literallayout class='monospaced'>
  4793. $ bitbake matchbox-desktop -c devpyshell
  4794. </literallayout>
  4795. </para>
  4796. <para>
  4797. This command spawns a terminal and places you in an interactive
  4798. Python interpreter within the OpenEmbedded build environment.
  4799. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  4800. variable controls what type of shell is opened.
  4801. </para>
  4802. <para>
  4803. When you are finished using <filename>devpyshell</filename>, you
  4804. can exit the shell either by using Ctrl+d or closing the terminal
  4805. window.
  4806. </para>
  4807. </section>
  4808. <section id='dev-building'>
  4809. <title>Building</title>
  4810. <para>
  4811. This section describes various build procedures.
  4812. For example, the steps needed for a simple build, a target that
  4813. uses multiple configurations, building an image for more than
  4814. one machine, and so forth.
  4815. </para>
  4816. <section id='dev-building-a-simple-image'>
  4817. <title>Building a Simple Image</title>
  4818. <para>
  4819. In the development environment, you need to build an image
  4820. whenever you change hardware support, add or change system
  4821. libraries, or add or change services that have dependencies.
  4822. Several methods exist that allow you to build an image within
  4823. the Yocto Project.
  4824. This section presents the basic steps you need to build a
  4825. simple image using BitBake from a build host running Linux.
  4826. <note><title>Notes</title>
  4827. <itemizedlist>
  4828. <listitem><para>
  4829. For information on how to build an image using
  4830. <ulink url='&YOCTO_DOCS_REF_URL;#toaster-term'>Toaster</ulink>,
  4831. see the
  4832. <ulink url='&YOCTO_DOCS_TOAST_URL;'>Toaster User Manual</ulink>.
  4833. </para></listitem>
  4834. <listitem><para>
  4835. For information on how to use
  4836. <filename>devtool</filename> to build images, see
  4837. the
  4838. "<ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'>Using <filename>devtool</filename> in Your SDK Workflow</ulink>"
  4839. section in the Yocto Project Application
  4840. Development and the Extensible Software Development
  4841. Kit (eSDK) manual.
  4842. </para></listitem>
  4843. <listitem><para>
  4844. For a quick example on how to build an image using
  4845. the OpenEmbedded build system, see the
  4846. <ulink url='&YOCTO_DOCS_BRIEF_URL;'>Yocto Project Quick Build</ulink>
  4847. document.
  4848. </para></listitem>
  4849. </itemizedlist>
  4850. </note>
  4851. </para>
  4852. <para>
  4853. The build process creates an entire Linux distribution from
  4854. source and places it in your
  4855. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  4856. under <filename>tmp/deploy/images</filename>.
  4857. For detailed information on the build process using BitBake,
  4858. see the
  4859. "<ulink url='&YOCTO_DOCS_OM_URL;#images-dev-environment'>Images</ulink>"
  4860. section in the Yocto Project Overview and Concepts Manual.
  4861. </para>
  4862. <para>
  4863. The following figure and list overviews the build process:
  4864. <imagedata fileref="figures/bitbake-build-flow.png" width="7in" depth="4in" align="center" scalefit="1" />
  4865. <orderedlist>
  4866. <listitem><para>
  4867. <emphasis>Set up Your Host Development System to Support
  4868. Development Using the Yocto Project</emphasis>:
  4869. See the
  4870. "<link linkend='dev-manual-start'>Setting Up to Use the Yocto Project</link>"
  4871. section for options on how to get a build host ready to
  4872. use the Yocto Project.
  4873. </para></listitem>
  4874. <listitem><para>
  4875. <emphasis>Initialize the Build Environment:</emphasis>
  4876. Initialize the build environment by sourcing the build
  4877. environment script (i.e.
  4878. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>):
  4879. <literallayout class='monospaced'>
  4880. $ source &OE_INIT_FILE; [<replaceable>build_dir</replaceable>]
  4881. </literallayout></para>
  4882. <para>When you use the initialization script, the
  4883. OpenEmbedded build system uses
  4884. <filename>build</filename> as the default Build
  4885. Directory in your current work directory.
  4886. You can use a <replaceable>build_dir</replaceable>
  4887. argument with the script to specify a different build
  4888. directory.
  4889. <note><title>Tip</title>
  4890. A common practice is to use a different Build
  4891. Directory for different targets.
  4892. For example, <filename>~/build/x86</filename> for a
  4893. <filename>qemux86</filename> target, and
  4894. <filename>~/build/arm</filename> for a
  4895. <filename>qemuarm</filename> target.
  4896. </note>
  4897. </para></listitem>
  4898. <listitem><para>
  4899. <emphasis>Make Sure Your <filename>local.conf</filename>
  4900. File is Correct:</emphasis>
  4901. Ensure the <filename>conf/local.conf</filename>
  4902. configuration file, which is found in the Build
  4903. Directory, is set up how you want it.
  4904. This file defines many aspects of the build environment
  4905. including the target machine architecture through the
  4906. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable,
  4907. the packaging format used during the build
  4908. (<ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>),
  4909. and a centralized tarball download directory through the
  4910. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> variable.
  4911. </para></listitem>
  4912. <listitem><para>
  4913. <emphasis>Build the Image:</emphasis>
  4914. Build the image using the <filename>bitbake</filename>
  4915. command:
  4916. <literallayout class='monospaced'>
  4917. $ bitbake <replaceable>target</replaceable>
  4918. </literallayout>
  4919. <note>
  4920. For information on BitBake, see the
  4921. <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
  4922. </note>
  4923. The <replaceable>target</replaceable> is the name of the
  4924. recipe you want to build.
  4925. Common targets are the images in
  4926. <filename>meta/recipes-core/images</filename>,
  4927. <filename>meta/recipes-sato/images</filename>, and so
  4928. forth all found in the
  4929. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  4930. Or, the target can be the name of a recipe for a
  4931. specific piece of software such as BusyBox.
  4932. For more details about the images the OpenEmbedded build
  4933. system supports, see the
  4934. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  4935. chapter in the Yocto Project Reference Manual.</para>
  4936. <para>As an example, the following command builds the
  4937. <filename>core-image-minimal</filename> image:
  4938. <literallayout class='monospaced'>
  4939. $ bitbake core-image-minimal
  4940. </literallayout>
  4941. Once an image has been built, it often needs to be
  4942. installed.
  4943. The images and kernels built by the OpenEmbedded
  4944. build system are placed in the Build Directory in
  4945. <filename class="directory">tmp/deploy/images</filename>.
  4946. For information on how to run pre-built images such as
  4947. <filename>qemux86</filename> and <filename>qemuarm</filename>,
  4948. see the
  4949. <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
  4950. manual.
  4951. For information about how to install these images,
  4952. see the documentation for your particular board or
  4953. machine.
  4954. </para></listitem>
  4955. </orderedlist>
  4956. </para>
  4957. </section>
  4958. <section id='dev-building-images-for-multiple-targets-using-multiple-configurations'>
  4959. <title>Building Images for Multiple Targets Using Multiple Configurations</title>
  4960. <para>
  4961. You can use a single <filename>bitbake</filename> command
  4962. to build multiple images or packages for different targets
  4963. where each image or package requires a different configuration
  4964. (multiple configuration builds).
  4965. The builds, in this scenario, are sometimes referred to as
  4966. "multiconfigs", and this section uses that term throughout.
  4967. </para>
  4968. <para>
  4969. This section describes how to set up for multiple
  4970. configuration builds and how to account for cross-build
  4971. dependencies between the multiconfigs.
  4972. </para>
  4973. <section id='dev-setting-up-and-running-a-multiple-configuration-build'>
  4974. <title>Setting Up and Running a Multiple Configuration Build</title>
  4975. <para>
  4976. To accomplish a multiple configuration build, you must
  4977. define each target's configuration separately using
  4978. a parallel configuration file in the
  4979. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  4980. and you must follow a required file hierarchy.
  4981. Additionally, you must enable the multiple configuration
  4982. builds in your <filename>local.conf</filename> file.
  4983. </para>
  4984. <para>
  4985. Follow these steps to set up and execute multiple
  4986. configuration builds:
  4987. <itemizedlist>
  4988. <listitem><para>
  4989. <emphasis>Create Separate Configuration Files</emphasis>:
  4990. You need to create a single configuration file for
  4991. each build target (each multiconfig).
  4992. Minimally, each configuration file must define the
  4993. machine and the temporary directory BitBake uses
  4994. for the build.
  4995. Suggested practice dictates that you do not
  4996. overlap the temporary directories
  4997. used during the builds.
  4998. However, it is possible that you can share the
  4999. temporary directory
  5000. (<ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>).
  5001. For example, consider a scenario with two
  5002. different multiconfigs for the same
  5003. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>: "qemux86" built for
  5004. two distributions such as "poky" and "poky-lsb".
  5005. In this case, you might want to use the same
  5006. <filename>TMPDIR</filename>.</para>
  5007. <para>Here is an example showing the minimal
  5008. statements needed in a configuration file for
  5009. a "qemux86" target whose temporary build directory
  5010. is <filename>tmpmultix86</filename>:
  5011. <literallayout class='monospaced'>
  5012. MACHINE="qemux86"
  5013. TMPDIR="${TOPDIR}/tmpmultix86"
  5014. </literallayout></para>
  5015. <para>The location for these multiconfig
  5016. configuration files is specific.
  5017. They must reside in the current build directory in
  5018. a sub-directory of <filename>conf</filename> named
  5019. <filename>multiconfig</filename>.
  5020. Following is an example that defines two
  5021. configuration files for the "x86" and "arm"
  5022. multiconfigs:
  5023. <imagedata fileref="figures/multiconfig_files.png" align="center" width="4in" depth="3in" />
  5024. </para>
  5025. <para>The reason for this required file hierarchy
  5026. is because the <filename>BBPATH</filename> variable
  5027. is not constructed until the layers are parsed.
  5028. Consequently, using the configuration file as a
  5029. pre-configuration file is not possible unless it is
  5030. located in the current working directory.
  5031. </para></listitem>
  5032. <listitem><para>
  5033. <emphasis>Add the BitBake Multi-configuration Variable to the Local Configuration File</emphasis>:
  5034. Use the
  5035. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBMULTICONFIG'><filename>BBMULTICONFIG</filename></ulink>
  5036. variable in your
  5037. <filename>conf/local.conf</filename> configuration
  5038. file to specify each multiconfig.
  5039. Continuing with the example from the previous
  5040. figure, the <filename>BBMULTICONFIG</filename>
  5041. variable needs to enable two multiconfigs: "x86"
  5042. and "arm" by specifying each configuration file:
  5043. <literallayout class='monospaced'>
  5044. BBMULTICONFIG = "x86 arm"
  5045. </literallayout>
  5046. </para></listitem>
  5047. <listitem><para>
  5048. <emphasis>Launch BitBake</emphasis>:
  5049. Use the following BitBake command form to launch the
  5050. multiple configuration build:
  5051. <literallayout class='monospaced'>
  5052. $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ]
  5053. </literallayout>
  5054. For the example in this section, the following
  5055. command applies:
  5056. <literallayout class='monospaced'>
  5057. $ bitbake multiconfig:x86:core-image-minimal multiconfig:arm:core-image-sato
  5058. </literallayout>
  5059. The previous BitBake command builds a
  5060. <filename>core-image-minimal</filename> image that
  5061. is configured through the
  5062. <filename>x86.conf</filename> configuration file
  5063. and builds a <filename>core-image-sato</filename>
  5064. image that is configured through the
  5065. <filename>arm.conf</filename> configuration file.
  5066. </para></listitem>
  5067. </itemizedlist>
  5068. <note>
  5069. Support for multiple configuration builds in the
  5070. Yocto Project &DISTRO; (&DISTRO_NAME;) Release does
  5071. not include Shared State (sstate) optimizations.
  5072. Consequently, if a build uses the same object twice
  5073. in, for example, two different
  5074. <filename>TMPDIR</filename> directories, the build
  5075. either loads from an existing sstate cache for that
  5076. build at the start or builds the object fresh.
  5077. </note>
  5078. </para>
  5079. </section>
  5080. <section id='dev-enabling-multiple-configuration-build-dependencies'>
  5081. <title>Enabling Multiple Configuration Build Dependencies</title>
  5082. <para>
  5083. Sometimes dependencies can exist between targets
  5084. (multiconfigs) in a multiple configuration build.
  5085. For example, suppose that in order to build a
  5086. <filename>core-image-sato</filename> image for an "x86"
  5087. multiconfig, the root filesystem of an "arm"
  5088. multiconfig must exist.
  5089. This dependency is essentially that the
  5090. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink>
  5091. task in the <filename>core-image-sato</filename> recipe
  5092. depends on the completion of the
  5093. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>
  5094. task of the <filename>core-image-minimal</filename>
  5095. recipe.
  5096. </para>
  5097. <para>
  5098. To enable dependencies in a multiple configuration
  5099. build, you must declare the dependencies in the recipe
  5100. using the following statement form:
  5101. <literallayout class='monospaced'>
  5102. <replaceable>task_or_package</replaceable>[mcdepends] = "multiconfig:<replaceable>from_multiconfig</replaceable>:<replaceable>to_multiconfig</replaceable>:<replaceable>recipe_name</replaceable>:<replaceable>task_on_which_to_depend</replaceable>"
  5103. </literallayout>
  5104. To better show how to use this statement, consider the
  5105. example scenario from the first paragraph of this section.
  5106. The following statement needs to be added to the recipe
  5107. that builds the <filename>core-image-sato</filename>
  5108. image:
  5109. <literallayout class='monospaced'>
  5110. do_image[mcdepends] = "multiconfig:x86:arm:core-image-minimal:do_rootfs"
  5111. </literallayout>
  5112. In this example, the
  5113. <replaceable>from_multiconfig</replaceable> is "x86".
  5114. The <replaceable>to_multiconfig</replaceable> is "arm".
  5115. The task on which the <filename>do_image</filename> task
  5116. in the recipe depends is the <filename>do_rootfs</filename>
  5117. task from the <filename>core-image-minimal</filename>
  5118. recipe associated with the "arm" multiconfig.
  5119. </para>
  5120. <para>
  5121. Once you set up this dependency, you can build the
  5122. "x86" multiconfig using a BitBake command as follows:
  5123. <literallayout class='monospaced'>
  5124. $ bitbake multiconfig:x86:core-image-sato
  5125. </literallayout>
  5126. This command executes all the tasks needed to create
  5127. the <filename>core-image-sato</filename> image for the
  5128. "x86" multiconfig.
  5129. Because of the dependency, BitBake also executes through
  5130. the <filename>do_rootfs</filename> task for the "arm"
  5131. multiconfig build.
  5132. </para>
  5133. <para>
  5134. Having a recipe depend on the root filesystem of another
  5135. build might not seem that useful.
  5136. Consider this change to the statement in the
  5137. <filename>core-image-sato</filename> recipe:
  5138. <literallayout class='monospaced'>
  5139. do_image[mcdepends] = "multiconfig:x86:arm:core-image-minimal:do_image"
  5140. </literallayout>
  5141. In this case, BitBake must create the
  5142. <filename>core-image-minimal</filename> image for the
  5143. "arm" build since the "x86" build depends on it.
  5144. </para>
  5145. <para>
  5146. Because "x86" and "arm" are enabled for multiple
  5147. configuration builds and have separate configuration
  5148. files, BitBake places the artifacts for each build in the
  5149. respective temporary build directories (i.e.
  5150. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>).
  5151. </para>
  5152. </section>
  5153. </section>
  5154. <section id='building-an-initramfs-image'>
  5155. <title>Building an Initial RAM Filesystem (initramfs) Image</title>
  5156. <para>
  5157. An initial RAM filesystem (initramfs) image provides a temporary
  5158. root filesystem used for early system initialization (e.g.
  5159. loading of modules needed to locate and mount the "real" root
  5160. filesystem).
  5161. <note>
  5162. The initramfs image is the successor of initial RAM disk
  5163. (initrd).
  5164. It is a "copy in and out" (cpio) archive of the initial
  5165. filesystem that gets loaded into memory during the Linux
  5166. startup process.
  5167. Because Linux uses the contents of the archive during
  5168. initialization, the initramfs image needs to contain all of the
  5169. device drivers and tools needed to mount the final root
  5170. filesystem.
  5171. </note>
  5172. </para>
  5173. <para>
  5174. Follow these steps to create an initramfs image:
  5175. <orderedlist>
  5176. <listitem><para>
  5177. <emphasis>Create the initramfs Image Recipe:</emphasis>
  5178. You can reference the
  5179. <filename>core-image-minimal-initramfs.bb</filename>
  5180. recipe found in the <filename>meta/recipes-core</filename>
  5181. directory of the
  5182. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  5183. as an example from which to work.
  5184. </para></listitem>
  5185. <listitem><para>
  5186. <emphasis>Decide if You Need to Bundle the initramfs Image
  5187. Into the Kernel Image:</emphasis>
  5188. If you want the initramfs image that is built to be
  5189. bundled in with the kernel image, set the
  5190. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  5191. variable to "1" in your <filename>local.conf</filename>
  5192. configuration file and set the
  5193. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink>
  5194. variable in the recipe that builds the kernel image.
  5195. <note><title>Tip</title>
  5196. It is recommended that you do bundle the initramfs
  5197. image with the kernel image to avoid circular
  5198. dependencies between the kernel recipe and the
  5199. initramfs recipe should the initramfs image
  5200. include kernel modules.
  5201. </note>
  5202. Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename>
  5203. flag causes the initramfs image to be unpacked
  5204. into the <filename>${B}/usr/</filename> directory.
  5205. The unpacked initramfs image is then passed to the kernel's
  5206. <filename>Makefile</filename> using the
  5207. <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink>
  5208. variable, allowing the initramfs image to be built into
  5209. the kernel normally.
  5210. <note>
  5211. If you choose to not bundle the initramfs image with
  5212. the kernel image, you are essentially using an
  5213. <ulink url='https://en.wikipedia.org/wiki/Initrd'>Initial RAM Disk (initrd)</ulink>.
  5214. Creating an initrd is handled primarily through the
  5215. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRD_IMAGE'><filename>INITRD_IMAGE</filename></ulink>,
  5216. <filename>INITRD_LIVE</filename>, and
  5217. <filename>INITRD_IMAGE_LIVE</filename> variables.
  5218. For more information, see the
  5219. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/image-live.bbclass'><filename>image-live.bbclass</filename></ulink>
  5220. file.
  5221. </note>
  5222. </para></listitem>
  5223. <listitem><para>
  5224. <emphasis>Optionally Add Items to the initramfs Image
  5225. Through the initramfs Image Recipe:</emphasis>
  5226. If you add items to the initramfs image by way of its
  5227. recipe, you should use
  5228. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>
  5229. rather than
  5230. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>.
  5231. <filename>PACKAGE_INSTALL</filename> gives more direct
  5232. control of what is added to the image as compared to
  5233. the defaults you might not necessarily want that are
  5234. set by the
  5235. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink>
  5236. or
  5237. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink>
  5238. classes.
  5239. </para></listitem>
  5240. <listitem><para>
  5241. <emphasis>Build the Kernel Image and the initramfs
  5242. Image:</emphasis>
  5243. Build your kernel image using BitBake.
  5244. Because the initramfs image recipe is a dependency of the
  5245. kernel image, the initramfs image is built as well and
  5246. bundled with the kernel image if you used the
  5247. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  5248. variable described earlier.
  5249. </para></listitem>
  5250. </orderedlist>
  5251. </para>
  5252. </section>
  5253. <section id='building-a-tiny-system'>
  5254. <title>Building a Tiny System</title>
  5255. <para>
  5256. Very small distributions have some significant advantages such
  5257. as requiring less on-die or in-package memory (cheaper), better
  5258. performance through efficient cache usage, lower power requirements
  5259. due to less memory, faster boot times, and reduced development
  5260. overhead.
  5261. Some real-world examples where a very small distribution gives
  5262. you distinct advantages are digital cameras, medical devices,
  5263. and small headless systems.
  5264. </para>
  5265. <para>
  5266. This section presents information that shows you how you can
  5267. trim your distribution to even smaller sizes than the
  5268. <filename>poky-tiny</filename> distribution, which is around
  5269. 5 Mbytes, that can be built out-of-the-box using the Yocto Project.
  5270. </para>
  5271. <section id='tiny-system-overview'>
  5272. <title>Overview</title>
  5273. <para>
  5274. The following list presents the overall steps you need to
  5275. consider and perform to create distributions with smaller
  5276. root filesystems, achieve faster boot times, maintain your critical
  5277. functionality, and avoid initial RAM disks:
  5278. <itemizedlist>
  5279. <listitem><para>
  5280. <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link>
  5281. </para></listitem>
  5282. <listitem><para>
  5283. <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link>
  5284. </para></listitem>
  5285. <listitem><para>
  5286. <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link>
  5287. </para></listitem>
  5288. <listitem><para>
  5289. <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link>
  5290. </para></listitem>
  5291. <listitem><para>
  5292. <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link>
  5293. </para></listitem>
  5294. <listitem><para>
  5295. <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link>
  5296. </para></listitem>
  5297. <listitem><para>
  5298. <link linkend='iterate-on-the-process'>Iterate on the process.</link>
  5299. </para></listitem>
  5300. </itemizedlist>
  5301. </para>
  5302. </section>
  5303. <section id='goals-and-guiding-principles'>
  5304. <title>Goals and Guiding Principles</title>
  5305. <para>
  5306. Before you can reach your destination, you need to know
  5307. where you are going.
  5308. Here is an example list that you can use as a guide when
  5309. creating very small distributions:
  5310. <itemizedlist>
  5311. <listitem><para>Determine how much space you need
  5312. (e.g. a kernel that is 1 Mbyte or less and
  5313. a root filesystem that is 3 Mbytes or less).
  5314. </para></listitem>
  5315. <listitem><para>Find the areas that are currently
  5316. taking 90% of the space and concentrate on reducing
  5317. those areas.
  5318. </para></listitem>
  5319. <listitem><para>Do not create any difficult "hacks"
  5320. to achieve your goals.</para></listitem>
  5321. <listitem><para>Leverage the device-specific
  5322. options.</para></listitem>
  5323. <listitem><para>Work in a separate layer so that you
  5324. keep changes isolated.
  5325. For information on how to create layers, see
  5326. the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section.
  5327. </para></listitem>
  5328. </itemizedlist>
  5329. </para>
  5330. </section>
  5331. <section id='understand-what-gives-your-image-size'>
  5332. <title>Understand What Contributes to Your Image Size</title>
  5333. <para>
  5334. It is easiest to have something to start with when creating
  5335. your own distribution.
  5336. You can use the Yocto Project out-of-the-box to create the
  5337. <filename>poky-tiny</filename> distribution.
  5338. Ultimately, you will want to make changes in your own
  5339. distribution that are likely modeled after
  5340. <filename>poky-tiny</filename>.
  5341. <note>
  5342. To use <filename>poky-tiny</filename> in your build,
  5343. set the
  5344. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5345. variable in your
  5346. <filename>local.conf</filename> file to "poky-tiny"
  5347. as described in the
  5348. "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  5349. section.
  5350. </note>
  5351. </para>
  5352. <para>
  5353. Understanding some memory concepts will help you reduce the
  5354. system size.
  5355. Memory consists of static, dynamic, and temporary memory.
  5356. Static memory is the TEXT (code), DATA (initialized data
  5357. in the code), and BSS (uninitialized data) sections.
  5358. Dynamic memory represents memory that is allocated at runtime:
  5359. stacks, hash tables, and so forth.
  5360. Temporary memory is recovered after the boot process.
  5361. This memory consists of memory used for decompressing
  5362. the kernel and for the <filename>__init__</filename>
  5363. functions.
  5364. </para>
  5365. <para>
  5366. To help you see where you currently are with kernel and root
  5367. filesystem sizes, you can use two tools found in the
  5368. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> in
  5369. the <filename>scripts/tiny/</filename> directory:
  5370. <itemizedlist>
  5371. <listitem><para><filename>ksize.py</filename>: Reports
  5372. component sizes for the kernel build objects.
  5373. </para></listitem>
  5374. <listitem><para><filename>dirsize.py</filename>: Reports
  5375. component sizes for the root filesystem.</para></listitem>
  5376. </itemizedlist>
  5377. This next tool and command help you organize configuration
  5378. fragments and view file dependencies in a human-readable form:
  5379. <itemizedlist>
  5380. <listitem><para><filename>merge_config.sh</filename>:
  5381. Helps you manage configuration files and fragments
  5382. within the kernel.
  5383. With this tool, you can merge individual configuration
  5384. fragments together.
  5385. The tool allows you to make overrides and warns you
  5386. of any missing configuration options.
  5387. The tool is ideal for allowing you to iterate on
  5388. configurations, create minimal configurations, and
  5389. create configuration files for different machines
  5390. without having to duplicate your process.</para>
  5391. <para>The <filename>merge_config.sh</filename> script is
  5392. part of the Linux Yocto kernel Git repositories
  5393. (i.e. <filename>linux-yocto-3.14</filename>,
  5394. <filename>linux-yocto-3.10</filename>,
  5395. <filename>linux-yocto-3.8</filename>, and so forth)
  5396. in the
  5397. <filename>scripts/kconfig</filename> directory.</para>
  5398. <para>For more information on configuration fragments,
  5399. see the
  5400. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#creating-config-fragments'>Creating Configuration Fragments</ulink>"
  5401. section in the Yocto Project Linux Kernel Development
  5402. Manual.
  5403. </para></listitem>
  5404. <listitem><para><filename>bitbake -u taskexp -g <replaceable>bitbake_target</replaceable></filename>:
  5405. Using the BitBake command with these options brings up
  5406. a Dependency Explorer from which you can view file
  5407. dependencies.
  5408. Understanding these dependencies allows you to make
  5409. informed decisions when cutting out various pieces of the
  5410. kernel and root filesystem.</para></listitem>
  5411. </itemizedlist>
  5412. </para>
  5413. </section>
  5414. <section id='trim-the-root-filesystem'>
  5415. <title>Trim the Root Filesystem</title>
  5416. <para>
  5417. The root filesystem is made up of packages for booting,
  5418. libraries, and applications.
  5419. To change things, you can configure how the packaging happens,
  5420. which changes the way you build them.
  5421. You can also modify the filesystem itself or select a different
  5422. filesystem.
  5423. </para>
  5424. <para>
  5425. First, find out what is hogging your root filesystem by running the
  5426. <filename>dirsize.py</filename> script from your root directory:
  5427. <literallayout class='monospaced'>
  5428. $ cd <replaceable>root-directory-of-image</replaceable>
  5429. $ dirsize.py 100000 > dirsize-100k.log
  5430. $ cat dirsize-100k.log
  5431. </literallayout>
  5432. You can apply a filter to the script to ignore files under
  5433. a certain size.
  5434. The previous example filters out any files below 100 Kbytes.
  5435. The sizes reported by the tool are uncompressed, and thus
  5436. will be smaller by a relatively constant factor in a
  5437. compressed root filesystem.
  5438. When you examine your log file, you can focus on areas of the
  5439. root filesystem that take up large amounts of memory.
  5440. </para>
  5441. <para>
  5442. You need to be sure that what you eliminate does not cripple
  5443. the functionality you need.
  5444. One way to see how packages relate to each other is by using
  5445. the Dependency Explorer UI with the BitBake command:
  5446. <literallayout class='monospaced'>
  5447. $ cd <replaceable>image-directory</replaceable>
  5448. $ bitbake -u taskexp -g <replaceable>image</replaceable>
  5449. </literallayout>
  5450. Use the interface to select potential packages you wish to
  5451. eliminate and see their dependency relationships.
  5452. </para>
  5453. <para>
  5454. When deciding how to reduce the size, get rid of packages that
  5455. result in minimal impact on the feature set.
  5456. For example, you might not need a VGA display.
  5457. Or, you might be able to get by with <filename>devtmpfs</filename>
  5458. and <filename>mdev</filename> instead of
  5459. <filename>udev</filename>.
  5460. </para>
  5461. <para>
  5462. Use your <filename>local.conf</filename> file to make changes.
  5463. For example, to eliminate <filename>udev</filename> and
  5464. <filename>glib</filename>, set the following in the
  5465. local configuration file:
  5466. <literallayout class='monospaced'>
  5467. VIRTUAL-RUNTIME_dev_manager = ""
  5468. </literallayout>
  5469. </para>
  5470. <para>
  5471. Finally, you should consider exactly the type of root
  5472. filesystem you need to meet your needs while also reducing
  5473. its size.
  5474. For example, consider <filename>cramfs</filename>,
  5475. <filename>squashfs</filename>, <filename>ubifs</filename>,
  5476. <filename>ext2</filename>, or an <filename>initramfs</filename>
  5477. using <filename>initramfs</filename>.
  5478. Be aware that <filename>ext3</filename> requires a 1 Mbyte
  5479. journal.
  5480. If you are okay with running read-only, you do not need this
  5481. journal.
  5482. </para>
  5483. <note>
  5484. After each round of elimination, you need to rebuild your
  5485. system and then use the tools to see the effects of your
  5486. reductions.
  5487. </note>
  5488. </section>
  5489. <section id='trim-the-kernel'>
  5490. <title>Trim the Kernel</title>
  5491. <para>
  5492. The kernel is built by including policies for hardware-independent
  5493. aspects.
  5494. What subsystems do you enable?
  5495. For what architecture are you building?
  5496. Which drivers do you build by default?
  5497. <note>You can modify the kernel source if you want to help
  5498. with boot time.
  5499. </note>
  5500. </para>
  5501. <para>
  5502. Run the <filename>ksize.py</filename> script from the top-level
  5503. Linux build directory to get an idea of what is making up
  5504. the kernel:
  5505. <literallayout class='monospaced'>
  5506. $ cd <replaceable>top-level-linux-build-directory</replaceable>
  5507. $ ksize.py > ksize.log
  5508. $ cat ksize.log
  5509. </literallayout>
  5510. When you examine the log, you will see how much space is
  5511. taken up with the built-in <filename>.o</filename> files for
  5512. drivers, networking, core kernel files, filesystem, sound,
  5513. and so forth.
  5514. The sizes reported by the tool are uncompressed, and thus
  5515. will be smaller by a relatively constant factor in a compressed
  5516. kernel image.
  5517. Look to reduce the areas that are large and taking up around
  5518. the "90% rule."
  5519. </para>
  5520. <para>
  5521. To examine, or drill down, into any particular area, use the
  5522. <filename>-d</filename> option with the script:
  5523. <literallayout class='monospaced'>
  5524. $ ksize.py -d > ksize.log
  5525. </literallayout>
  5526. Using this option breaks out the individual file information
  5527. for each area of the kernel (e.g. drivers, networking, and
  5528. so forth).
  5529. </para>
  5530. <para>
  5531. Use your log file to see what you can eliminate from the kernel
  5532. based on features you can let go.
  5533. For example, if you are not going to need sound, you do not
  5534. need any drivers that support sound.
  5535. </para>
  5536. <para>
  5537. After figuring out what to eliminate, you need to reconfigure
  5538. the kernel to reflect those changes during the next build.
  5539. You could run <filename>menuconfig</filename> and make all your
  5540. changes at once.
  5541. However, that makes it difficult to see the effects of your
  5542. individual eliminations and also makes it difficult to replicate
  5543. the changes for perhaps another target device.
  5544. A better method is to start with no configurations using
  5545. <filename>allnoconfig</filename>, create configuration
  5546. fragments for individual changes, and then manage the
  5547. fragments into a single configuration file using
  5548. <filename>merge_config.sh</filename>.
  5549. The tool makes it easy for you to iterate using the
  5550. configuration change and build cycle.
  5551. </para>
  5552. <para>
  5553. Each time you make configuration changes, you need to rebuild
  5554. the kernel and check to see what impact your changes had on
  5555. the overall size.
  5556. </para>
  5557. </section>
  5558. <section id='remove-package-management-requirements'>
  5559. <title>Remove Package Management Requirements</title>
  5560. <para>
  5561. Packaging requirements add size to the image.
  5562. One way to reduce the size of the image is to remove all the
  5563. packaging requirements from the image.
  5564. This reduction includes both removing the package manager
  5565. and its unique dependencies as well as removing the package
  5566. management data itself.
  5567. </para>
  5568. <para>
  5569. To eliminate all the packaging requirements for an image,
  5570. be sure that "package-management" is not part of your
  5571. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  5572. statement for the image.
  5573. When you remove this feature, you are removing the package
  5574. manager as well as its dependencies from the root filesystem.
  5575. </para>
  5576. </section>
  5577. <section id='look-for-other-ways-to-minimize-size'>
  5578. <title>Look for Other Ways to Minimize Size</title>
  5579. <para>
  5580. Depending on your particular circumstances, other areas that you
  5581. can trim likely exist.
  5582. The key to finding these areas is through tools and methods
  5583. described here combined with experimentation and iteration.
  5584. Here are a couple of areas to experiment with:
  5585. <itemizedlist>
  5586. <listitem><para><filename>glibc</filename>:
  5587. In general, follow this process:
  5588. <orderedlist>
  5589. <listitem><para>Remove <filename>glibc</filename>
  5590. features from
  5591. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  5592. that you think you do not need.</para></listitem>
  5593. <listitem><para>Build your distribution.
  5594. </para></listitem>
  5595. <listitem><para>If the build fails due to missing
  5596. symbols in a package, determine if you can
  5597. reconfigure the package to not need those
  5598. features.
  5599. For example, change the configuration to not
  5600. support wide character support as is done for
  5601. <filename>ncurses</filename>.
  5602. Or, if support for those characters is needed,
  5603. determine what <filename>glibc</filename>
  5604. features provide the support and restore the
  5605. configuration.
  5606. </para></listitem>
  5607. <listitem><para>Rebuild and repeat the process.
  5608. </para></listitem>
  5609. </orderedlist></para></listitem>
  5610. <listitem><para><filename>busybox</filename>:
  5611. For BusyBox, use a process similar as described for
  5612. <filename>glibc</filename>.
  5613. A difference is you will need to boot the resulting
  5614. system to see if you are able to do everything you
  5615. expect from the running system.
  5616. You need to be sure to integrate configuration fragments
  5617. into Busybox because BusyBox handles its own core
  5618. features and then allows you to add configuration
  5619. fragments on top.
  5620. </para></listitem>
  5621. </itemizedlist>
  5622. </para>
  5623. </section>
  5624. <section id='iterate-on-the-process'>
  5625. <title>Iterate on the Process</title>
  5626. <para>
  5627. If you have not reached your goals on system size, you need
  5628. to iterate on the process.
  5629. The process is the same.
  5630. Use the tools and see just what is taking up 90% of the root
  5631. filesystem and the kernel.
  5632. Decide what you can eliminate without limiting your device
  5633. beyond what you need.
  5634. </para>
  5635. <para>
  5636. Depending on your system, a good place to look might be
  5637. Busybox, which provides a stripped down
  5638. version of Unix tools in a single, executable file.
  5639. You might be able to drop virtual terminal services or perhaps
  5640. ipv6.
  5641. </para>
  5642. </section>
  5643. </section>
  5644. <section id='building-images-for-more-than-one-machine'>
  5645. <title>Building Images for More than One Machine</title>
  5646. <para>
  5647. A common scenario developers face is creating images for several
  5648. different machines that use the same software environment.
  5649. In this situation, it is tempting to set the
  5650. tunings and optimization flags for each build specifically for
  5651. the targeted hardware (i.e. "maxing out" the tunings).
  5652. Doing so can considerably add to build times and package feed
  5653. maintenance collectively for the machines.
  5654. For example, selecting tunes that are extremely specific to a
  5655. CPU core used in a system might enable some micro optimizations
  5656. in GCC for that particular system but would otherwise not gain
  5657. you much of a performance difference across the other systems
  5658. as compared to using a more general tuning across all the builds
  5659. (e.g. setting
  5660. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink>
  5661. specifically for each machine's build).
  5662. Rather than "max out" each build's tunings, you can take steps that
  5663. cause the OpenEmbedded build system to reuse software across the
  5664. various machines where it makes sense.
  5665. </para>
  5666. <para>
  5667. If build speed and package feed maintenance are considerations,
  5668. you should consider the points in this section that can help you
  5669. optimize your tunings to best consider build times and package
  5670. feed maintenance.
  5671. <itemizedlist>
  5672. <listitem><para>
  5673. <emphasis>Share the Build Directory:</emphasis>
  5674. If at all possible, share the
  5675. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  5676. across builds.
  5677. The Yocto Project supports switching between different
  5678. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  5679. values in the same <filename>TMPDIR</filename>.
  5680. This practice is well supported and regularly used by
  5681. developers when building for multiple machines.
  5682. When you use the same <filename>TMPDIR</filename> for
  5683. multiple machine builds, the OpenEmbedded build system can
  5684. reuse the existing native and often cross-recipes for
  5685. multiple machines.
  5686. Thus, build time decreases.
  5687. <note>
  5688. If
  5689. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5690. settings change or fundamental configuration settings
  5691. such as the filesystem layout, you need to work with
  5692. a clean <filename>TMPDIR</filename>.
  5693. Sharing <filename>TMPDIR</filename> under these
  5694. circumstances might work but since it is not
  5695. guaranteed, you should use a clean
  5696. <filename>TMPDIR</filename>.
  5697. </note>
  5698. </para></listitem>
  5699. <listitem><para>
  5700. <emphasis>Enable the Appropriate Package Architecture:</emphasis>
  5701. By default, the OpenEmbedded build system enables three
  5702. levels of package architectures: "all", "tune" or "package",
  5703. and "machine".
  5704. Any given recipe usually selects one of these package
  5705. architectures (types) for its output.
  5706. Depending for what a given recipe creates packages, making
  5707. sure you enable the appropriate package architecture can
  5708. directly impact the build time.</para>
  5709. <para>A recipe that just generates scripts can enable
  5710. "all" architecture because there are no binaries to build.
  5711. To specifically enable "all" architecture, be sure your
  5712. recipe inherits the
  5713. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  5714. class.
  5715. This class is useful for "all" architectures because it
  5716. configures many variables so packages can be used across
  5717. multiple architectures.</para>
  5718. <para>If your recipe needs to generate packages that are
  5719. machine-specific or when one of the build or runtime
  5720. dependencies is already machine-architecture dependent,
  5721. which makes your recipe also machine-architecture dependent,
  5722. make sure your recipe enables the "machine" package
  5723. architecture through the
  5724. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>
  5725. variable:
  5726. <literallayout class='monospaced'>
  5727. PACKAGE_ARCH = "${MACHINE_ARCH}"
  5728. </literallayout>
  5729. When you do not specifically enable a package
  5730. architecture through the
  5731. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>,
  5732. The OpenEmbedded build system defaults to the
  5733. <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink>
  5734. setting:
  5735. <literallayout class='monospaced'>
  5736. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  5737. </literallayout>
  5738. </para></listitem>
  5739. <listitem><para>
  5740. <emphasis>Choose a Generic Tuning File if Possible:</emphasis>
  5741. Some tunes are more generic and can run on multiple targets
  5742. (e.g. an <filename>armv5</filename> set of packages could
  5743. run on <filename>armv6</filename> and
  5744. <filename>armv7</filename> processors in most cases).
  5745. Similarly, <filename>i486</filename> binaries could work
  5746. on <filename>i586</filename> and higher processors.
  5747. You should realize, however, that advances on newer
  5748. processor versions would not be used.</para>
  5749. <para>If you select the same tune for several different
  5750. machines, the OpenEmbedded build system reuses software
  5751. previously built, thus speeding up the overall build time.
  5752. Realize that even though a new sysroot for each machine is
  5753. generated, the software is not recompiled and only one
  5754. package feed exists.
  5755. </para></listitem>
  5756. <listitem><para>
  5757. <emphasis>Manage Granular Level Packaging:</emphasis>
  5758. Sometimes cases exist where injecting another level of
  5759. package architecture beyond the three higher levels noted
  5760. earlier can be useful.
  5761. For example, consider how NXP (formerly Freescale) allows
  5762. for the easy reuse of binary packages in their layer
  5763. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/meta-freescale/'><filename>meta-freescale</filename></ulink>.
  5764. In this example, the
  5765. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/meta-freescale/tree/classes/fsl-dynamic-packagearch.bbclass'><filename>fsl-dynamic-packagearch</filename></ulink>
  5766. class shares GPU packages for i.MX53 boards because
  5767. all boards share the AMD GPU.
  5768. The i.MX6-based boards can do the same because all boards
  5769. share the Vivante GPU.
  5770. This class inspects the BitBake datastore to identify if
  5771. the package provides or depends on one of the
  5772. sub-architecture values.
  5773. If so, the class sets the
  5774. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>
  5775. value based on the <filename>MACHINE_SUBARCH</filename>
  5776. value.
  5777. If the package does not provide or depend on one of the
  5778. sub-architecture values but it matches a value in the
  5779. machine-specific filter, it sets
  5780. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>.
  5781. This behavior reduces the number of packages built and
  5782. saves build time by reusing binaries.
  5783. </para></listitem>
  5784. <listitem><para>
  5785. <emphasis>Use Tools to Debug Issues:</emphasis>
  5786. Sometimes you can run into situations where software is
  5787. being rebuilt when you think it should not be.
  5788. For example, the OpenEmbedded build system might not be
  5789. using shared state between machines when you think it
  5790. should be.
  5791. These types of situations are usually due to references
  5792. to machine-specific variables such as
  5793. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  5794. <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'><filename>SERIAL_CONSOLES</filename></ulink>,
  5795. <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>,
  5796. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>,
  5797. and so forth in code that is supposed to only be
  5798. tune-specific or when the recipe depends
  5799. (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  5800. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  5801. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  5802. <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>,
  5803. and so forth) on some other recipe that already has
  5804. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>
  5805. defined as "${MACHINE_ARCH}".
  5806. <note>
  5807. Patches to fix any issues identified are most welcome
  5808. as these issues occasionally do occur.
  5809. </note></para>
  5810. <para>For such cases, you can use some tools to help you
  5811. sort out the situation:
  5812. <itemizedlist>
  5813. <listitem><para>
  5814. <emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis>
  5815. You can find this tool in the
  5816. <filename>scripts</filename> directory of the
  5817. Source Repositories.
  5818. See the comments in the script for information on
  5819. how to use the tool.
  5820. </para></listitem>
  5821. <listitem><para>
  5822. <emphasis>BitBake's "-S printdiff" Option:</emphasis>
  5823. Using this option causes BitBake to try to
  5824. establish the closest signature match it can
  5825. (e.g. in the shared state cache) and then run
  5826. <filename>bitbake-diffsigs</filename> over the
  5827. matches to determine the stamps and delta where
  5828. these two stamp trees diverge.
  5829. </para></listitem>
  5830. </itemizedlist>
  5831. </para></listitem>
  5832. </itemizedlist>
  5833. </para>
  5834. </section>
  5835. <section id="building-software-from-an-external-source">
  5836. <title>Building Software from an External Source</title>
  5837. <para>
  5838. By default, the OpenEmbedded build system uses the
  5839. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  5840. when building source code.
  5841. The build process involves fetching the source files, unpacking
  5842. them, and then patching them if necessary before the build takes
  5843. place.
  5844. </para>
  5845. <para>
  5846. Situations exist where you might want to build software from source
  5847. files that are external to and thus outside of the
  5848. OpenEmbedded build system.
  5849. For example, suppose you have a project that includes a new BSP with
  5850. a heavily customized kernel.
  5851. And, you want to minimize exposing the build system to the
  5852. development team so that they can focus on their project and
  5853. maintain everyone's workflow as much as possible.
  5854. In this case, you want a kernel source directory on the development
  5855. machine where the development occurs.
  5856. You want the recipe's
  5857. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  5858. variable to point to the external directory and use it as is, not
  5859. copy it.
  5860. </para>
  5861. <para>
  5862. To build from software that comes from an external source, all you
  5863. need to do is inherit the
  5864. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  5865. class and then set the
  5866. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>
  5867. variable to point to your external source code.
  5868. Here are the statements to put in your
  5869. <filename>local.conf</filename> file:
  5870. <literallayout class='monospaced'>
  5871. INHERIT += "externalsrc"
  5872. EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  5873. </literallayout>
  5874. </para>
  5875. <para>
  5876. This next example shows how to accomplish the same thing by setting
  5877. <filename>EXTERNALSRC</filename> in the recipe itself or in the
  5878. recipe's append file:
  5879. <literallayout class='monospaced'>
  5880. EXTERNALSRC = "<replaceable>path</replaceable>"
  5881. EXTERNALSRC_BUILD = "<replaceable>path</replaceable>"
  5882. </literallayout>
  5883. <note>
  5884. In order for these settings to take effect, you must globally
  5885. or locally inherit the
  5886. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  5887. class.
  5888. </note>
  5889. </para>
  5890. <para>
  5891. By default, <filename>externalsrc.bbclass</filename> builds
  5892. the source code in a directory separate from the external source
  5893. directory as specified by
  5894. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>.
  5895. If you need to have the source built in the same directory in
  5896. which it resides, or some other nominated directory, you can set
  5897. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink>
  5898. to point to that directory:
  5899. <literallayout class='monospaced'>
  5900. EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  5901. </literallayout>
  5902. </para>
  5903. </section>
  5904. </section>
  5905. <section id='speeding-up-a-build'>
  5906. <title>Speeding Up a Build</title>
  5907. <para>
  5908. Build time can be an issue.
  5909. By default, the build system uses simple controls to try and maximize
  5910. build efficiency.
  5911. In general, the default settings for all the following variables
  5912. result in the most efficient build times when dealing with single
  5913. socket systems (i.e. a single CPU).
  5914. If you have multiple CPUs, you might try increasing the default
  5915. values to gain more speed.
  5916. See the descriptions in the glossary for each variable for more
  5917. information:
  5918. <itemizedlist>
  5919. <listitem><para>
  5920. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename>:</ulink>
  5921. The maximum number of threads BitBake simultaneously executes.
  5922. </para></listitem>
  5923. <listitem><para>
  5924. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename>:</ulink>
  5925. The number of threads BitBake uses during parsing.
  5926. </para></listitem>
  5927. <listitem><para>
  5928. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename>:</ulink>
  5929. Extra options passed to the <filename>make</filename> command
  5930. during the
  5931. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  5932. task in order to specify parallel compilation on the
  5933. local build host.
  5934. </para></listitem>
  5935. <listitem><para>
  5936. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename>:</ulink>
  5937. Extra options passed to the <filename>make</filename> command
  5938. during the
  5939. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  5940. task in order to specify parallel installation on the
  5941. local build host.
  5942. </para></listitem>
  5943. </itemizedlist>
  5944. As mentioned, these variables all scale to the number of processor
  5945. cores available on the build system.
  5946. For single socket systems, this auto-scaling ensures that the build
  5947. system fundamentally takes advantage of potential parallel operations
  5948. during the build based on the build machine's capabilities.
  5949. </para>
  5950. <para>
  5951. Following are additional factors that can affect build speed:
  5952. <itemizedlist>
  5953. <listitem><para>
  5954. File system type:
  5955. The file system type that the build is being performed on can
  5956. also influence performance.
  5957. Using <filename>ext4</filename> is recommended as compared
  5958. to <filename>ext2</filename> and <filename>ext3</filename>
  5959. due to <filename>ext4</filename> improved features
  5960. such as extents.
  5961. </para></listitem>
  5962. <listitem><para>
  5963. Disabling the updating of access time using
  5964. <filename>noatime</filename>:
  5965. The <filename>noatime</filename> mount option prevents the
  5966. build system from updating file and directory access times.
  5967. </para></listitem>
  5968. <listitem><para>
  5969. Setting a longer commit:
  5970. Using the "commit=" mount option increases the interval
  5971. in seconds between disk cache writes.
  5972. Changing this interval from the five second default to
  5973. something longer increases the risk of data loss but decreases
  5974. the need to write to the disk, thus increasing the build
  5975. performance.
  5976. </para></listitem>
  5977. <listitem><para>
  5978. Choosing the packaging backend:
  5979. Of the available packaging backends, IPK is the fastest.
  5980. Additionally, selecting a singular packaging backend also
  5981. helps.
  5982. </para></listitem>
  5983. <listitem><para>
  5984. Using <filename>tmpfs</filename> for
  5985. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  5986. as a temporary file system:
  5987. While this can help speed up the build, the benefits are
  5988. limited due to the compiler using
  5989. <filename>-pipe</filename>.
  5990. The build system goes to some lengths to avoid
  5991. <filename>sync()</filename> calls into the
  5992. file system on the principle that if there was a significant
  5993. failure, the
  5994. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  5995. contents could easily be rebuilt.
  5996. </para></listitem>
  5997. <listitem><para>
  5998. Inheriting the
  5999. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  6000. class:
  6001. Inheriting this class has shown to speed up builds due to
  6002. significantly lower amounts of data stored in the data
  6003. cache as well as on disk.
  6004. Inheriting this class also makes cleanup of
  6005. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  6006. faster, at the expense of being easily able to dive into the
  6007. source code.
  6008. File system maintainers have recommended that the fastest way
  6009. to clean up large numbers of files is to reformat partitions
  6010. rather than delete files due to the linear nature of
  6011. partitions.
  6012. This, of course, assumes you structure the disk partitions and
  6013. file systems in a way that this is practical.
  6014. </para></listitem>
  6015. </itemizedlist>
  6016. Aside from the previous list, you should keep some trade offs in
  6017. mind that can help you speed up the build:
  6018. <itemizedlist>
  6019. <listitem><para>
  6020. Remove items from
  6021. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6022. that you might not need.
  6023. </para></listitem>
  6024. <listitem><para>
  6025. Exclude debug symbols and other debug information:
  6026. If you do not need these symbols and other debug information,
  6027. disabling the <filename>*-dbg</filename> package generation
  6028. can speed up the build.
  6029. You can disable this generation by setting the
  6030. <ulink url='&YOCTO_DOCS_REF_URL;#var-INHIBIT_PACKAGE_DEBUG_SPLIT'><filename>INHIBIT_PACKAGE_DEBUG_SPLIT</filename></ulink>
  6031. variable to "1".
  6032. </para></listitem>
  6033. <listitem><para>
  6034. Disable static library generation for recipes derived from
  6035. <filename>autoconf</filename> or <filename>libtool</filename>:
  6036. Following is an example showing how to disable static
  6037. libraries and still provide an override to handle exceptions:
  6038. <literallayout class='monospaced'>
  6039. STATICLIBCONF = "--disable-static"
  6040. STATICLIBCONF_sqlite3-native = ""
  6041. EXTRA_OECONF += "${STATICLIBCONF}"
  6042. </literallayout>
  6043. <note><title>Notes</title>
  6044. <itemizedlist>
  6045. <listitem><para>
  6046. Some recipes need static libraries in order to work
  6047. correctly (e.g. <filename>pseudo-native</filename>
  6048. needs <filename>sqlite3-native</filename>).
  6049. Overrides, as in the previous example, account for
  6050. these kinds of exceptions.
  6051. </para></listitem>
  6052. <listitem><para>
  6053. Some packages have packaging code that assumes the
  6054. presence of the static libraries.
  6055. If so, you might need to exclude them as well.
  6056. </para></listitem>
  6057. </itemizedlist>
  6058. </note>
  6059. </para></listitem>
  6060. </itemizedlist>
  6061. </para>
  6062. </section>
  6063. <section id="platdev-working-with-libraries">
  6064. <title>Working With Libraries</title>
  6065. <para>
  6066. Libraries are an integral part of your system.
  6067. This section describes some common practices you might find
  6068. helpful when working with libraries to build your system:
  6069. <itemizedlist>
  6070. <listitem><para><link linkend='including-static-library-files'>How to include static library files</link>
  6071. </para></listitem>
  6072. <listitem><para><link linkend='combining-multiple-versions-library-files-into-one-image'>How to use the Multilib feature to combine multiple versions of library files into a single image</link>
  6073. </para></listitem>
  6074. <listitem><para><link linkend='installing-multiple-versions-of-the-same-library'>How to install multiple versions of the same library in parallel on the same system</link>
  6075. </para></listitem>
  6076. </itemizedlist>
  6077. </para>
  6078. <section id='including-static-library-files'>
  6079. <title>Including Static Library Files</title>
  6080. <para>
  6081. If you are building a library and the library offers static linking, you can control
  6082. which static library files (<filename>*.a</filename> files) get included in the
  6083. built library.
  6084. </para>
  6085. <para>
  6086. The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  6087. and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink>
  6088. variables in the
  6089. <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed
  6090. by the <filename>do_install</filename> task are packaged.
  6091. By default, the <filename>PACKAGES</filename> variable includes
  6092. <filename>${PN}-staticdev</filename>, which represents all static library files.
  6093. <note>
  6094. Some previously released versions of the Yocto Project
  6095. defined the static library files through
  6096. <filename>${PN}-dev</filename>.
  6097. </note>
  6098. Following is part of the BitBake configuration file, where
  6099. you can see how the static library files are defined:
  6100. <literallayout class='monospaced'>
  6101. PACKAGE_BEFORE_PN ?= ""
  6102. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  6103. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  6104. FILES = ""
  6105. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  6106. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  6107. ${base_bindir}/* ${base_sbindir}/* \
  6108. ${base_libdir}/*${SOLIBS} \
  6109. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  6110. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  6111. ${datadir}/pixmaps ${datadir}/applications \
  6112. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  6113. ${libdir}/bonobo/servers"
  6114. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  6115. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  6116. ${datadir}/gnome/help"
  6117. SECTION_${PN}-doc = "doc"
  6118. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  6119. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  6120. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  6121. ${datadir}/aclocal ${base_libdir}/*.o \
  6122. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  6123. SECTION_${PN}-dev = "devel"
  6124. ALLOW_EMPTY_${PN}-dev = "1"
  6125. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  6126. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  6127. SECTION_${PN}-staticdev = "devel"
  6128. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  6129. </literallayout>
  6130. </para>
  6131. </section>
  6132. <section id="combining-multiple-versions-library-files-into-one-image">
  6133. <title>Combining Multiple Versions of Library Files into One Image</title>
  6134. <para>
  6135. The build system offers the ability to build libraries with different
  6136. target optimizations or architecture formats and combine these together
  6137. into one system image.
  6138. You can link different binaries in the image
  6139. against the different libraries as needed for specific use cases.
  6140. This feature is called "Multilib."
  6141. </para>
  6142. <para>
  6143. An example would be where you have most of a system compiled in 32-bit
  6144. mode using 32-bit libraries, but you have something large, like a database
  6145. engine, that needs to be a 64-bit application and uses 64-bit libraries.
  6146. Multilib allows you to get the best of both 32-bit and 64-bit libraries.
  6147. </para>
  6148. <para>
  6149. While the Multilib feature is most commonly used for 32 and 64-bit differences,
  6150. the approach the build system uses facilitates different target optimizations.
  6151. You could compile some binaries to use one set of libraries and other binaries
  6152. to use a different set of libraries.
  6153. The libraries could differ in architecture, compiler options, or other
  6154. optimizations.
  6155. </para>
  6156. <para>
  6157. Several examples exist in the
  6158. <filename>meta-skeleton</filename> layer found in the
  6159. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  6160. <itemizedlist>
  6161. <listitem><para><filename>conf/multilib-example.conf</filename>
  6162. configuration file</para></listitem>
  6163. <listitem><para><filename>conf/multilib-example2.conf</filename>
  6164. configuration file</para></listitem>
  6165. <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename>
  6166. recipe</para></listitem>
  6167. </itemizedlist>
  6168. </para>
  6169. <section id='preparing-to-use-multilib'>
  6170. <title>Preparing to Use Multilib</title>
  6171. <para>
  6172. User-specific requirements drive the Multilib feature.
  6173. Consequently, there is no one "out-of-the-box" configuration that likely
  6174. exists to meet your needs.
  6175. </para>
  6176. <para>
  6177. In order to enable Multilib, you first need to ensure your recipe is
  6178. extended to support multiple libraries.
  6179. Many standard recipes are already extended and support multiple libraries.
  6180. You can check in the <filename>meta/conf/multilib.conf</filename>
  6181. configuration file in the
  6182. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> to see how this is
  6183. done using the
  6184. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink>
  6185. variable.
  6186. Eventually, all recipes will be covered and this list will
  6187. not be needed.
  6188. </para>
  6189. <para>
  6190. For the most part, the Multilib class extension works automatically to
  6191. extend the package name from <filename>${PN}</filename> to
  6192. <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename>
  6193. is the particular multilib (e.g. "lib32-" or "lib64-").
  6194. Standard variables such as
  6195. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  6196. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  6197. <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>,
  6198. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  6199. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and
  6200. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink>
  6201. are automatically extended by the system.
  6202. If you are extending any manual code in the recipe, you can use the
  6203. <filename>${MLPREFIX}</filename> variable to ensure those names are extended
  6204. correctly.
  6205. This automatic extension code resides in <filename>multilib.bbclass</filename>.
  6206. </para>
  6207. </section>
  6208. <section id='using-multilib'>
  6209. <title>Using Multilib</title>
  6210. <para>
  6211. After you have set up the recipes, you need to define the actual
  6212. combination of multiple libraries you want to build.
  6213. You accomplish this through your <filename>local.conf</filename>
  6214. configuration file in the
  6215. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6216. An example configuration would be as follows:
  6217. <literallayout class='monospaced'>
  6218. MACHINE = "qemux86-64"
  6219. require conf/multilib.conf
  6220. MULTILIBS = "multilib:lib32"
  6221. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  6222. IMAGE_INSTALL_append = " lib32-glib-2.0"
  6223. </literallayout>
  6224. This example enables an
  6225. additional library named <filename>lib32</filename> alongside the
  6226. normal target packages.
  6227. When combining these "lib32" alternatives, the example uses "x86" for tuning.
  6228. For information on this particular tuning, see
  6229. <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>.
  6230. </para>
  6231. <para>
  6232. The example then includes <filename>lib32-glib-2.0</filename>
  6233. in all the images, which illustrates one method of including a
  6234. multiple library dependency.
  6235. You can use a normal image build to include this dependency,
  6236. for example:
  6237. <literallayout class='monospaced'>
  6238. $ bitbake core-image-sato
  6239. </literallayout>
  6240. You can also build Multilib packages specifically with a command like this:
  6241. <literallayout class='monospaced'>
  6242. $ bitbake lib32-glib-2.0
  6243. </literallayout>
  6244. </para>
  6245. </section>
  6246. <section id='additional-implementation-details'>
  6247. <title>Additional Implementation Details</title>
  6248. <para>
  6249. Generic implementation details as well as details that are
  6250. specific to package management systems exist.
  6251. Following are implementation details that exist regardless
  6252. of the package management system:
  6253. <itemizedlist>
  6254. <listitem><para>The typical convention used for the
  6255. class extension code as used by
  6256. Multilib assumes that all package names specified
  6257. in
  6258. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  6259. that contain <filename>${PN}</filename> have
  6260. <filename>${PN}</filename> at the start of the name.
  6261. When that convention is not followed and
  6262. <filename>${PN}</filename> appears at
  6263. the middle or the end of a name, problems occur.
  6264. </para></listitem>
  6265. <listitem><para>The
  6266. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink>
  6267. value under Multilib will be extended to
  6268. "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>"
  6269. (e.g. "-pokymllib32" for a "lib32" Multilib with
  6270. Poky).
  6271. The reason for this slightly unwieldy contraction
  6272. is that any "-" characters in the vendor
  6273. string presently break Autoconf's
  6274. <filename>config.sub</filename>, and
  6275. other separators are problematic for different
  6276. reasons.
  6277. </para></listitem>
  6278. </itemizedlist>
  6279. </para>
  6280. <para>
  6281. For the RPM Package Management System, the following implementation details
  6282. exist:
  6283. <itemizedlist>
  6284. <listitem><para>A unique architecture is defined for the Multilib packages,
  6285. along with creating a unique deploy folder under
  6286. <filename>tmp/deploy/rpm</filename> in the
  6287. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6288. For example, consider <filename>lib32</filename> in a
  6289. <filename>qemux86-64</filename> image.
  6290. The possible architectures in the system are "all", "qemux86_64",
  6291. "lib32_qemux86_64", and "lib32_x86".</para></listitem>
  6292. <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from
  6293. <filename>${PN}</filename> during RPM packaging.
  6294. The naming for a normal RPM package and a Multilib RPM package in a
  6295. <filename>qemux86-64</filename> system resolves to something similar to
  6296. <filename>bash-4.1-r2.x86_64.rpm</filename> and
  6297. <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively.
  6298. </para></listitem>
  6299. <listitem><para>When installing a Multilib image, the RPM backend first
  6300. installs the base image and then installs the Multilib libraries.
  6301. </para></listitem>
  6302. <listitem><para>The build system relies on RPM to resolve the identical files in the
  6303. two (or more) Multilib packages.</para></listitem>
  6304. </itemizedlist>
  6305. </para>
  6306. <para>
  6307. For the IPK Package Management System, the following implementation details exist:
  6308. <itemizedlist>
  6309. <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from
  6310. <filename>${PN}</filename> during IPK packaging.
  6311. The naming for a normal RPM package and a Multilib IPK package in a
  6312. <filename>qemux86-64</filename> system resolves to something like
  6313. <filename>bash_4.1-r2.x86_64.ipk</filename> and
  6314. <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively.
  6315. </para></listitem>
  6316. <listitem><para>The IPK deploy folder is not modified with
  6317. <filename>${MLPREFIX}</filename> because packages with and without
  6318. the Multilib feature can exist in the same folder due to the
  6319. <filename>${PN}</filename> differences.</para></listitem>
  6320. <listitem><para>IPK defines a sanity check for Multilib installation
  6321. using certain rules for file comparison, overridden, etc.
  6322. </para></listitem>
  6323. </itemizedlist>
  6324. </para>
  6325. </section>
  6326. </section>
  6327. <section id='installing-multiple-versions-of-the-same-library'>
  6328. <title>Installing Multiple Versions of the Same Library</title>
  6329. <para>
  6330. Situations can exist where you need to install and use
  6331. multiple versions of the same library on the same system
  6332. at the same time.
  6333. These situations almost always exist when a library API
  6334. changes and you have multiple pieces of software that
  6335. depend on the separate versions of the library.
  6336. To accommodate these situations, you can install multiple
  6337. versions of the same library in parallel on the same system.
  6338. </para>
  6339. <para>
  6340. The process is straightforward as long as the libraries use
  6341. proper versioning.
  6342. With properly versioned libraries, all you need to do to
  6343. individually specify the libraries is create separate,
  6344. appropriately named recipes where the
  6345. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the
  6346. name includes a portion that differentiates each library version
  6347. (e.g.the major part of the version number).
  6348. Thus, instead of having a single recipe that loads one version
  6349. of a library (e.g. <filename>clutter</filename>), you provide
  6350. multiple recipes that result in different versions
  6351. of the libraries you want.
  6352. As an example, the following two recipes would allow the
  6353. two separate versions of the <filename>clutter</filename>
  6354. library to co-exist on the same system:
  6355. <literallayout class='monospaced'>
  6356. clutter-1.6_1.6.20.bb
  6357. clutter-1.8_1.8.4.bb
  6358. </literallayout>
  6359. Additionally, if you have other recipes that depend on a given
  6360. library, you need to use the
  6361. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  6362. variable to create the dependency.
  6363. Continuing with the same example, if you want to have a recipe
  6364. depend on the 1.8 version of the <filename>clutter</filename>
  6365. library, use the following in your recipe:
  6366. <literallayout class='monospaced'>
  6367. DEPENDS = "clutter-1.8"
  6368. </literallayout>
  6369. </para>
  6370. </section>
  6371. </section>
  6372. <section id='using-x32-psabi'>
  6373. <title>Using x32 psABI</title>
  6374. <para>
  6375. x32 processor-specific Application Binary Interface
  6376. (<ulink url='https://software.intel.com/en-us/node/628948'>x32 psABI</ulink>)
  6377. is a native 32-bit processor-specific ABI for
  6378. <trademark class='registered'>Intel</trademark> 64 (x86-64)
  6379. architectures.
  6380. An ABI defines the calling conventions between functions in a
  6381. processing environment.
  6382. The interface determines what registers are used and what the
  6383. sizes are for various C data types.
  6384. </para>
  6385. <para>
  6386. Some processing environments prefer using 32-bit applications even
  6387. when running on Intel 64-bit platforms.
  6388. Consider the i386 psABI, which is a very old 32-bit ABI for Intel
  6389. 64-bit platforms.
  6390. The i386 psABI does not provide efficient use and access of the
  6391. Intel 64-bit processor resources, leaving the system underutilized.
  6392. Now consider the x86_64 psABI.
  6393. This ABI is newer and uses 64-bits for data sizes and program
  6394. pointers.
  6395. The extra bits increase the footprint size of the programs,
  6396. libraries, and also increases the memory and file system size
  6397. requirements.
  6398. Executing under the x32 psABI enables user programs to utilize CPU
  6399. and system resources more efficiently while keeping the memory
  6400. footprint of the applications low.
  6401. Extra bits are used for registers but not for addressing mechanisms.
  6402. </para>
  6403. <para>
  6404. The Yocto Project supports the final specifications of x32 psABI
  6405. as follows:
  6406. <itemizedlist>
  6407. <listitem><para>
  6408. You can create packages and images in x32 psABI format on
  6409. x86_64 architecture targets.
  6410. </para></listitem>
  6411. <listitem><para>
  6412. You can successfully build recipes with the x32 toolchain.
  6413. </para></listitem>
  6414. <listitem><para>
  6415. You can create and boot
  6416. <filename>core-image-minimal</filename> and
  6417. <filename>core-image-sato</filename> images.
  6418. </para></listitem>
  6419. <listitem><para>
  6420. RPM Package Manager (RPM) support exists for x32 binaries.
  6421. </para></listitem>
  6422. <listitem><para>
  6423. Support for large images exists.
  6424. </para></listitem>
  6425. </itemizedlist>
  6426. </para>
  6427. <para>
  6428. To use the x32 psABI, you need to edit your
  6429. <filename>conf/local.conf</filename> configuration file as
  6430. follows:
  6431. <literallayout class='monospaced'>
  6432. MACHINE = "qemux86-64"
  6433. DEFAULTTUNE = "x86-64-x32"
  6434. baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE', True) \
  6435. or 'INVALID'), True) or 'lib'}"
  6436. </literallayout>
  6437. Once you have set up your configuration file, use BitBake to
  6438. build an image that supports the x32 psABI.
  6439. Here is an example:
  6440. <literallayout class='monospaced'>
  6441. $ bitbake core-image-sato
  6442. </literallayout>
  6443. </para>
  6444. </section>
  6445. <section id='enabling-gobject-introspection-support'>
  6446. <title>Enabling GObject Introspection Support</title>
  6447. <para>
  6448. <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink>
  6449. is the standard mechanism for accessing GObject-based software
  6450. from runtime environments.
  6451. GObject is a feature of the GLib library that provides an object
  6452. framework for the GNOME desktop and related software.
  6453. GObject Introspection adds information to GObject that allows
  6454. objects created within it to be represented across different
  6455. programming languages.
  6456. If you want to construct GStreamer pipelines using Python, or
  6457. control UPnP infrastructure using Javascript and GUPnP,
  6458. GObject introspection is the only way to do it.
  6459. </para>
  6460. <para>
  6461. This section describes the Yocto Project support for generating
  6462. and packaging GObject introspection data.
  6463. GObject introspection data is a description of the
  6464. API provided by libraries built on top of GLib framework,
  6465. and, in particular, that framework's GObject mechanism.
  6466. GObject Introspection Repository (GIR) files go to
  6467. <filename>-dev</filename> packages,
  6468. <filename>typelib</filename> files go to main packages as they
  6469. are packaged together with libraries that are introspected.
  6470. </para>
  6471. <para>
  6472. The data is generated when building such a library, by linking
  6473. the library with a small executable binary that asks the library
  6474. to describe itself, and then executing the binary and
  6475. processing its output.
  6476. </para>
  6477. <para>
  6478. Generating this data in a cross-compilation environment
  6479. is difficult because the library is produced for the target
  6480. architecture, but its code needs to be executed on the build host.
  6481. This problem is solved with the OpenEmbedded build system by
  6482. running the code through QEMU, which allows precisely that.
  6483. Unfortunately, QEMU does not always work perfectly as mentioned
  6484. in the xxx section.
  6485. </para>
  6486. <section id='enabling-the-generation-of-introspection-data'>
  6487. <title>Enabling the Generation of Introspection Data</title>
  6488. <para>
  6489. Enabling the generation of introspection data (GIR files)
  6490. in your library package involves the following:
  6491. <orderedlist>
  6492. <listitem><para>
  6493. Inherit the
  6494. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink>
  6495. class.
  6496. </para></listitem>
  6497. <listitem><para>
  6498. Make sure introspection is not disabled anywhere in
  6499. the recipe or from anything the recipe includes.
  6500. Also, make sure that "gobject-introspection-data" is
  6501. not in
  6502. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  6503. and that "qemu-usermode" is not in
  6504. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  6505. If either of these conditions exist, nothing will
  6506. happen.
  6507. </para></listitem>
  6508. <listitem><para>
  6509. Try to build the recipe.
  6510. If you encounter build errors that look like
  6511. something is unable to find
  6512. <filename>.so</filename> libraries, check where these
  6513. libraries are located in the source tree and add
  6514. the following to the recipe:
  6515. <literallayout class='monospaced'>
  6516. GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs"
  6517. </literallayout>
  6518. <note>
  6519. See recipes in the <filename>oe-core</filename>
  6520. repository that use that
  6521. <filename>GIR_EXTRA_LIBS_PATH</filename> variable
  6522. as an example.
  6523. </note>
  6524. </para></listitem>
  6525. <listitem><para>
  6526. Look for any other errors, which probably mean that
  6527. introspection support in a package is not entirely
  6528. standard, and thus breaks down in a cross-compilation
  6529. environment.
  6530. For such cases, custom-made fixes are needed.
  6531. A good place to ask and receive help in these cases
  6532. is the
  6533. <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>.
  6534. </para></listitem>
  6535. </orderedlist>
  6536. <note>
  6537. Using a library that no longer builds against the latest
  6538. Yocto Project release and prints introspection related
  6539. errors is a good candidate for the previous procedure.
  6540. </note>
  6541. </para>
  6542. </section>
  6543. <section id='disabling-the-generation-of-introspection-data'>
  6544. <title>Disabling the Generation of Introspection Data</title>
  6545. <para>
  6546. You might find that you do not want to generate
  6547. introspection data.
  6548. Or, perhaps QEMU does not work on your build host and
  6549. target architecture combination.
  6550. If so, you can use either of the following methods to
  6551. disable GIR file generations:
  6552. <itemizedlist>
  6553. <listitem><para>
  6554. Add the following to your distro configuration:
  6555. <literallayout class='monospaced'>
  6556. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  6557. </literallayout>
  6558. Adding this statement disables generating
  6559. introspection data using QEMU but will still enable
  6560. building introspection tools and libraries
  6561. (i.e. building them does not require the use of QEMU).
  6562. </para></listitem>
  6563. <listitem><para>
  6564. Add the following to your machine configuration:
  6565. <literallayout class='monospaced'>
  6566. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  6567. </literallayout>
  6568. Adding this statement disables the use of QEMU
  6569. when building packages for your machine.
  6570. Currently, this feature is used only by introspection
  6571. recipes and has the same effect as the previously
  6572. described option.
  6573. <note>
  6574. Future releases of the Yocto Project might have
  6575. other features affected by this option.
  6576. </note>
  6577. </para></listitem>
  6578. </itemizedlist>
  6579. If you disable introspection data, you can still
  6580. obtain it through other means such as copying the data
  6581. from a suitable sysroot, or by generating it on the
  6582. target hardware.
  6583. The OpenEmbedded build system does not currently
  6584. provide specific support for these techniques.
  6585. </para>
  6586. </section>
  6587. <section id='testing-that-introspection-works-in-an-image'>
  6588. <title>Testing that Introspection Works in an Image</title>
  6589. <para>
  6590. Use the following procedure to test if generating
  6591. introspection data is working in an image:
  6592. <orderedlist>
  6593. <listitem><para>
  6594. Make sure that "gobject-introspection-data" is not in
  6595. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  6596. and that "qemu-usermode" is not in
  6597. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  6598. </para></listitem>
  6599. <listitem><para>
  6600. Build <filename>core-image-sato</filename>.
  6601. </para></listitem>
  6602. <listitem><para>
  6603. Launch a Terminal and then start Python in the
  6604. terminal.
  6605. </para></listitem>
  6606. <listitem><para>
  6607. Enter the following in the terminal:
  6608. <literallayout class='monospaced'>
  6609. >>> from gi.repository import GLib
  6610. >>> GLib.get_host_name()
  6611. </literallayout>
  6612. </para></listitem>
  6613. <listitem><para>
  6614. For something a little more advanced, enter the
  6615. following:
  6616. <literallayout class='monospaced'>
  6617. http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
  6618. </literallayout>
  6619. </para></listitem>
  6620. </orderedlist>
  6621. </para>
  6622. </section>
  6623. <section id='known-issues'>
  6624. <title>Known Issues</title>
  6625. <para>
  6626. The following know issues exist for
  6627. GObject Introspection Support:
  6628. <itemizedlist>
  6629. <listitem><para>
  6630. <filename>qemu-ppc64</filename> immediately crashes.
  6631. Consequently, you cannot build introspection data on
  6632. that architecture.
  6633. </para></listitem>
  6634. <listitem><para>
  6635. x32 is not supported by QEMU.
  6636. Consequently, introspection data is disabled.
  6637. </para></listitem>
  6638. <listitem><para>
  6639. musl causes transient GLib binaries to crash on
  6640. assertion failures.
  6641. Consequently, generating introspection data is
  6642. disabled.
  6643. </para></listitem>
  6644. <listitem><para>
  6645. Because QEMU is not able to run the binaries correctly,
  6646. introspection is disabled for some specific packages
  6647. under specific architectures (e.g.
  6648. <filename>gcr</filename>,
  6649. <filename>libsecret</filename>, and
  6650. <filename>webkit</filename>).
  6651. </para></listitem>
  6652. <listitem><para>
  6653. QEMU usermode might not work properly when running
  6654. 64-bit binaries under 32-bit host machines.
  6655. In particular, "qemumips64" is known to not work under
  6656. i686.
  6657. </para></listitem>
  6658. </itemizedlist>
  6659. </para>
  6660. </section>
  6661. </section>
  6662. <section id='dev-optionally-using-an-external-toolchain'>
  6663. <title>Optionally Using an External Toolchain</title>
  6664. <para>
  6665. You might want to use an external toolchain as part of your
  6666. development.
  6667. If this is the case, the fundamental steps you need to accomplish
  6668. are as follows:
  6669. <itemizedlist>
  6670. <listitem><para>
  6671. Understand where the installed toolchain resides.
  6672. For cases where you need to build the external toolchain,
  6673. you would need to take separate steps to build and install
  6674. the toolchain.
  6675. </para></listitem>
  6676. <listitem><para>
  6677. Make sure you add the layer that contains the toolchain to
  6678. your <filename>bblayers.conf</filename> file through the
  6679. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  6680. variable.
  6681. </para></listitem>
  6682. <listitem><para>
  6683. Set the <filename>EXTERNAL_TOOLCHAIN</filename>
  6684. variable in your <filename>local.conf</filename> file
  6685. to the location in which you installed the toolchain.
  6686. </para></listitem>
  6687. </itemizedlist>
  6688. A good example of an external toolchain used with the Yocto Project
  6689. is <trademark class='registered'>Mentor Graphics</trademark>
  6690. Sourcery G++ Toolchain.
  6691. You can see information on how to use that particular layer in the
  6692. <filename>README</filename> file at
  6693. <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
  6694. You can find further information by reading about the
  6695. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
  6696. variable in the Yocto Project Reference Manual's variable glossary.
  6697. </para>
  6698. </section>
  6699. <section id='creating-partitioned-images-using-wic'>
  6700. <title>Creating Partitioned Images Using Wic</title>
  6701. <para>
  6702. Creating an image for a particular hardware target using the
  6703. OpenEmbedded build system does not necessarily mean you can boot
  6704. that image as is on your device.
  6705. Physical devices accept and boot images in various ways depending
  6706. on the specifics of the device.
  6707. Usually, information about the hardware can tell you what image
  6708. format the device requires.
  6709. Should your device require multiple partitions on an SD card, flash,
  6710. or an HDD, you can use the OpenEmbedded Image Creator,
  6711. Wic, to create the properly partitioned image.
  6712. </para>
  6713. <para>
  6714. The <filename>wic</filename> command generates partitioned
  6715. images from existing OpenEmbedded build artifacts.
  6716. Image generation is driven by partitioning commands
  6717. contained in an Openembedded kickstart file
  6718. (<filename>.wks</filename>) specified either directly on
  6719. the command line or as one of a selection of canned
  6720. kickstart files as shown with the
  6721. <filename>wic list images</filename> command in the
  6722. "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>"
  6723. section.
  6724. When you apply the command to a given set of build
  6725. artifacts, the result is an image or set of images that
  6726. can be directly written onto media and used on a particular
  6727. system.
  6728. <note>
  6729. For a kickstart file reference, see the
  6730. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-kickstart'>OpenEmbedded Kickstart (<filename>.wks</filename>) Reference</ulink>"
  6731. Chapter in the Yocto Project Reference Manual.
  6732. </note>
  6733. </para>
  6734. <para>
  6735. The <filename>wic</filename> command and the infrastructure
  6736. it is based on is by definition incomplete.
  6737. The purpose of the command is to allow the generation of
  6738. customized images, and as such, was designed to be
  6739. completely extensible through a plug-in interface.
  6740. See the
  6741. "<link linkend='wic-using-the-wic-plug-ins-interface'>Using the Wic Plug-Ins Interface</link>"
  6742. section for information on these plug-ins.
  6743. </para>
  6744. <para>
  6745. This section provides some background information on Wic,
  6746. describes what you need to have in
  6747. place to run the tool, provides instruction on how to use
  6748. the Wic utility, provides information on using the Wic plug-ins
  6749. interface, and provides several examples that show how to use
  6750. Wic.
  6751. </para>
  6752. <section id='wic-background'>
  6753. <title>Background</title>
  6754. <para>
  6755. This section provides some background on the Wic utility.
  6756. While none of this information is required to use
  6757. Wic, you might find it interesting.
  6758. <itemizedlist>
  6759. <listitem><para>
  6760. The name "Wic" is derived from OpenEmbedded
  6761. Image Creator (oeic).
  6762. The "oe" diphthong in "oeic" was promoted to the
  6763. letter "w", because "oeic" is both difficult to
  6764. remember and to pronounce.
  6765. </para></listitem>
  6766. <listitem><para>
  6767. Wic is loosely based on the
  6768. Meego Image Creator (<filename>mic</filename>)
  6769. framework.
  6770. The Wic implementation has been
  6771. heavily modified to make direct use of OpenEmbedded
  6772. build artifacts instead of package installation and
  6773. configuration, which are already incorporated within
  6774. the OpenEmbedded artifacts.
  6775. </para></listitem>
  6776. <listitem><para>
  6777. Wic is a completely independent
  6778. standalone utility that initially provides
  6779. easier-to-use and more flexible replacements for an
  6780. existing functionality in OE-Core's
  6781. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink>
  6782. class.
  6783. The difference between Wic and those examples is
  6784. that with Wic the functionality of those scripts is
  6785. implemented by a general-purpose partitioning language,
  6786. which is based on Redhat kickstart syntax.
  6787. </para></listitem>
  6788. </itemizedlist>
  6789. </para>
  6790. </section>
  6791. <section id='wic-requirements'>
  6792. <title>Requirements</title>
  6793. <para>
  6794. In order to use the Wic utility with the OpenEmbedded Build
  6795. system, your system needs to meet the following
  6796. requirements:
  6797. <itemizedlist>
  6798. <listitem><para>
  6799. The Linux distribution on your development host must
  6800. support the Yocto Project.
  6801. See the
  6802. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  6803. section in the Yocto Project Reference Manual for
  6804. the list of distributions that support the
  6805. Yocto Project.
  6806. </para></listitem>
  6807. <listitem><para>
  6808. The standard system utilities, such as
  6809. <filename>cp</filename>, must be installed on your
  6810. development host system.
  6811. </para></listitem>
  6812. <listitem><para>
  6813. You must have sourced the build environment
  6814. setup script (i.e.
  6815. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  6816. found in the
  6817. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6818. </para></listitem>
  6819. <listitem><para>
  6820. You need to have the build artifacts already
  6821. available, which typically means that you must
  6822. have already created an image using the
  6823. Openembedded build system (e.g.
  6824. <filename>core-image-minimal</filename>).
  6825. While it might seem redundant to generate an image
  6826. in order to create an image using
  6827. Wic, the current version of
  6828. Wic requires the artifacts
  6829. in the form generated by the OpenEmbedded build
  6830. system.
  6831. </para></listitem>
  6832. <listitem><para>
  6833. You must build several native tools, which are
  6834. built to run on the build system:
  6835. <literallayout class='monospaced'>
  6836. $ bitbake parted-native dosfstools-native mtools-native
  6837. </literallayout>
  6838. </para></listitem>
  6839. <listitem><para>
  6840. Include "wic" as part of the
  6841. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  6842. variable.
  6843. </para></listitem>
  6844. <listitem><para>
  6845. Include the name of the
  6846. <ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>wic kickstart file</ulink>
  6847. as part of the
  6848. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink>
  6849. variable
  6850. </para></listitem>
  6851. </itemizedlist>
  6852. </para>
  6853. </section>
  6854. <section id='wic-getting-help'>
  6855. <title>Getting Help</title>
  6856. <para>
  6857. You can get general help for the <filename>wic</filename>
  6858. command by entering the <filename>wic</filename> command
  6859. by itself or by entering the command with a help argument
  6860. as follows:
  6861. <literallayout class='monospaced'>
  6862. $ wic -h
  6863. $ wic --help
  6864. $ wic help
  6865. </literallayout>
  6866. </para>
  6867. <para>
  6868. Currently, Wic supports seven commands:
  6869. <filename>cp</filename>, <filename>create</filename>,
  6870. <filename>help</filename>, <filename>list</filename>,
  6871. <filename>ls</filename>, <filename>rm</filename>, and
  6872. <filename>write</filename>.
  6873. You can get help for all these commands except "help" by
  6874. using the following form:
  6875. <literallayout class='monospaced'>
  6876. $ wic help <replaceable>command</replaceable>
  6877. </literallayout>
  6878. For example, the following command returns help for the
  6879. <filename>write</filename> command:
  6880. <literallayout class='monospaced'>
  6881. $ wic help write
  6882. </literallayout>
  6883. </para>
  6884. <para>
  6885. Wic supports help for three topics:
  6886. <filename>overview</filename>,
  6887. <filename>plugins</filename>, and
  6888. <filename>kickstart</filename>.
  6889. You can get help for any topic using the following form:
  6890. <literallayout class='monospaced'>
  6891. $ wic help <replaceable>topic</replaceable>
  6892. </literallayout>
  6893. For example, the following returns overview help for Wic:
  6894. <literallayout class='monospaced'>
  6895. $ wic help overview
  6896. </literallayout>
  6897. </para>
  6898. <para>
  6899. One additional level of help exists for Wic.
  6900. You can get help on individual images through the
  6901. <filename>list</filename> command.
  6902. You can use the <filename>list</filename> command to return the
  6903. available Wic images as follows:
  6904. <literallayout class='monospaced'>
  6905. $ wic list images
  6906. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  6907. genericx86 Create an EFI disk image for genericx86*
  6908. beaglebone-yocto Create SD card image for Beaglebone
  6909. edgerouter Create SD card image for Edgerouter
  6910. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  6911. directdisk-gpt Create a 'pcbios' direct disk image
  6912. mkefidisk Create an EFI disk image
  6913. directdisk Create a 'pcbios' direct disk image
  6914. systemd-bootdisk Create an EFI disk image with systemd-boot
  6915. mkhybridiso Create a hybrid ISO image
  6916. sdimage-bootpart Create SD card image with a boot partition
  6917. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  6918. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  6919. </literallayout>
  6920. Once you know the list of available Wic images, you can use
  6921. <filename>help</filename> with the command to get help on a
  6922. particular image.
  6923. For example, the following command returns help on the
  6924. "beaglebone-yocto" image:
  6925. <literallayout class='monospaced'>
  6926. $ wic list beaglebone-yocto help
  6927. Creates a partitioned SD card image for Beaglebone.
  6928. Boot files are located in the first vfat partition.
  6929. </literallayout>
  6930. </para>
  6931. </section>
  6932. <section id='operational-modes'>
  6933. <title>Operational Modes</title>
  6934. <para>
  6935. You can use Wic in two different
  6936. modes, depending on how much control you need for
  6937. specifying the Openembedded build artifacts that are
  6938. used for creating the image: Raw and Cooked:
  6939. <itemizedlist>
  6940. <listitem><para>
  6941. <emphasis>Raw Mode:</emphasis>
  6942. You explicitly specify build artifacts through
  6943. Wic command-line arguments.
  6944. </para></listitem>
  6945. <listitem><para>
  6946. <emphasis>Cooked Mode:</emphasis>
  6947. The current
  6948. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6949. setting and image name are used to automatically
  6950. locate and provide the build artifacts.
  6951. You just supply a kickstart file and the name
  6952. of the image from which to use artifacts.
  6953. </para></listitem>
  6954. </itemizedlist>
  6955. </para>
  6956. <para>
  6957. Regardless of the mode you use, you need to have the build
  6958. artifacts ready and available.
  6959. </para>
  6960. <section id='raw-mode'>
  6961. <title>Raw Mode</title>
  6962. <para>
  6963. Running Wic in raw mode allows you to specify all the
  6964. partitions through the <filename>wic</filename>
  6965. command line.
  6966. The primary use for raw mode is if you have built
  6967. your kernel outside of the Yocto Project
  6968. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6969. In other words, you can point to arbitrary kernel,
  6970. root filesystem locations, and so forth.
  6971. Contrast this behavior with cooked mode where Wic
  6972. looks in the Build Directory (e.g.
  6973. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>).
  6974. </para>
  6975. <para>
  6976. The general form of the
  6977. <filename>wic</filename> command in raw mode is:
  6978. <literallayout class='monospaced'>
  6979. $ wic create <replaceable>wks_file</replaceable> <replaceable>options</replaceable> ...
  6980. Where:
  6981. <replaceable>wks_file</replaceable>:
  6982. An OpenEmbedded kickstart file. You can provide
  6983. your own custom file or use a file from a set of
  6984. existing files as described by further options.
  6985. optional arguments:
  6986. -h, --help show this help message and exit
  6987. -o <replaceable>OUTDIR</replaceable>, --outdir <replaceable>OUTDIR</replaceable>
  6988. name of directory to create image in
  6989. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  6990. name of the image to use the artifacts from e.g. core-
  6991. image-sato
  6992. -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir <replaceable>ROOTFS_DIR</replaceable>
  6993. path to the /rootfs dir to use as the .wks rootfs
  6994. source
  6995. -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir <replaceable>BOOTIMG_DIR</replaceable>
  6996. path to the dir containing the boot artifacts (e.g.
  6997. /EFI or /syslinux dirs) to use as the .wks bootimg
  6998. source
  6999. -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir <replaceable>KERNEL_DIR</replaceable>
  7000. path to the dir containing the kernel to use in the
  7001. .wks bootimg
  7002. -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot <replaceable>NATIVE_SYSROOT</replaceable>
  7003. path to the native sysroot containing the tools to use
  7004. to build the image
  7005. -s, --skip-build-check
  7006. skip the build check
  7007. -f, --build-rootfs build rootfs
  7008. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  7009. compress image with specified compressor
  7010. -m, --bmap generate .bmap
  7011. --no-fstab-update Do not change fstab file.
  7012. -v <replaceable>VARS_DIR</replaceable>, --vars <replaceable>VARS_DIR</replaceable>
  7013. directory with &lt;image&gt;.env files that store bitbake
  7014. variables
  7015. -D, --debug output debug information
  7016. </literallayout>
  7017. <note>
  7018. You do not need root privileges to run
  7019. Wic.
  7020. In fact, you should not run as root when using the
  7021. utility.
  7022. </note>
  7023. </para>
  7024. </section>
  7025. <section id='cooked-mode'>
  7026. <title>Cooked Mode</title>
  7027. <para>
  7028. Running Wic in cooked mode leverages off artifacts in
  7029. the Build Directory.
  7030. In other words, you do not have to specify kernel or
  7031. root filesystem locations as part of the command.
  7032. All you need to provide is a kickstart file and the
  7033. name of the image from which to use artifacts by using
  7034. the "-e" option.
  7035. Wic looks in the Build Directory (e.g.
  7036. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>)
  7037. for artifacts.
  7038. </para>
  7039. <para>
  7040. The general form of the <filename>wic</filename>
  7041. command using Cooked Mode is as follows:
  7042. <literallayout class='monospaced'>
  7043. $ wic create <replaceable>wks_file</replaceable> -e <replaceable>IMAGE_NAME</replaceable>
  7044. Where:
  7045. <replaceable>wks_file</replaceable>:
  7046. An OpenEmbedded kickstart file. You can provide
  7047. your own custom file or use a file from a set of
  7048. existing files provided with the Yocto Project
  7049. release.
  7050. required argument:
  7051. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  7052. name of the image to use the artifacts from e.g. core-
  7053. image-sato
  7054. </literallayout>
  7055. </para>
  7056. </section>
  7057. </section>
  7058. <section id='using-a-provided-kickstart-file'>
  7059. <title>Using an Existing Kickstart File</title>
  7060. <para>
  7061. If you do not want to create your own kickstart file, you
  7062. can use an existing file provided by the Wic installation.
  7063. As shipped, kickstart files can be found in the
  7064. Yocto Project
  7065. <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink>
  7066. in the following two locations:
  7067. <literallayout class='monospaced'>
  7068. poky/meta-yocto-bsp/wic
  7069. poky/scripts/lib/wic/canned-wks
  7070. </literallayout>
  7071. Use the following command to list the available kickstart
  7072. files:
  7073. <literallayout class='monospaced'>
  7074. $ wic list images
  7075. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  7076. genericx86 Create an EFI disk image for genericx86*
  7077. beaglebone-yocto Create SD card image for Beaglebone
  7078. edgerouter Create SD card image for Edgerouter
  7079. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  7080. directdisk-gpt Create a 'pcbios' direct disk image
  7081. mkefidisk Create an EFI disk image
  7082. directdisk Create a 'pcbios' direct disk image
  7083. systemd-bootdisk Create an EFI disk image with systemd-boot
  7084. mkhybridiso Create a hybrid ISO image
  7085. sdimage-bootpart Create SD card image with a boot partition
  7086. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  7087. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  7088. </literallayout>
  7089. When you use an existing file, you do not have to use the
  7090. <filename>.wks</filename> extension.
  7091. Here is an example in Raw Mode that uses the
  7092. <filename>directdisk</filename> file:
  7093. <literallayout class='monospaced'>
  7094. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  7095. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  7096. </literallayout>
  7097. </para>
  7098. <para>
  7099. Here are the actual partition language commands
  7100. used in the <filename>genericx86.wks</filename> file to
  7101. generate an image:
  7102. <literallayout class='monospaced'>
  7103. # short-description: Create an EFI disk image for genericx86*
  7104. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  7105. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  7106. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  7107. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  7108. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  7109. </literallayout>
  7110. </para>
  7111. </section>
  7112. <section id='wic-using-the-wic-plug-ins-interface'>
  7113. <title>Using the Wic Plug-Ins Interface</title>
  7114. <para>
  7115. You can extend and specialize Wic functionality by using
  7116. Wic plug-ins.
  7117. This section explains the Wic plug-in interface.
  7118. <note>
  7119. Wic plug-ins consist of "source" and "imager" plug-ins.
  7120. Imager plug-ins are beyond the scope of this section.
  7121. </note>
  7122. </para>
  7123. <para>
  7124. Source plug-ins provide a mechanism to customize partition
  7125. content during the Wic image generation process.
  7126. You can use source plug-ins to map values that you specify
  7127. using <filename>--source</filename> commands in kickstart
  7128. files (i.e. <filename>*.wks</filename>) to a plug-in
  7129. implementation used to populate a given partition.
  7130. <note>
  7131. If you use plug-ins that have build-time dependencies
  7132. (e.g. native tools, bootloaders, and so forth)
  7133. when building a Wic image, you need to specify those
  7134. dependencies using the
  7135. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink>
  7136. variable.
  7137. </note>
  7138. </para>
  7139. <para>
  7140. Source plug-ins are subclasses defined in plug-in files.
  7141. As shipped, the Yocto Project provides several plug-in
  7142. files.
  7143. You can see the source plug-in files that ship with the
  7144. Yocto Project
  7145. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>.
  7146. Each of these plug-in files contains source plug-ins that
  7147. are designed to populate a specific Wic image partition.
  7148. </para>
  7149. <para>
  7150. Source plug-ins are subclasses of the
  7151. <filename>SourcePlugin</filename> class, which is
  7152. defined in the
  7153. <filename>poky/scripts/lib/wic/pluginbase.py</filename>
  7154. file.
  7155. For example, the <filename>BootimgEFIPlugin</filename>
  7156. source plug-in found in the
  7157. <filename>bootimg-efi.py</filename> file is a subclass of
  7158. the <filename>SourcePlugin</filename> class, which is found
  7159. in the <filename>pluginbase.py</filename> file.
  7160. </para>
  7161. <para>
  7162. You can also implement source plug-ins in a layer outside
  7163. of the Source Repositories (external layer).
  7164. To do so, be sure that your plug-in files are located in
  7165. a directory whose path is
  7166. <filename>scripts/lib/wic/plugins/source/</filename>
  7167. within your external layer.
  7168. When the plug-in files are located there, the source
  7169. plug-ins they contain are made available to Wic.
  7170. </para>
  7171. <para>
  7172. When the Wic implementation needs to invoke a
  7173. partition-specific implementation, it looks for the plug-in
  7174. with the same name as the <filename>--source</filename>
  7175. parameter used in the kickstart file given to that
  7176. partition.
  7177. For example, if the partition is set up using the following
  7178. command in a kickstart file:
  7179. <literallayout class='monospaced'>
  7180. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  7181. </literallayout>
  7182. The methods defined as class members of the matching
  7183. source plug-in (i.e. <filename>bootimg-pcbios</filename>)
  7184. in the <filename>bootimg-pcbios.py</filename> plug-in file
  7185. are used.
  7186. </para>
  7187. <para>
  7188. To be more concrete, here is the corresponding plug-in
  7189. definition from the <filename>bootimg-pcbios.py</filename>
  7190. file for the previous command along with an example
  7191. method called by the Wic implementation when it needs to
  7192. prepare a partition using an implementation-specific
  7193. function:
  7194. <literallayout class='monospaced'>
  7195. .
  7196. .
  7197. .
  7198. class BootimgPcbiosPlugin(SourcePlugin):
  7199. """
  7200. Create MBR boot partition and install syslinux on it.
  7201. """
  7202. name = 'bootimg-pcbios'
  7203. .
  7204. .
  7205. .
  7206. @classmethod
  7207. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  7208. oe_builddir, bootimg_dir, kernel_dir,
  7209. rootfs_dir, native_sysroot):
  7210. """
  7211. Called to do the actual content population for a partition i.e. it
  7212. 'prepares' the partition to be incorporated into the image.
  7213. In this case, prepare content for legacy bios boot partition.
  7214. """
  7215. .
  7216. .
  7217. .
  7218. </literallayout>
  7219. If a subclass (plug-in) itself does not implement a
  7220. particular function, Wic locates and uses the default
  7221. version in the superclass.
  7222. It is for this reason that all source plug-ins are derived
  7223. from the <filename>SourcePlugin</filename> class.
  7224. </para>
  7225. <para>
  7226. The <filename>SourcePlugin</filename> class defined in
  7227. the <filename>pluginbase.py</filename> file defines
  7228. a set of methods that source plug-ins can implement or
  7229. override.
  7230. Any plug-ins (subclass of
  7231. <filename>SourcePlugin</filename>) that do not implement
  7232. a particular method inherit the implementation of the
  7233. method from the <filename>SourcePlugin</filename> class.
  7234. For more information, see the
  7235. <filename>SourcePlugin</filename> class in the
  7236. <filename>pluginbase.py</filename> file for details:
  7237. </para>
  7238. <para>
  7239. The following list describes the methods implemented in the
  7240. <filename>SourcePlugin</filename> class:
  7241. <itemizedlist>
  7242. <listitem><para>
  7243. <emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  7244. Called to populate a partition with actual content.
  7245. In other words, the method prepares the final
  7246. partition image that is incorporated into the
  7247. disk image.
  7248. </para></listitem>
  7249. <listitem><para>
  7250. <emphasis><filename>do_configure_partition()</filename>:</emphasis>
  7251. Called before
  7252. <filename>do_prepare_partition()</filename> to
  7253. create custom configuration files for a partition
  7254. (e.g. syslinux or grub configuration files).
  7255. </para></listitem>
  7256. <listitem><para>
  7257. <emphasis><filename>do_install_disk()</filename>:</emphasis>
  7258. Called after all partitions have been prepared and
  7259. assembled into a disk image.
  7260. This method provides a hook to allow finalization
  7261. of a disk image (e.g. writing an MBR).
  7262. </para></listitem>
  7263. <listitem><para>
  7264. <emphasis><filename>do_stage_partition()</filename>:</emphasis>
  7265. Special content-staging hook called before
  7266. <filename>do_prepare_partition()</filename>.
  7267. This method is normally empty.</para>
  7268. <para>Typically, a partition just uses the passed-in
  7269. parameters (e.g. the unmodified value of
  7270. <filename>bootimg_dir</filename>).
  7271. However, in some cases, things might need to be
  7272. more tailored.
  7273. As an example, certain files might additionally
  7274. need to be taken from
  7275. <filename>bootimg_dir + /boot</filename>.
  7276. This hook allows those files to be staged in a
  7277. customized fashion.
  7278. <note>
  7279. <filename>get_bitbake_var()</filename>
  7280. allows you to access non-standard variables
  7281. that you might want to use for this
  7282. behavior.
  7283. </note>
  7284. </para></listitem>
  7285. </itemizedlist>
  7286. </para>
  7287. <para>
  7288. You can extend the source plug-in mechanism.
  7289. To add more hooks, create more source plug-in methods
  7290. within <filename>SourcePlugin</filename> and the
  7291. corresponding derived subclasses.
  7292. The code that calls the plug-in methods uses the
  7293. <filename>plugin.get_source_plugin_methods()</filename>
  7294. function to find the method or methods needed by the call.
  7295. Retrieval of those methods is accomplished by filling up
  7296. a dict with keys that contain the method names of interest.
  7297. On success, these will be filled in with the actual
  7298. methods.
  7299. See the Wic implementation for examples and details.
  7300. </para>
  7301. </section>
  7302. <section id='wic-usage-examples'>
  7303. <title>Examples</title>
  7304. <para>
  7305. This section provides several examples that show how to use
  7306. the Wic utility.
  7307. All the examples assume the list of requirements in the
  7308. "<link linkend='wic-requirements'>Requirements</link>"
  7309. section have been met.
  7310. The examples assume the previously generated image is
  7311. <filename>core-image-minimal</filename>.
  7312. </para>
  7313. <section id='generate-an-image-using-a-provided-kickstart-file'>
  7314. <title>Generate an Image using an Existing Kickstart File</title>
  7315. <para>
  7316. This example runs in Cooked Mode and uses the
  7317. <filename>mkefidisk</filename> kickstart file:
  7318. <literallayout class='monospaced'>
  7319. $ wic create mkefidisk -e core-image-minimal
  7320. INFO: Building wic-tools...
  7321. .
  7322. .
  7323. .
  7324. INFO: The new image(s) can be found here:
  7325. ./mkefidisk-201804191017-sda.direct
  7326. The following build artifacts were used to create the image(s):
  7327. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  7328. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  7329. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  7330. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7331. INFO: The image(s) were created using OE kickstart file:
  7332. /home/stephano/build/master/openembedded-core/scripts/lib/wic/canned-wks/mkefidisk.wks
  7333. </literallayout>
  7334. The previous example shows the easiest way to create
  7335. an image by running in cooked mode and supplying
  7336. a kickstart file and the "-e" option to point to the
  7337. existing build artifacts.
  7338. Your <filename>local.conf</filename> file needs to have
  7339. the
  7340. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7341. variable set to the machine you are using, which is
  7342. "qemux86" in this example.
  7343. </para>
  7344. <para>
  7345. Once the image builds, the output provides image
  7346. location, artifact use, and kickstart file information.
  7347. <note>
  7348. You should always verify the details provided in the
  7349. output to make sure that the image was indeed
  7350. created exactly as expected.
  7351. </note>
  7352. </para>
  7353. <para>
  7354. Continuing with the example, you can now write the
  7355. image from the Build Directory onto a USB stick, or
  7356. whatever media for which you built your image, and boot
  7357. from the media.
  7358. You can write the image by using
  7359. <filename>bmaptool</filename> or
  7360. <filename>dd</filename>:
  7361. <literallayout class='monospaced'>
  7362. $ oe-run-native bmaptool copy mkefidisk-201804191017-sda.direct /dev/sd<replaceable>X</replaceable>
  7363. </literallayout>
  7364. or
  7365. <literallayout class='monospaced'>
  7366. $ sudo dd if=mkefidisk-201804191017-sda.direct of=/dev/sd<replaceable>X</replaceable>
  7367. </literallayout>
  7368. <note>
  7369. For more information on how to use the
  7370. <filename>bmaptool</filename> to flash a device
  7371. with an image, see the
  7372. "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>"
  7373. section.
  7374. </note>
  7375. </para>
  7376. </section>
  7377. <section id='using-a-modified-kickstart-file'>
  7378. <title>Using a Modified Kickstart File</title>
  7379. <para>
  7380. Because partitioned image creation is driven by the
  7381. kickstart file, it is easy to affect image creation by
  7382. changing the parameters in the file.
  7383. This next example demonstrates that through modification
  7384. of the <filename>directdisk-gpt</filename> kickstart
  7385. file.
  7386. </para>
  7387. <para>
  7388. As mentioned earlier, you can use the command
  7389. <filename>wic list images</filename> to show the list
  7390. of existing kickstart files.
  7391. The directory in which the
  7392. <filename>directdisk-gpt.wks</filename> file resides is
  7393. <filename>scripts/lib/image/canned-wks/</filename>,
  7394. which is located in the
  7395. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  7396. (e.g. <filename>poky</filename>).
  7397. Because available files reside in this directory,
  7398. you can create and add your own custom files to the
  7399. directory.
  7400. Subsequent use of the
  7401. <filename>wic list images</filename> command would then
  7402. include your kickstart files.
  7403. </para>
  7404. <para>
  7405. In this example, the existing
  7406. <filename>directdisk-gpt</filename> file already does
  7407. most of what is needed.
  7408. However, for the hardware in this example, the image
  7409. will need to boot from <filename>sdb</filename> instead
  7410. of <filename>sda</filename>, which is what the
  7411. <filename>directdisk-gpt</filename> kickstart file
  7412. uses.
  7413. </para>
  7414. <para>
  7415. The example begins by making a copy of the
  7416. <filename>directdisk-gpt.wks</filename> file in the
  7417. <filename>scripts/lib/image/canned-wks</filename>
  7418. directory and then by changing the lines that specify
  7419. the target disk from which to boot.
  7420. <literallayout class='monospaced'>
  7421. $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  7422. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  7423. </literallayout>
  7424. Next, the example modifies the
  7425. <filename>directdisksdb-gpt.wks</filename> file and
  7426. changes all instances of
  7427. "<filename>--ondisk sda</filename>" to
  7428. "<filename>--ondisk sdb</filename>".
  7429. The example changes the following two lines and leaves
  7430. the remaining lines untouched:
  7431. <literallayout class='monospaced'>
  7432. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  7433. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  7434. </literallayout>
  7435. Once the lines are changed, the example generates the
  7436. <filename>directdisksdb-gpt</filename> image.
  7437. The command points the process at the
  7438. <filename>core-image-minimal</filename> artifacts for
  7439. the Next Unit of Computing (nuc)
  7440. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7441. the <filename>local.conf</filename>.
  7442. <literallayout class='monospaced'>
  7443. $ wic create directdisksdb-gpt -e core-image-minimal
  7444. INFO: Building wic-tools...
  7445. .
  7446. .
  7447. .
  7448. Initialising tasks: 100% |#######################################| Time: 0:00:01
  7449. NOTE: Executing SetScene Tasks
  7450. NOTE: Executing RunQueue Tasks
  7451. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  7452. INFO: Creating image(s)...
  7453. INFO: The new image(s) can be found here:
  7454. ./directdisksdb-gpt-201710090938-sdb.direct
  7455. The following build artifacts were used to create the image(s):
  7456. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  7457. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  7458. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  7459. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7460. INFO: The image(s) were created using OE kickstart file:
  7461. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  7462. </literallayout>
  7463. Continuing with the example, you can now directly
  7464. <filename>dd</filename> the image to a USB stick, or
  7465. whatever media for which you built your image,
  7466. and boot the resulting media:
  7467. <literallayout class='monospaced'>
  7468. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  7469. 140966+0 records in
  7470. 140966+0 records out
  7471. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  7472. $ sudo eject /dev/sdb
  7473. </literallayout>
  7474. </para>
  7475. </section>
  7476. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  7477. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  7478. <para>
  7479. This next example manually specifies each build artifact
  7480. (runs in Raw Mode) and uses a modified kickstart file.
  7481. The example also uses the <filename>-o</filename> option
  7482. to cause Wic to create the output
  7483. somewhere other than the default output directory,
  7484. which is the current directory:
  7485. <literallayout class='monospaced'>
  7486. $ wic create /home/stephano/my_yocto/test.wks -o /home/stephano/testwic \
  7487. --rootfs-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  7488. --bootimg-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  7489. --kernel-dir /home/stephano/build/master/build/tmp/deploy/images/qemux86 \
  7490. --native-sysroot /home/stephano/build/master/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7491. INFO: Creating image(s)...
  7492. INFO: The new image(s) can be found here:
  7493. /home/stephano/testwic/test-201710091445-sdb.direct
  7494. The following build artifacts were used to create the image(s):
  7495. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  7496. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  7497. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  7498. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7499. INFO: The image(s) were created using OE kickstart file:
  7500. /home/stephano/my_yocto/test.wks
  7501. </literallayout>
  7502. For this example,
  7503. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7504. did not have to be specified in the
  7505. <filename>local.conf</filename> file since the
  7506. artifact is manually specified.
  7507. </para>
  7508. </section>
  7509. <section id='using-wic-to-manipulate-an-image'>
  7510. <title>Using Wic to Manipulate an Image</title>
  7511. <para>
  7512. Wic image manipulation allows you to shorten turnaround
  7513. time during image development.
  7514. For example, you can use Wic to delete the kernel partition
  7515. of a Wic image and then insert a newly built kernel.
  7516. This saves you time from having to rebuild the entire image
  7517. each time you modify the kernel.
  7518. <note>
  7519. In order to use Wic to manipulate a Wic image as in
  7520. this example, your development machine must have the
  7521. <filename>mtools</filename> package installed.
  7522. </note>
  7523. </para>
  7524. <para>
  7525. The following example examines the contents of the Wic
  7526. image, deletes the existing kernel, and then inserts a
  7527. new kernel:
  7528. <orderedlist>
  7529. <listitem><para>
  7530. <emphasis>List the Partitions:</emphasis>
  7531. Use the <filename>wic ls</filename> command to list
  7532. all the partitions in the Wic image:
  7533. <literallayout class='monospaced'>
  7534. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  7535. Num Start End Size Fstype
  7536. 1 1048576 25041919 23993344 fat16
  7537. 2 25165824 72157183 46991360 ext4
  7538. </literallayout>
  7539. The previous output shows two partitions in the
  7540. <filename>core-image-minimal-qemux86.wic</filename>
  7541. image.
  7542. </para></listitem>
  7543. <listitem><para>
  7544. <emphasis>Examine a Particular Partition:</emphasis>
  7545. Use the <filename>wic ls</filename> command again
  7546. but in a different form to examine a particular
  7547. partition.
  7548. <note>
  7549. You can get command usage on any Wic command
  7550. using the following form:
  7551. <literallayout class='monospaced'>
  7552. $ wic help <replaceable>command</replaceable>
  7553. </literallayout>
  7554. For example, the following command shows you
  7555. the various ways to use the
  7556. <filename>wic ls</filename> command:
  7557. <literallayout class='monospaced'>
  7558. $ wic help ls
  7559. </literallayout>
  7560. </note>
  7561. The following command shows what is in Partition
  7562. one:
  7563. <literallayout class='monospaced'>
  7564. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  7565. Volume in drive : is boot
  7566. Volume Serial Number is E894-1809
  7567. Directory for ::/
  7568. libcom32 c32 186500 2017-10-09 16:06
  7569. libutil c32 24148 2017-10-09 16:06
  7570. syslinux cfg 220 2017-10-09 16:06
  7571. vesamenu c32 27104 2017-10-09 16:06
  7572. vmlinuz 6904608 2017-10-09 16:06
  7573. 5 files 7 142 580 bytes
  7574. 16 582 656 bytes free
  7575. </literallayout>
  7576. The previous output shows five files, with the
  7577. <filename>vmlinuz</filename> being the kernel.
  7578. <note>
  7579. If you see the following error, you need to
  7580. update or create a
  7581. <filename>~/.mtoolsrc</filename> file and
  7582. be sure to have the line “mtools_skip_check=1“
  7583. in the file.
  7584. Then, run the Wic command again:
  7585. <literallayout class='monospaced'>
  7586. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  7587. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  7588. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  7589. </literallayout>
  7590. </note>
  7591. </para></listitem>
  7592. <listitem><para>
  7593. <emphasis>Remove the Old Kernel:</emphasis>
  7594. Use the <filename>wic rm</filename> command to
  7595. remove the <filename>vmlinuz</filename> file
  7596. (kernel):
  7597. <literallayout class='monospaced'>
  7598. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  7599. </literallayout>
  7600. </para></listitem>
  7601. <listitem><para>
  7602. <emphasis>Add In the New Kernel:</emphasis>
  7603. Use the <filename>wic cp</filename> command to
  7604. add the updated kernel to the Wic image.
  7605. Depending on how you built your kernel, it could
  7606. be in different places.
  7607. If you used <filename>devtool</filename> and
  7608. an SDK to build your kernel, it resides in the
  7609. <filename>tmp/work</filename> directory of the
  7610. extensible SDK.
  7611. If you used <filename>make</filename> to build the
  7612. kernel, the kernel will be in the
  7613. <filename>workspace/sources</filename> area.
  7614. </para>
  7615. <para>The following example assumes
  7616. <filename>devtool</filename> was used to build
  7617. the kernel:
  7618. <literallayout class='monospaced'>
  7619. 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 \
  7620. ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  7621. </literallayout>
  7622. Once the new kernel is added back into the image,
  7623. you can use the <filename>dd</filename>
  7624. command or
  7625. <link linkend='flashing-images-using-bmaptool'><filename>bmaptool</filename></link>
  7626. to flash your wic image onto an SD card
  7627. or USB stick and test your target.
  7628. <note>
  7629. Using <filename>bmaptool</filename> is
  7630. generally 10 to 20 times faster than using
  7631. <filename>dd</filename>.
  7632. </note>
  7633. </para></listitem>
  7634. </orderedlist>
  7635. </para>
  7636. </section>
  7637. </section>
  7638. </section>
  7639. <section id='flashing-images-using-bmaptool'>
  7640. <title>Flashing Images Using <filename>bmaptool</filename></title>
  7641. <para>
  7642. A fast and easy way to flash an image to a bootable device
  7643. is to use Bmaptool, which is integrated into the OpenEmbedded
  7644. build system.
  7645. Bmaptool is a generic tool that creates a file's block map (bmap)
  7646. and then uses that map to copy the file.
  7647. As compared to traditional tools such as dd or cp, Bmaptool
  7648. can copy (or flash) large files like raw system image files
  7649. much faster.
  7650. <note><title>Notes</title>
  7651. <itemizedlist>
  7652. <listitem><para>
  7653. If you are using Ubuntu or Debian distributions, you
  7654. can install the <filename>bmap-tools</filename> package
  7655. using the following command and then use the tool
  7656. without specifying <filename>PATH</filename> even from
  7657. the root account:
  7658. <literallayout class='monospaced'>
  7659. $ sudo apt-get install bmap-tools
  7660. </literallayout>
  7661. </para></listitem>
  7662. <listitem><para>
  7663. If you are unable to install the
  7664. <filename>bmap-tools</filename> package, you will
  7665. need to build Bmaptool before using it.
  7666. Use the following command:
  7667. <literallayout class='monospaced'>
  7668. $ bitbake bmap-tools-native
  7669. </literallayout>
  7670. </para></listitem>
  7671. </itemizedlist>
  7672. </note>
  7673. </para>
  7674. <para>
  7675. Following, is an example that shows how to flash a Wic image.
  7676. Realize that while this example uses a Wic image, you can use
  7677. Bmaptool to flash any type of image.
  7678. Use these steps to flash an image using Bmaptool:
  7679. <orderedlist>
  7680. <listitem><para>
  7681. <emphasis>Update your <filename>local.conf</filename> File:</emphasis>
  7682. You need to have the following set in your
  7683. <filename>local.conf</filename> file before building
  7684. your image:
  7685. <literallayout class='monospaced'>
  7686. IMAGE_FSTYPES += "wic wic.bmap"
  7687. </literallayout>
  7688. </para></listitem>
  7689. <listitem><para>
  7690. <emphasis>Get Your Image:</emphasis>
  7691. Either have your image ready (pre-built with the
  7692. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  7693. setting previously mentioned) or take the step to build
  7694. the image:
  7695. <literallayout class='monospaced'>
  7696. $ bitbake <replaceable>image</replaceable>
  7697. </literallayout>
  7698. </para></listitem>
  7699. <listitem><para>
  7700. <emphasis>Flash the Device:</emphasis>
  7701. Flash the device with the image by using Bmaptool
  7702. depending on your particular setup.
  7703. The following commands assume the image resides in the
  7704. Build Directory's <filename>deploy/images/</filename>
  7705. area:
  7706. <itemizedlist>
  7707. <listitem><para>
  7708. If you have write access to the media, use this
  7709. command form:
  7710. <literallayout class='monospaced'>
  7711. $ oe-run-native bmap-tools-native bmaptool copy <replaceable>build-directory</replaceable>/tmp/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.wic /dev/sd<replaceable>X</replaceable>
  7712. </literallayout>
  7713. </para></listitem>
  7714. <listitem><para>
  7715. If you do not have write access to the media, set
  7716. your permissions first and then use the same
  7717. command form:
  7718. <literallayout class='monospaced'>
  7719. $ sudo chmod 666 /dev/sd<replaceable>X</replaceable>
  7720. $ oe-run-native bmap-tools-native bmaptool copy <replaceable>build-directory</replaceable>/tmp/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.wic /dev/sd<replaceable>X</replaceable>
  7721. </literallayout>
  7722. </para></listitem>
  7723. </itemizedlist>
  7724. </para></listitem>
  7725. </orderedlist>
  7726. </para>
  7727. <para>
  7728. For help on the <filename>bmaptool</filename> command, use the
  7729. following command:
  7730. <literallayout class='monospaced'>
  7731. $ bmaptool --help
  7732. </literallayout>
  7733. </para>
  7734. </section>
  7735. <section id='making-images-more-secure'>
  7736. <title>Making Images More Secure</title>
  7737. <para>
  7738. Security is of increasing concern for embedded devices.
  7739. Consider the issues and problems discussed in just this
  7740. sampling of work found across the Internet:
  7741. <itemizedlist>
  7742. <listitem><para><emphasis>
  7743. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  7744. by Bruce Schneier
  7745. </para></listitem>
  7746. <listitem><para><emphasis>
  7747. "<ulink url='http://census2012.sourceforge.net/paper.html'>Internet Census 2012</ulink>"</emphasis>
  7748. by Carna Botnet</para></listitem>
  7749. <listitem><para><emphasis>
  7750. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  7751. by Jake Edge
  7752. </para></listitem>
  7753. </itemizedlist>
  7754. </para>
  7755. <para>
  7756. When securing your image is of concern, there are steps, tools,
  7757. and variables that you can consider to help you reach the
  7758. security goals you need for your particular device.
  7759. Not all situations are identical when it comes to making an
  7760. image secure.
  7761. Consequently, this section provides some guidance and suggestions
  7762. for consideration when you want to make your image more secure.
  7763. <note>
  7764. Because the security requirements and risks are
  7765. different for every type of device, this section cannot
  7766. provide a complete reference on securing your custom OS.
  7767. It is strongly recommended that you also consult other sources
  7768. of information on embedded Linux system hardening and on
  7769. security.
  7770. </note>
  7771. </para>
  7772. <section id='general-considerations'>
  7773. <title>General Considerations</title>
  7774. <para>
  7775. General considerations exist that help you create more
  7776. secure images.
  7777. You should consider the following suggestions to help
  7778. make your device more secure:
  7779. <itemizedlist>
  7780. <listitem><para>
  7781. Scan additional code you are adding to the system
  7782. (e.g. application code) by using static analysis
  7783. tools.
  7784. Look for buffer overflows and other potential
  7785. security problems.
  7786. </para></listitem>
  7787. <listitem><para>
  7788. Pay particular attention to the security for
  7789. any web-based administration interface.
  7790. </para>
  7791. <para>Web interfaces typically need to perform
  7792. administrative functions and tend to need to run with
  7793. elevated privileges.
  7794. Thus, the consequences resulting from the interface's
  7795. security becoming compromised can be serious.
  7796. Look for common web vulnerabilities such as
  7797. cross-site-scripting (XSS), unvalidated inputs,
  7798. and so forth.</para>
  7799. <para>As with system passwords, the default credentials
  7800. for accessing a web-based interface should not be the
  7801. same across all devices.
  7802. This is particularly true if the interface is enabled
  7803. by default as it can be assumed that many end-users
  7804. will not change the credentials.
  7805. </para></listitem>
  7806. <listitem><para>
  7807. Ensure you can update the software on the device to
  7808. mitigate vulnerabilities discovered in the future.
  7809. This consideration especially applies when your
  7810. device is network-enabled.
  7811. </para></listitem>
  7812. <listitem><para>
  7813. Ensure you remove or disable debugging functionality
  7814. before producing the final image.
  7815. For information on how to do this, see the
  7816. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  7817. section.
  7818. </para></listitem>
  7819. <listitem><para>
  7820. Ensure you have no network services listening that
  7821. are not needed.
  7822. </para></listitem>
  7823. <listitem><para>
  7824. Remove any software from the image that is not needed.
  7825. </para></listitem>
  7826. <listitem><para>
  7827. Enable hardware support for secure boot functionality
  7828. when your device supports this functionality.
  7829. </para></listitem>
  7830. </itemizedlist>
  7831. </para>
  7832. </section>
  7833. <section id='security-flags'>
  7834. <title>Security Flags</title>
  7835. <para>
  7836. The Yocto Project has security flags that you can enable that
  7837. help make your build output more secure.
  7838. The security flags are in the
  7839. <filename>meta/conf/distro/include/security_flags.inc</filename>
  7840. file in your
  7841. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  7842. (e.g. <filename>poky</filename>).
  7843. <note>
  7844. Depending on the recipe, certain security flags are enabled
  7845. and disabled by default.
  7846. </note>
  7847. </para>
  7848. <para>
  7849. <!--
  7850. The GCC/LD flags in <filename>security_flags.inc</filename>
  7851. enable more secure code generation.
  7852. By including the <filename>security_flags.inc</filename>
  7853. file, you enable flags to the compiler and linker that cause
  7854. them to generate more secure code.
  7855. <note>
  7856. The GCC/LD flags are enabled by default in the
  7857. <filename>poky-lsb</filename> distribution.
  7858. </note>
  7859. -->
  7860. Use the following line in your
  7861. <filename>local.conf</filename> file or in your custom
  7862. distribution configuration file to enable the security
  7863. compiler and linker flags for your build:
  7864. <literallayout class='monospaced'>
  7865. require conf/distro/include/security_flags.inc
  7866. </literallayout>
  7867. </para>
  7868. </section>
  7869. <section id='considerations-specific-to-the-openembedded-build-system'>
  7870. <title>Considerations Specific to the OpenEmbedded Build System</title>
  7871. <para>
  7872. You can take some steps that are specific to the
  7873. OpenEmbedded build system to make your images more secure:
  7874. <itemizedlist>
  7875. <listitem><para>
  7876. Ensure "debug-tweaks" is not one of your selected
  7877. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  7878. When creating a new project, the default is to provide you
  7879. with an initial <filename>local.conf</filename> file that
  7880. enables this feature using the
  7881. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  7882. <literallayout class='monospaced'>
  7883. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  7884. </literallayout>
  7885. To disable that feature, simply comment out that line in your
  7886. <filename>local.conf</filename> file, or
  7887. make sure <filename>IMAGE_FEATURES</filename> does not contain
  7888. "debug-tweaks" before producing your final image.
  7889. Among other things, leaving this in place sets the
  7890. root password as blank, which makes logging in for
  7891. debugging or inspection easy during
  7892. development but also means anyone can easily log in
  7893. during production.
  7894. </para></listitem>
  7895. <listitem><para>
  7896. It is possible to set a root password for the image
  7897. and also to set passwords for any extra users you might
  7898. add (e.g. administrative or service type users).
  7899. When you set up passwords for multiple images or
  7900. users, you should not duplicate passwords.
  7901. </para>
  7902. <para>
  7903. To set up passwords, use the
  7904. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  7905. class, which is the preferred method.
  7906. For an example on how to set up both root and user
  7907. passwords, see the
  7908. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  7909. section.
  7910. <note>
  7911. When adding extra user accounts or setting a
  7912. root password, be cautious about setting the
  7913. same password on every device.
  7914. If you do this, and the password you have set
  7915. is exposed, then every device is now potentially
  7916. compromised.
  7917. If you need this access but want to ensure
  7918. security, consider setting a different,
  7919. random password for each device.
  7920. Typically, you do this as a separate step after
  7921. you deploy the image onto the device.
  7922. </note>
  7923. </para></listitem>
  7924. <listitem><para>
  7925. Consider enabling a Mandatory Access Control (MAC)
  7926. framework such as SMACK or SELinux and tuning it
  7927. appropriately for your device's usage.
  7928. You can find more information in the
  7929. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink>
  7930. layer.
  7931. </para></listitem>
  7932. </itemizedlist>
  7933. </para>
  7934. <para>
  7935. </para>
  7936. </section>
  7937. <section id='tools-for-hardening-your-image'>
  7938. <title>Tools for Hardening Your Image</title>
  7939. <para>
  7940. The Yocto Project provides tools for making your image
  7941. more secure.
  7942. You can find these tools in the
  7943. <filename>meta-security</filename> layer of the
  7944. <ulink url='&YOCTO_GIT_URL;'>Yocto Project Source Repositories</ulink>.
  7945. </para>
  7946. </section>
  7947. </section>
  7948. <section id='creating-your-own-distribution'>
  7949. <title>Creating Your Own Distribution</title>
  7950. <para>
  7951. When you build an image using the Yocto Project and
  7952. do not alter any distribution
  7953. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  7954. you are creating a Poky distribution.
  7955. If you wish to gain more control over package alternative
  7956. selections, compile-time options, and other low-level
  7957. configurations, you can create your own distribution.
  7958. </para>
  7959. <para>
  7960. To create your own distribution, the basic steps consist of
  7961. creating your own distribution layer, creating your own
  7962. distribution configuration file, and then adding any needed
  7963. code and Metadata to the layer.
  7964. The following steps provide some more detail:
  7965. <itemizedlist>
  7966. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  7967. Create your distribution layer so that you can keep your
  7968. Metadata and code for the distribution separate.
  7969. It is strongly recommended that you create and use your own
  7970. layer for configuration and code.
  7971. Using your own layer as compared to just placing
  7972. configurations in a <filename>local.conf</filename>
  7973. configuration file makes it easier to reproduce the same
  7974. build configuration when using multiple build machines.
  7975. See the
  7976. "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>"
  7977. section for information on how to quickly set up a layer.
  7978. </para></listitem>
  7979. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  7980. The distribution configuration file needs to be created in
  7981. the <filename>conf/distro</filename> directory of your
  7982. layer.
  7983. You need to name it using your distribution name
  7984. (e.g. <filename>mydistro.conf</filename>).
  7985. <note>
  7986. The
  7987. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  7988. variable in your
  7989. <filename>local.conf</filename> file determines the
  7990. name of your distribution.
  7991. </note></para>
  7992. <para>You can split out parts of your configuration file
  7993. into include files and then "require" them from within
  7994. your distribution configuration file.
  7995. Be sure to place the include files in the
  7996. <filename>conf/distro/include</filename> directory of
  7997. your layer.
  7998. A common example usage of include files would be to
  7999. separate out the selection of desired version and revisions
  8000. for individual recipes.
  8001. </para>
  8002. <para>Your configuration file needs to set the following
  8003. required variables:
  8004. <literallayout class='monospaced'>
  8005. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  8006. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  8007. </literallayout>
  8008. These following variables are optional and you typically
  8009. set them from the distribution configuration file:
  8010. <literallayout class='monospaced'>
  8011. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  8012. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  8013. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  8014. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  8015. </literallayout>
  8016. <tip>
  8017. If you want to base your distribution configuration file
  8018. on the very basic configuration from OE-Core, you
  8019. can use
  8020. <filename>conf/distro/defaultsetup.conf</filename> as
  8021. a reference and just include variables that differ
  8022. as compared to <filename>defaultsetup.conf</filename>.
  8023. Alternatively, you can create a distribution
  8024. configuration file from scratch using the
  8025. <filename>defaultsetup.conf</filename> file
  8026. or configuration files from other distributions
  8027. such as Poky or Angstrom as references.
  8028. </tip></para></listitem>
  8029. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  8030. Be sure to define any other variables for which you want to
  8031. create a default or enforce as part of the distribution
  8032. configuration.
  8033. You can include nearly any variable from the
  8034. <filename>local.conf</filename> file.
  8035. The variables you use are not limited to the list in the
  8036. previous bulleted item.</para></listitem>
  8037. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  8038. In your <filename>local.conf</filename> file in the
  8039. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  8040. set your
  8041. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  8042. variable to point to your distribution's configuration file.
  8043. For example, if your distribution's configuration file is
  8044. named <filename>mydistro.conf</filename>, then you point
  8045. to it as follows:
  8046. <literallayout class='monospaced'>
  8047. DISTRO = "mydistro"
  8048. </literallayout></para></listitem>
  8049. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  8050. Use your layer to hold other information needed for the
  8051. distribution:
  8052. <itemizedlist>
  8053. <listitem><para>Add recipes for installing
  8054. distro-specific configuration files that are not
  8055. already installed by another recipe.
  8056. If you have distro-specific configuration files
  8057. that are included by an existing recipe, you should
  8058. add an append file (<filename>.bbappend</filename>)
  8059. for those.
  8060. For general information and recommendations
  8061. on how to add recipes to your layer, see the
  8062. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  8063. and
  8064. "<link linkend='best-practices-to-follow-when-creating-layers'>Following Best Practices When Creating Layers</link>"
  8065. sections.</para></listitem>
  8066. <listitem><para>Add any image recipes that are specific
  8067. to your distribution.</para></listitem>
  8068. <listitem><para>Add a <filename>psplash</filename>
  8069. append file for a branded splash screen.
  8070. For information on append files, see the
  8071. "<link linkend='using-bbappend-files'>Using .bbappend Files in Your Layer</link>"
  8072. section.</para></listitem>
  8073. <listitem><para>Add any other append files to make
  8074. custom changes that are specific to individual
  8075. recipes.</para></listitem>
  8076. </itemizedlist></para></listitem>
  8077. </itemizedlist>
  8078. </para>
  8079. </section>
  8080. <section id='creating-a-custom-template-configuration-directory'>
  8081. <title>Creating a Custom Template Configuration Directory</title>
  8082. <para>
  8083. If you are producing your own customized version
  8084. of the build system for use by other users, you might
  8085. want to customize the message shown by the setup script or
  8086. you might want to change the template configuration files (i.e.
  8087. <filename>local.conf</filename> and
  8088. <filename>bblayers.conf</filename>) that are created in
  8089. a new build directory.
  8090. </para>
  8091. <para>
  8092. The OpenEmbedded build system uses the environment variable
  8093. <filename>TEMPLATECONF</filename> to locate the directory
  8094. from which it gathers configuration information that ultimately
  8095. ends up in the
  8096. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8097. <filename>conf</filename> directory.
  8098. By default, <filename>TEMPLATECONF</filename> is set as
  8099. follows in the <filename>poky</filename> repository:
  8100. <literallayout class='monospaced'>
  8101. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  8102. </literallayout>
  8103. This is the directory used by the build system to find templates
  8104. from which to build some key configuration files.
  8105. If you look at this directory, you will see the
  8106. <filename>bblayers.conf.sample</filename>,
  8107. <filename>local.conf.sample</filename>, and
  8108. <filename>conf-notes.txt</filename> files.
  8109. The build system uses these files to form the respective
  8110. <filename>bblayers.conf</filename> file,
  8111. <filename>local.conf</filename> file, and display the list of
  8112. BitBake targets when running the setup script.
  8113. </para>
  8114. <para>
  8115. To override these default configuration files with
  8116. configurations you want used within every new
  8117. Build Directory, simply set the
  8118. <filename>TEMPLATECONF</filename> variable to your directory.
  8119. The <filename>TEMPLATECONF</filename> variable is set in the
  8120. <filename>.templateconf</filename> file, which is in the
  8121. top-level
  8122. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  8123. folder (e.g. <filename>poky</filename>).
  8124. Edit the <filename>.templateconf</filename> so that it can locate
  8125. your directory.
  8126. </para>
  8127. <para>
  8128. Best practices dictate that you should keep your
  8129. template configuration directory in your custom distribution layer.
  8130. For example, suppose you have a layer named
  8131. <filename>meta-mylayer</filename> located in your home directory
  8132. and you want your template configuration directory named
  8133. <filename>myconf</filename>.
  8134. Changing the <filename>.templateconf</filename> as follows
  8135. causes the OpenEmbedded build system to look in your directory
  8136. and base its configuration files on the
  8137. <filename>*.sample</filename> configuration files it finds.
  8138. The final configuration files (i.e.
  8139. <filename>local.conf</filename> and
  8140. <filename>bblayers.conf</filename> ultimately still end up in
  8141. your Build Directory, but they are based on your
  8142. <filename>*.sample</filename> files.
  8143. <literallayout class='monospaced'>
  8144. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  8145. </literallayout>
  8146. </para>
  8147. <para>
  8148. Aside from the <filename>*.sample</filename> configuration files,
  8149. the <filename>conf-notes.txt</filename> also resides in the
  8150. default <filename>meta-poky/conf</filename> directory.
  8151. The script that sets up the build environment
  8152. (i.e.
  8153. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>)
  8154. uses this file to display BitBake targets as part of the script
  8155. output.
  8156. Customizing this <filename>conf-notes.txt</filename> file is a
  8157. good way to make sure your list of custom targets appears
  8158. as part of the script's output.
  8159. </para>
  8160. <para>
  8161. Here is the default list of targets displayed as a result of
  8162. running either of the setup scripts:
  8163. <literallayout class='monospaced'>
  8164. You can now run 'bitbake &lt;target&gt;'
  8165. Common targets are:
  8166. core-image-minimal
  8167. core-image-sato
  8168. meta-toolchain
  8169. meta-ide-support
  8170. </literallayout>
  8171. </para>
  8172. <para>
  8173. Changing the listed common targets is as easy as editing your
  8174. version of <filename>conf-notes.txt</filename> in your
  8175. custom template configuration directory and making sure you
  8176. have <filename>TEMPLATECONF</filename> set to your directory.
  8177. </para>
  8178. </section>
  8179. <section id='dev-saving-memory-during-a-build'>
  8180. <title>Conserving Disk Space During Builds</title>
  8181. <para>
  8182. To help conserve disk space during builds, you can add the
  8183. following statement to your project's
  8184. <filename>local.conf</filename> configuration file found in the
  8185. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8186. <literallayout class='monospaced'>
  8187. INHERIT += "rm_work"
  8188. </literallayout>
  8189. Adding this statement deletes the work directory used for building
  8190. a recipe once the recipe is built.
  8191. For more information on "rm_work", see the
  8192. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  8193. class in the Yocto Project Reference Manual.
  8194. </para>
  8195. </section>
  8196. <section id='working-with-packages'>
  8197. <title>Working with Packages</title>
  8198. <para>
  8199. This section describes a few tasks that involve packages:
  8200. <itemizedlist>
  8201. <listitem><para>
  8202. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  8203. </para></listitem>
  8204. <listitem><para>
  8205. <link linkend='incrementing-a-binary-package-version'>Incrementing a binary package version</link>
  8206. </para></listitem>
  8207. <listitem><para>
  8208. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  8209. </para></listitem>
  8210. <listitem><para>
  8211. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  8212. </para></listitem>
  8213. <listitem><para>
  8214. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  8215. </para></listitem>
  8216. </itemizedlist>
  8217. </para>
  8218. <section id='excluding-packages-from-an-image'>
  8219. <title>Excluding Packages from an Image</title>
  8220. <para>
  8221. You might find it necessary to prevent specific packages
  8222. from being installed into an image.
  8223. If so, you can use several variables to direct the build
  8224. system to essentially ignore installing recommended packages
  8225. or to not install a package at all.
  8226. </para>
  8227. <para>
  8228. The following list introduces variables you can use to
  8229. prevent packages from being installed into your image.
  8230. Each of these variables only works with IPK and RPM
  8231. package types.
  8232. Support for Debian packages does not exist.
  8233. Also, you can use these variables from your
  8234. <filename>local.conf</filename> file or attach them to a
  8235. specific image recipe by using a recipe name override.
  8236. For more detail on the variables, see the descriptions in the
  8237. Yocto Project Reference Manual's glossary chapter.
  8238. <itemizedlist>
  8239. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  8240. Use this variable to specify "recommended-only"
  8241. packages that you do not want installed.
  8242. </para></listitem>
  8243. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  8244. Use this variable to prevent all "recommended-only"
  8245. packages from being installed.
  8246. </para></listitem>
  8247. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  8248. Use this variable to prevent specific packages from
  8249. being installed regardless of whether they are
  8250. "recommended-only" or not.
  8251. You need to realize that the build process could
  8252. fail with an error when you
  8253. prevent the installation of a package whose presence
  8254. is required by an installed package.
  8255. </para></listitem>
  8256. </itemizedlist>
  8257. </para>
  8258. </section>
  8259. <section id='incrementing-a-binary-package-version'>
  8260. <title>Incrementing a Package Version</title>
  8261. <para>
  8262. This section provides some background on how binary package
  8263. versioning is accomplished and presents some of the services,
  8264. variables, and terminology involved.
  8265. </para>
  8266. <para>
  8267. In order to understand binary package versioning, you need
  8268. to consider the following:
  8269. <itemizedlist>
  8270. <listitem><para>
  8271. Binary Package: The binary package that is eventually
  8272. built and installed into an image.
  8273. </para></listitem>
  8274. <listitem><para>
  8275. Binary Package Version: The binary package version
  8276. is composed of two components - a version and a
  8277. revision.
  8278. <note>
  8279. Technically, a third component, the "epoch" (i.e.
  8280. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>)
  8281. is involved but this discussion for the most part
  8282. ignores <filename>PE</filename>.
  8283. </note>
  8284. The version and revision are taken from the
  8285. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  8286. and
  8287. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8288. variables, respectively.
  8289. </para></listitem>
  8290. <listitem><para>
  8291. <filename>PV</filename>: The recipe version.
  8292. <filename>PV</filename> represents the version of the
  8293. software being packaged.
  8294. Do not confuse <filename>PV</filename> with the
  8295. binary package version.
  8296. </para></listitem>
  8297. <listitem><para>
  8298. <filename>PR</filename>: The recipe revision.
  8299. </para></listitem>
  8300. <listitem><para>
  8301. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>:
  8302. The OpenEmbedded build system uses this string
  8303. to help define the value of <filename>PV</filename>
  8304. when the source code revision needs to be included
  8305. in it.
  8306. </para></listitem>
  8307. <listitem><para>
  8308. <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>:
  8309. A network-based service that helps automate keeping
  8310. package feeds compatible with existing package
  8311. manager applications such as RPM, APT, and OPKG.
  8312. </para></listitem>
  8313. </itemizedlist>
  8314. </para>
  8315. <para>
  8316. Whenever the binary package content changes, the binary package
  8317. version must change.
  8318. Changing the binary package version is accomplished by changing
  8319. or "bumping" the <filename>PR</filename> and/or
  8320. <filename>PV</filename> values.
  8321. Increasing these values occurs one of two ways:
  8322. <itemizedlist>
  8323. <listitem><para>Automatically using a Package Revision
  8324. Service (PR Service).
  8325. </para></listitem>
  8326. <listitem><para>Manually incrementing the
  8327. <filename>PR</filename> and/or
  8328. <filename>PV</filename> variables.
  8329. </para></listitem>
  8330. </itemizedlist>
  8331. </para>
  8332. <para>
  8333. Given a primary challenge of any build system and its users
  8334. is how to maintain a package feed that is compatible with
  8335. existing package manager applications such as RPM, APT, and
  8336. OPKG, using an automated system is much preferred over a
  8337. manual system.
  8338. In either system, the main requirement is that binary package
  8339. version numbering increases in a linear fashion and that a
  8340. number of version components exist that support that linear
  8341. progression.
  8342. For information on how to ensure package revisioning remains
  8343. linear, see the
  8344. "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>"
  8345. section.
  8346. </para>
  8347. <para>
  8348. The following three sections provide related information on the
  8349. PR Service, the manual method for "bumping"
  8350. <filename>PR</filename> and/or <filename>PV</filename>, and
  8351. on how to ensure binary package revisioning remains linear.
  8352. </para>
  8353. <section id='working-with-a-pr-service'>
  8354. <title>Working With a PR Service</title>
  8355. <para>
  8356. As mentioned, attempting to maintain revision numbers in the
  8357. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  8358. is error prone, inaccurate, and causes problems for people
  8359. submitting recipes.
  8360. Conversely, the PR Service automatically generates
  8361. increasing numbers, particularly the revision field,
  8362. which removes the human element.
  8363. <note>
  8364. For additional information on using a PR Service, you
  8365. can see the
  8366. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  8367. wiki page.
  8368. </note>
  8369. </para>
  8370. <para>
  8371. The Yocto Project uses variables in order of
  8372. decreasing priority to facilitate revision numbering (i.e.
  8373. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  8374. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  8375. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8376. for epoch, version, and revision, respectively).
  8377. The values are highly dependent on the policies and
  8378. procedures of a given distribution and package feed.
  8379. </para>
  8380. <para>
  8381. Because the OpenEmbedded build system uses
  8382. "<ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>signatures</ulink>",
  8383. which are unique to a given build, the build system
  8384. knows when to rebuild packages.
  8385. All the inputs into a given task are represented by a
  8386. signature, which can trigger a rebuild when different.
  8387. Thus, the build system itself does not rely on the
  8388. <filename>PR</filename>, <filename>PV</filename>, and
  8389. <filename>PE</filename> numbers to trigger a rebuild.
  8390. The signatures, however, can be used to generate
  8391. these values.
  8392. </para>
  8393. <para>
  8394. The PR Service works with both
  8395. <filename>OEBasic</filename> and
  8396. <filename>OEBasicHash</filename> generators.
  8397. The value of <filename>PR</filename> bumps when the
  8398. checksum changes and the different generator mechanisms
  8399. change signatures under different circumstances.
  8400. </para>
  8401. <para>
  8402. As implemented, the build system includes values from
  8403. the PR Service into the <filename>PR</filename> field as
  8404. an addition using the form "<filename>.x</filename>" so
  8405. <filename>r0</filename> becomes <filename>r0.1</filename>,
  8406. <filename>r0.2</filename> and so forth.
  8407. This scheme allows existing <filename>PR</filename> values
  8408. to be used for whatever reasons, which include manual
  8409. <filename>PR</filename> bumps, should it be necessary.
  8410. </para>
  8411. <para>
  8412. By default, the PR Service is not enabled or running.
  8413. Thus, the packages generated are just "self consistent".
  8414. The build system adds and removes packages and
  8415. there are no guarantees about upgrade paths but images
  8416. will be consistent and correct with the latest changes.
  8417. </para>
  8418. <para>
  8419. The simplest form for a PR Service is for it to exist
  8420. for a single host development system that builds the
  8421. package feed (building system).
  8422. For this scenario, you can enable a local PR Service by
  8423. setting
  8424. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  8425. in your <filename>local.conf</filename> file in the
  8426. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8427. <literallayout class='monospaced'>
  8428. PRSERV_HOST = "localhost:0"
  8429. </literallayout>
  8430. Once the service is started, packages will automatically
  8431. get increasing <filename>PR</filename> values and
  8432. BitBake takes care of starting and stopping the server.
  8433. </para>
  8434. <para>
  8435. If you have a more complex setup where multiple host
  8436. development systems work against a common, shared package
  8437. feed, you have a single PR Service running and it is
  8438. connected to each building system.
  8439. For this scenario, you need to start the PR Service using
  8440. the <filename>bitbake-prserv</filename> command:
  8441. <literallayout class='monospaced'>
  8442. bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start
  8443. </literallayout>
  8444. In addition to hand-starting the service, you need to
  8445. update the <filename>local.conf</filename> file of each
  8446. building system as described earlier so each system
  8447. points to the server and port.
  8448. </para>
  8449. <para>
  8450. It is also recommended you use build history, which adds
  8451. some sanity checks to binary package versions, in
  8452. conjunction with the server that is running the PR Service.
  8453. To enable build history, add the following to each building
  8454. system's <filename>local.conf</filename> file:
  8455. <literallayout class='monospaced'>
  8456. # It is recommended to activate "buildhistory" for testing the PR service
  8457. INHERIT += "buildhistory"
  8458. BUILDHISTORY_COMMIT = "1"
  8459. </literallayout>
  8460. For information on build history, see the
  8461. "<link linkend='maintaining-build-output-quality'>Maintaining Build Output Quality</link>"
  8462. section.
  8463. </para>
  8464. <note>
  8465. <para>
  8466. The OpenEmbedded build system does not maintain
  8467. <filename>PR</filename> information as part of the
  8468. shared state (sstate) packages.
  8469. If you maintain an sstate feed, its expected that either
  8470. all your building systems that contribute to the sstate
  8471. feed use a shared PR Service, or you do not run a PR
  8472. Service on any of your building systems.
  8473. Having some systems use a PR Service while others do
  8474. not leads to obvious problems.
  8475. </para>
  8476. <para>
  8477. For more information on shared state, see the
  8478. "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>Shared State Cache</ulink>"
  8479. section in the Yocto Project Overview and Concepts
  8480. Manual.
  8481. </para>
  8482. </note>
  8483. </section>
  8484. <section id='manually-bumping-pr'>
  8485. <title>Manually Bumping PR</title>
  8486. <para>
  8487. The alternative to setting up a PR Service is to manually
  8488. "bump" the
  8489. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8490. variable.
  8491. </para>
  8492. <para>
  8493. If a committed change results in changing the package
  8494. output, then the value of the PR variable needs to be
  8495. increased (or "bumped") as part of that commit.
  8496. For new recipes you should add the <filename>PR</filename>
  8497. variable and set its initial value equal to "r0", which is
  8498. the default.
  8499. Even though the default value is "r0", the practice of
  8500. adding it to a new recipe makes it harder to forget to bump
  8501. the variable when you make changes to the recipe in future.
  8502. </para>
  8503. <para>
  8504. If you are sharing a common <filename>.inc</filename> file
  8505. with multiple recipes, you can also use the
  8506. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  8507. variable to ensure that the recipes sharing the
  8508. <filename>.inc</filename> file are rebuilt when the
  8509. <filename>.inc</filename> file itself is changed.
  8510. The <filename>.inc</filename> file must set
  8511. <filename>INC_PR</filename> (initially to "r0"), and all
  8512. recipes referring to it should set <filename>PR</filename>
  8513. to "${INC_PR}.0" initially, incrementing the last number
  8514. when the recipe is changed.
  8515. If the <filename>.inc</filename> file is changed then its
  8516. <filename>INC_PR</filename> should be incremented.
  8517. </para>
  8518. <para>
  8519. When upgrading the version of a binary package, assuming the
  8520. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  8521. changes, the <filename>PR</filename> variable should be
  8522. reset to "r0" (or "${INC_PR}.0" if you are using
  8523. <filename>INC_PR</filename>).
  8524. </para>
  8525. <para>
  8526. Usually, version increases occur only to binary packages.
  8527. However, if for some reason <filename>PV</filename> changes
  8528. but does not increase, you can increase the
  8529. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  8530. variable (Package Epoch).
  8531. The <filename>PE</filename> variable defaults to "0".
  8532. </para>
  8533. <para>
  8534. Binary package version numbering strives to follow the
  8535. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  8536. Debian Version Field Policy Guidelines</ulink>.
  8537. These guidelines define how versions are compared and what
  8538. "increasing" a version means.
  8539. </para>
  8540. </section>
  8541. <section id='automatically-incrementing-a-binary-package-revision-number'>
  8542. <title>Automatically Incrementing a Package Version Number</title>
  8543. <para>
  8544. When fetching a repository, BitBake uses the
  8545. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  8546. variable to determine the specific source code revision
  8547. from which to build.
  8548. You set the <filename>SRCREV</filename> variable to
  8549. <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>
  8550. to cause the OpenEmbedded build system to automatically use the
  8551. latest revision of the software:
  8552. <literallayout class='monospaced'>
  8553. SRCREV = "${AUTOREV}"
  8554. </literallayout>
  8555. </para>
  8556. <para>
  8557. Furthermore, you need to reference <filename>SRCPV</filename>
  8558. in <filename>PV</filename> in order to automatically update
  8559. the version whenever the revision of the source code
  8560. changes.
  8561. Here is an example:
  8562. <literallayout class='monospaced'>
  8563. PV = "1.0+git${SRCPV}"
  8564. </literallayout>
  8565. The OpenEmbedded build system substitutes
  8566. <filename>SRCPV</filename> with the following:
  8567. <literallayout class='monospaced'>
  8568. AUTOINC+<replaceable>source_code_revision</replaceable>
  8569. </literallayout>
  8570. The build system replaces the <filename>AUTOINC</filename> with
  8571. a number.
  8572. The number used depends on the state of the PR Service:
  8573. <itemizedlist>
  8574. <listitem><para>
  8575. If PR Service is enabled, the build system increments
  8576. the number, which is similar to the behavior of
  8577. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>.
  8578. This behavior results in linearly increasing package
  8579. versions, which is desirable.
  8580. Here is an example:
  8581. <literallayout class='monospaced'>
  8582. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  8583. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  8584. </literallayout>
  8585. </para></listitem>
  8586. <listitem><para>
  8587. If PR Service is not enabled, the build system
  8588. replaces the <filename>AUTOINC</filename>
  8589. placeholder with zero (i.e. "0").
  8590. This results in changing the package version since
  8591. the source revision is included.
  8592. However, package versions are not increased linearly.
  8593. Here is an example:
  8594. <literallayout class='monospaced'>
  8595. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  8596. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  8597. </literallayout>
  8598. </para></listitem>
  8599. </itemizedlist>
  8600. </para>
  8601. <para>
  8602. In summary, the OpenEmbedded build system does not track the
  8603. history of binary package versions for this purpose.
  8604. <filename>AUTOINC</filename>, in this case, is comparable to
  8605. <filename>PR</filename>.
  8606. If PR server is not enabled, <filename>AUTOINC</filename>
  8607. in the package version is simply replaced by "0".
  8608. If PR server is enabled, the build system keeps track of the
  8609. package versions and bumps the number when the package
  8610. revision changes.
  8611. </para>
  8612. </section>
  8613. </section>
  8614. <section id='handling-optional-module-packaging'>
  8615. <title>Handling Optional Module Packaging</title>
  8616. <para>
  8617. Many pieces of software split functionality into optional
  8618. modules (or plug-ins) and the plug-ins that are built
  8619. might depend on configuration options.
  8620. To avoid having to duplicate the logic that determines what
  8621. modules are available in your recipe or to avoid having
  8622. to package each module by hand, the OpenEmbedded build system
  8623. provides functionality to handle module packaging dynamically.
  8624. </para>
  8625. <para>
  8626. To handle optional module packaging, you need to do two things:
  8627. <itemizedlist>
  8628. <listitem><para>Ensure the module packaging is actually
  8629. done.</para></listitem>
  8630. <listitem><para>Ensure that any dependencies on optional
  8631. modules from other recipes are satisfied by your recipe.
  8632. </para></listitem>
  8633. </itemizedlist>
  8634. </para>
  8635. <section id='making-sure-the-packaging-is-done'>
  8636. <title>Making Sure the Packaging is Done</title>
  8637. <para>
  8638. To ensure the module packaging actually gets done, you use
  8639. the <filename>do_split_packages</filename> function within
  8640. the <filename>populate_packages</filename> Python function
  8641. in your recipe.
  8642. The <filename>do_split_packages</filename> function
  8643. searches for a pattern of files or directories under a
  8644. specified path and creates a package for each one it finds
  8645. by appending to the
  8646. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  8647. variable and setting the appropriate values for
  8648. <filename>FILES_packagename</filename>,
  8649. <filename>RDEPENDS_packagename</filename>,
  8650. <filename>DESCRIPTION_packagename</filename>, and so forth.
  8651. Here is an example from the <filename>lighttpd</filename>
  8652. recipe:
  8653. <literallayout class='monospaced'>
  8654. python populate_packages_prepend () {
  8655. lighttpd_libdir = d.expand('${libdir}')
  8656. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  8657. 'lighttpd-module-%s', 'Lighttpd module for %s',
  8658. extra_depends='')
  8659. }
  8660. </literallayout>
  8661. The previous example specifies a number of things in the
  8662. call to <filename>do_split_packages</filename>.
  8663. <itemizedlist>
  8664. <listitem><para>A directory within the files installed
  8665. by your recipe through <filename>do_install</filename>
  8666. in which to search.</para></listitem>
  8667. <listitem><para>A regular expression used to match module
  8668. files in that directory.
  8669. In the example, note the parentheses () that mark
  8670. the part of the expression from which the module
  8671. name should be derived.</para></listitem>
  8672. <listitem><para>A pattern to use for the package names.
  8673. </para></listitem>
  8674. <listitem><para>A description for each package.
  8675. </para></listitem>
  8676. <listitem><para>An empty string for
  8677. <filename>extra_depends</filename>, which disables
  8678. the default dependency on the main
  8679. <filename>lighttpd</filename> package.
  8680. Thus, if a file in <filename>${libdir}</filename>
  8681. called <filename>mod_alias.so</filename> is found,
  8682. a package called <filename>lighttpd-module-alias</filename>
  8683. is created for it and the
  8684. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  8685. is set to "Lighttpd module for alias".</para></listitem>
  8686. </itemizedlist>
  8687. </para>
  8688. <para>
  8689. Often, packaging modules is as simple as the previous
  8690. example.
  8691. However, more advanced options exist that you can use
  8692. within <filename>do_split_packages</filename> to modify its
  8693. behavior.
  8694. And, if you need to, you can add more logic by specifying
  8695. a hook function that is called for each package.
  8696. It is also perfectly acceptable to call
  8697. <filename>do_split_packages</filename> multiple times if
  8698. you have more than one set of modules to package.
  8699. </para>
  8700. <para>
  8701. For more examples that show how to use
  8702. <filename>do_split_packages</filename>, see the
  8703. <filename>connman.inc</filename> file in the
  8704. <filename>meta/recipes-connectivity/connman/</filename>
  8705. directory of the <filename>poky</filename>
  8706. <ulink url='&YOCTO_DOCS_OM_URL;#yocto-project-repositories'>source repository</ulink>.
  8707. You can also find examples in
  8708. <filename>meta/classes/kernel.bbclass</filename>.
  8709. </para>
  8710. <para>
  8711. Following is a reference that shows
  8712. <filename>do_split_packages</filename> mandatory and
  8713. optional arguments:
  8714. <literallayout class='monospaced'>
  8715. Mandatory arguments
  8716. root
  8717. The path in which to search
  8718. file_regex
  8719. Regular expression to match searched files.
  8720. Use parentheses () to mark the part of this
  8721. expression that should be used to derive the
  8722. module name (to be substituted where %s is
  8723. used in other function arguments as noted below)
  8724. output_pattern
  8725. Pattern to use for the package names. Must
  8726. include %s.
  8727. description
  8728. Description to set for each package. Must
  8729. include %s.
  8730. Optional arguments
  8731. postinst
  8732. Postinstall script to use for all packages
  8733. (as a string)
  8734. recursive
  8735. True to perform a recursive search - default
  8736. False
  8737. hook
  8738. A hook function to be called for every match.
  8739. The function will be called with the following
  8740. arguments (in the order listed):
  8741. f
  8742. Full path to the file/directory match
  8743. pkg
  8744. The package name
  8745. file_regex
  8746. As above
  8747. output_pattern
  8748. As above
  8749. modulename
  8750. The module name derived using file_regex
  8751. extra_depends
  8752. Extra runtime dependencies (RDEPENDS) to be
  8753. set for all packages. The default value of None
  8754. causes a dependency on the main package
  8755. (${PN}) - if you do not want this, pass empty
  8756. string '' for this parameter.
  8757. aux_files_pattern
  8758. Extra item(s) to be added to FILES for each
  8759. package. Can be a single string item or a list
  8760. of strings for multiple items. Must include %s.
  8761. postrm
  8762. postrm script to use for all packages (as a
  8763. string)
  8764. allow_dirs
  8765. True to allow directories to be matched -
  8766. default False
  8767. prepend
  8768. If True, prepend created packages to PACKAGES
  8769. instead of the default False which appends them
  8770. match_path
  8771. match file_regex on the whole relative path to
  8772. the root rather than just the file name
  8773. aux_files_pattern_verbatim
  8774. Extra item(s) to be added to FILES for each
  8775. package, using the actual derived module name
  8776. rather than converting it to something legal
  8777. for a package name. Can be a single string item
  8778. or a list of strings for multiple items. Must
  8779. include %s.
  8780. allow_links
  8781. True to allow symlinks to be matched - default
  8782. False
  8783. summary
  8784. Summary to set for each package. Must include %s;
  8785. defaults to description if not set.
  8786. </literallayout>
  8787. </para>
  8788. </section>
  8789. <section id='satisfying-dependencies'>
  8790. <title>Satisfying Dependencies</title>
  8791. <para>
  8792. The second part for handling optional module packaging
  8793. is to ensure that any dependencies on optional modules
  8794. from other recipes are satisfied by your recipe.
  8795. You can be sure these dependencies are satisfied by
  8796. using the
  8797. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  8798. Here is an example that continues with the
  8799. <filename>lighttpd</filename> recipe shown earlier:
  8800. <literallayout class='monospaced'>
  8801. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  8802. </literallayout>
  8803. The name specified in the regular expression can of
  8804. course be anything.
  8805. In this example, it is <filename>lighttpd-module-</filename>
  8806. and is specified as the prefix to ensure that any
  8807. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  8808. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  8809. on a package name starting with the prefix are satisfied
  8810. during build time.
  8811. If you are using <filename>do_split_packages</filename>
  8812. as described in the previous section, the value you put in
  8813. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  8814. the name pattern specified in the call to
  8815. <filename>do_split_packages</filename>.
  8816. </para>
  8817. </section>
  8818. </section>
  8819. <section id='using-runtime-package-management'>
  8820. <title>Using Runtime Package Management</title>
  8821. <para>
  8822. During a build, BitBake always transforms a recipe into one or
  8823. more packages.
  8824. For example, BitBake takes the <filename>bash</filename> recipe
  8825. and produces a number of packages (e.g.
  8826. <filename>bash</filename>, <filename>bash-bashbug</filename>,
  8827. <filename>bash-completion</filename>,
  8828. <filename>bash-completion-dbg</filename>,
  8829. <filename>bash-completion-dev</filename>,
  8830. <filename>bash-completion-extra</filename>,
  8831. <filename>bash-dbg</filename>, and so forth).
  8832. Not all generated packages are included in an image.
  8833. </para>
  8834. <para>
  8835. In several situations, you might need to update, add, remove,
  8836. or query the packages on a target device at runtime
  8837. (i.e. without having to generate a new image).
  8838. Examples of such situations include:
  8839. <itemizedlist>
  8840. <listitem><para>
  8841. You want to provide in-the-field updates to deployed
  8842. devices (e.g. security updates).
  8843. </para></listitem>
  8844. <listitem><para>
  8845. You want to have a fast turn-around development cycle
  8846. for one or more applications that run on your device.
  8847. </para></listitem>
  8848. <listitem><para>
  8849. You want to temporarily install the "debug" packages
  8850. of various applications on your device so that
  8851. debugging can be greatly improved by allowing
  8852. access to symbols and source debugging.
  8853. </para></listitem>
  8854. <listitem><para>
  8855. You want to deploy a more minimal package selection of
  8856. your device but allow in-the-field updates to add a
  8857. larger selection for customization.
  8858. </para></listitem>
  8859. </itemizedlist>
  8860. </para>
  8861. <para>
  8862. In all these situations, you have something similar to a more
  8863. traditional Linux distribution in that in-field devices
  8864. are able to receive pre-compiled packages from a server for
  8865. installation or update.
  8866. Being able to install these packages on a running,
  8867. in-field device is what is termed "runtime package
  8868. management".
  8869. </para>
  8870. <para>
  8871. In order to use runtime package management, you
  8872. need a host or server machine that serves up the pre-compiled
  8873. packages plus the required metadata.
  8874. You also need package manipulation tools on the target.
  8875. The build machine is a likely candidate to act as the server.
  8876. However, that machine does not necessarily have to be the
  8877. package server.
  8878. The build machine could push its artifacts to another machine
  8879. that acts as the server (e.g. Internet-facing).
  8880. In fact, doing so is advantageous for a production
  8881. environment as getting the packages away from the
  8882. development system's build directory prevents accidental
  8883. overwrites.
  8884. </para>
  8885. <para>
  8886. A simple build that targets just one device produces
  8887. more than one package database.
  8888. In other words, the packages produced by a build are separated
  8889. out into a couple of different package groupings based on
  8890. criteria such as the target's CPU architecture, the target
  8891. board, or the C library used on the target.
  8892. For example, a build targeting the <filename>qemux86</filename>
  8893. device produces the following three package databases:
  8894. <filename>noarch</filename>, <filename>i586</filename>, and
  8895. <filename>qemux86</filename>.
  8896. If you wanted your <filename>qemux86</filename> device to be
  8897. aware of all the packages that were available to it,
  8898. you would need to point it to each of these databases
  8899. individually.
  8900. In a similar way, a traditional Linux distribution usually is
  8901. configured to be aware of a number of software repositories
  8902. from which it retrieves packages.
  8903. </para>
  8904. <para>
  8905. Using runtime package management is completely optional and
  8906. not required for a successful build or deployment in any
  8907. way.
  8908. But if you want to make use of runtime package management,
  8909. you need to do a couple things above and beyond the basics.
  8910. The remainder of this section describes what you need to do.
  8911. </para>
  8912. <section id='runtime-package-management-build'>
  8913. <title>Build Considerations</title>
  8914. <para>
  8915. This section describes build considerations of which you
  8916. need to be aware in order to provide support for runtime
  8917. package management.
  8918. </para>
  8919. <para>
  8920. When BitBake generates packages, it needs to know
  8921. what format or formats to use.
  8922. In your configuration, you use the
  8923. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  8924. variable to specify the format:
  8925. <orderedlist>
  8926. <listitem><para>
  8927. Open the <filename>local.conf</filename> file
  8928. inside your
  8929. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8930. (e.g. <filename>~/poky/build/conf/local.conf</filename>).
  8931. </para></listitem>
  8932. <listitem><para>
  8933. Select the desired package format as follows:
  8934. <literallayout class='monospaced'>
  8935. PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>”
  8936. </literallayout>
  8937. where <replaceable>packageformat</replaceable>
  8938. can be "ipk", "rpm", "deb", or "tar" which are the
  8939. supported package formats.
  8940. <note>
  8941. Because the Yocto Project supports four
  8942. different package formats, you can set the
  8943. variable with more than one argument.
  8944. However, the OpenEmbedded build system only
  8945. uses the first argument when creating an image
  8946. or Software Development Kit (SDK).
  8947. </note>
  8948. </para></listitem>
  8949. </orderedlist>
  8950. </para>
  8951. <para>
  8952. If you would like your image to start off with a basic
  8953. package database containing the packages in your current
  8954. build as well as to have the relevant tools available on the
  8955. target for runtime package management, you can include
  8956. "package-management" in the
  8957. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  8958. variable.
  8959. Including "package-management" in this configuration
  8960. variable ensures that when the image is assembled for your
  8961. target, the image includes the currently-known package
  8962. databases as well as the target-specific tools required
  8963. for runtime package management to be performed on the
  8964. target.
  8965. However, this is not strictly necessary.
  8966. You could start your image off without any databases
  8967. but only include the required on-target package
  8968. tool(s).
  8969. As an example, you could include "opkg" in your
  8970. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  8971. variable if you are using the IPK package format.
  8972. You can then initialize your target's package database(s)
  8973. later once your image is up and running.
  8974. </para>
  8975. <para>
  8976. Whenever you perform any sort of build step that can
  8977. potentially generate a package or modify existing
  8978. package, it is always a good idea to re-generate the
  8979. package index after the build by using the following
  8980. command:
  8981. <literallayout class='monospaced'>
  8982. $ bitbake package-index
  8983. </literallayout>
  8984. It might be tempting to build the package and the
  8985. package index at the same time with a command such as
  8986. the following:
  8987. <literallayout class='monospaced'>
  8988. $ bitbake <replaceable>some-package</replaceable> package-index
  8989. </literallayout>
  8990. Do not do this as BitBake does not schedule the package
  8991. index for after the completion of the package you are
  8992. building.
  8993. Consequently, you cannot be sure of the package index
  8994. including information for the package you just built.
  8995. Thus, be sure to run the package update step separately
  8996. after building any packages.
  8997. </para>
  8998. <para>
  8999. You can use the
  9000. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9001. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  9002. and
  9003. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9004. variables to pre-configure target images to use a package
  9005. feed.
  9006. If you do not define these variables, then manual steps
  9007. as described in the subsequent sections are necessary to
  9008. configure the target.
  9009. You should set these variables before building the image
  9010. in order to produce a correctly configured image.
  9011. </para>
  9012. <para>
  9013. When your build is complete, your packages reside in the
  9014. <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename>
  9015. directory.
  9016. For example, if
  9017. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename>
  9018. is <filename>tmp</filename> and your selected package type
  9019. is RPM, then your RPM packages are available in
  9020. <filename>tmp/deploy/rpm</filename>.
  9021. </para>
  9022. </section>
  9023. <section id='runtime-package-management-server'>
  9024. <title>Host or Server Machine Setup</title>
  9025. <para>
  9026. Although other protocols are possible, a server using HTTP
  9027. typically serves packages.
  9028. If you want to use HTTP, then set up and configure a
  9029. web server such as Apache 2, lighttpd, or
  9030. SimpleHTTPServer on the machine serving the packages.
  9031. </para>
  9032. <para>
  9033. To keep things simple, this section describes how to set
  9034. up a SimpleHTTPServer web server to share package feeds
  9035. from the developer's machine.
  9036. Although this server might not be the best for a production
  9037. environment, the setup is simple and straight forward.
  9038. Should you want to use a different server more suited for
  9039. production (e.g. Apache 2, Lighttpd, or Nginx), take the
  9040. appropriate steps to do so.
  9041. </para>
  9042. <para>
  9043. From within the build directory where you have built an
  9044. image based on your packaging choice (i.e. the
  9045. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  9046. setting), simply start the server.
  9047. The following example assumes a build directory of
  9048. <filename>~/poky/build/tmp/deploy/rpm</filename> and a
  9049. <filename>PACKAGE_CLASSES</filename> setting of
  9050. "package_rpm":
  9051. <literallayout class='monospaced'>
  9052. $ cd ~/poky/build/tmp/deploy/rpm
  9053. $ python -m SimpleHTTPServer
  9054. </literallayout>
  9055. </para>
  9056. </section>
  9057. <section id='runtime-package-management-target'>
  9058. <title>Target Setup</title>
  9059. <para>
  9060. Setting up the target differs depending on the
  9061. package management system.
  9062. This section provides information for RPM, IPK, and DEB.
  9063. </para>
  9064. <section id='runtime-package-management-target-rpm'>
  9065. <title>Using RPM</title>
  9066. <para>
  9067. The
  9068. <ulink url='https://en.wikipedia.org/wiki/DNF_(software)'>Dandified Packaging Tool</ulink>
  9069. (DNF) performs runtime package management of RPM
  9070. packages.
  9071. In order to use DNF for runtime package management,
  9072. you must perform an initial setup on the target
  9073. machine for cases where the
  9074. <filename>PACKAGE_FEED_*</filename> variables were not
  9075. set as part of the image that is running on the
  9076. target.
  9077. This means if you built your image and did not not use
  9078. these variables as part of the build and your image is
  9079. now running on the target, you need to perform the
  9080. steps in this section if you want to use runtime
  9081. package management.
  9082. <note>
  9083. For information on the
  9084. <filename>PACKAGE_FEED_*</filename> variables, see
  9085. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9086. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  9087. and
  9088. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9089. in the Yocto Project Reference Manual variables
  9090. glossary.
  9091. </note>
  9092. </para>
  9093. <para>
  9094. On the target, you must inform DNF that package
  9095. databases are available.
  9096. You do this by creating a file named
  9097. <filename>/etc/yum.repos.d/oe-packages.repo</filename>
  9098. and defining the <filename>oe-packages</filename>.
  9099. </para>
  9100. <para>
  9101. As an example, assume the target is able to use the
  9102. following package databases:
  9103. <filename>all</filename>, <filename>i586</filename>,
  9104. and <filename>qemux86</filename> from a server named
  9105. <filename>my.server</filename>.
  9106. The specifics for setting up the web server are up to
  9107. you.
  9108. The critical requirement is that the URIs in the
  9109. target repository configuration point to the
  9110. correct remote location for the feeds.
  9111. <note><title>Tip</title>
  9112. For development purposes, you can point the web
  9113. server to the build system's
  9114. <filename>deploy</filename> directory.
  9115. However, for production use, it is better to copy
  9116. the package directories to a location outside of
  9117. the build area and use that location.
  9118. Doing so avoids situations where the build system
  9119. overwrites or changes the
  9120. <filename>deploy</filename> directory.
  9121. </note>
  9122. </para>
  9123. <para>
  9124. When telling DNF where to look for the package
  9125. databases, you must declare individual locations
  9126. per architecture or a single location used for all
  9127. architectures.
  9128. You cannot do both:
  9129. <itemizedlist>
  9130. <listitem><para>
  9131. <emphasis>Create an Explicit List of Architectures:</emphasis>
  9132. Define individual base URLs to identify where
  9133. each package database is located:
  9134. <literallayout class='monospaced'>
  9135. [oe-packages]
  9136. baseurl=http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all
  9137. </literallayout>
  9138. This example informs DNF about individual
  9139. package databases for all three architectures.
  9140. </para></listitem>
  9141. <listitem><para>
  9142. <emphasis>Create a Single (Full) Package Index:</emphasis>
  9143. Define a single base URL that identifies where
  9144. a full package database is located:
  9145. <literallayout class='monospaced'>
  9146. [oe-packages]
  9147. baseurl=http://my.server/rpm
  9148. </literallayout>
  9149. This example informs DNF about a single package
  9150. database that contains all the package index
  9151. information for all supported architectures.
  9152. </para></listitem>
  9153. </itemizedlist>
  9154. </para>
  9155. <para>
  9156. Once you have informed DNF where to find the package
  9157. databases, you need to fetch them:
  9158. <literallayout class='monospaced'>
  9159. # dnf makecache
  9160. </literallayout>
  9161. DNF is now able to find, install, and upgrade packages
  9162. from the specified repository or repositories.
  9163. <note>
  9164. See the
  9165. <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink>
  9166. for additional information.
  9167. </note>
  9168. </para>
  9169. </section>
  9170. <section id='runtime-package-management-target-ipk'>
  9171. <title>Using IPK</title>
  9172. <para>
  9173. The <filename>opkg</filename> application performs
  9174. runtime package management of IPK packages.
  9175. You must perform an initial setup for
  9176. <filename>opkg</filename> on the target machine
  9177. if the
  9178. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9179. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  9180. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9181. variables have not been set or the target image was
  9182. built before the variables were set.
  9183. </para>
  9184. <para>
  9185. The <filename>opkg</filename> application uses
  9186. configuration files to find available package
  9187. databases.
  9188. Thus, you need to create a configuration file inside
  9189. the <filename>/etc/opkg/</filename> direction, which
  9190. informs <filename>opkg</filename> of any repository
  9191. you want to use.
  9192. </para>
  9193. <para>
  9194. As an example, suppose you are serving packages from a
  9195. <filename>ipk/</filename> directory containing the
  9196. <filename>i586</filename>,
  9197. <filename>all</filename>, and
  9198. <filename>qemux86</filename> databases through an
  9199. HTTP server named <filename>my.server</filename>.
  9200. On the target, create a configuration file
  9201. (e.g. <filename>my_repo.conf</filename>) inside the
  9202. <filename>/etc/opkg/</filename> directory containing
  9203. the following:
  9204. <literallayout class='monospaced'>
  9205. src/gz all http://my.server/ipk/all
  9206. src/gz i586 http://my.server/ipk/i586
  9207. src/gz qemux86 http://my.server/ipk/qemux86
  9208. </literallayout>
  9209. Next, instruct <filename>opkg</filename> to fetch
  9210. the repository information:
  9211. <literallayout class='monospaced'>
  9212. # opkg update
  9213. </literallayout>
  9214. The <filename>opkg</filename> application is now able
  9215. to find, install, and upgrade packages from the
  9216. specified repository.
  9217. </para>
  9218. </section>
  9219. <section id='runtime-package-management-target-deb'>
  9220. <title>Using DEB</title>
  9221. <para>
  9222. The <filename>apt</filename> application performs
  9223. runtime package management of DEB packages.
  9224. This application uses a source list file to find
  9225. available package databases.
  9226. You must perform an initial setup for
  9227. <filename>apt</filename> on the target machine
  9228. if the
  9229. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9230. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  9231. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9232. variables have not been set or the target image was
  9233. built before the variables were set.
  9234. </para>
  9235. <para>
  9236. To inform <filename>apt</filename> of the repository
  9237. you want to use, you might create a list file (e.g.
  9238. <filename>my_repo.list</filename>) inside the
  9239. <filename>/etc/apt/sources.list.d/</filename>
  9240. directory.
  9241. As an example, suppose you are serving packages from a
  9242. <filename>deb/</filename> directory containing the
  9243. <filename>i586</filename>,
  9244. <filename>all</filename>, and
  9245. <filename>qemux86</filename> databases through an
  9246. HTTP server named <filename>my.server</filename>.
  9247. The list file should contain:
  9248. <literallayout class='monospaced'>
  9249. deb http://my.server/deb/all ./
  9250. deb http://my.server/deb/i586 ./
  9251. deb http://my.server/deb/qemux86 ./
  9252. </literallayout>
  9253. Next, instruct the <filename>apt</filename>
  9254. application to fetch the repository information:
  9255. <literallayout class='monospaced'>
  9256. # apt-get update
  9257. </literallayout>
  9258. After this step, <filename>apt</filename> is able
  9259. to find, install, and upgrade packages from the
  9260. specified repository.
  9261. </para>
  9262. </section>
  9263. </section>
  9264. </section>
  9265. <section id='generating-and-using-signed-packages'>
  9266. <title>Generating and Using Signed Packages</title>
  9267. <para>
  9268. In order to add security to RPM packages used during a build,
  9269. you can take steps to securely sign them.
  9270. Once a signature is verified, the OpenEmbedded build system
  9271. can use the package in the build.
  9272. If security fails for a signed package, the build system
  9273. aborts the build.
  9274. </para>
  9275. <para>
  9276. This section describes how to sign RPM packages during a build
  9277. and how to use signed package feeds (repositories) when
  9278. doing a build.
  9279. </para>
  9280. <section id='signing-rpm-packages'>
  9281. <title>Signing RPM Packages</title>
  9282. <para>
  9283. To enable signing RPM packages, you must set up the
  9284. following configurations in either your
  9285. <filename>local.config</filename> or
  9286. <filename>distro.config</filename> file:
  9287. <literallayout class='monospaced'>
  9288. # Inherit sign_rpm.bbclass to enable signing functionality
  9289. INHERIT += " sign_rpm"
  9290. # Define the GPG key that will be used for signing.
  9291. RPM_GPG_NAME = "<replaceable>key_name</replaceable>"
  9292. # Provide passphrase for the key
  9293. RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>"
  9294. </literallayout>
  9295. <note>
  9296. Be sure to supply appropriate values for both
  9297. <replaceable>key_name</replaceable> and
  9298. <replaceable>passphrase</replaceable>
  9299. </note>
  9300. Aside from the
  9301. <filename>RPM_GPG_NAME</filename> and
  9302. <filename>RPM_GPG_PASSPHRASE</filename> variables in the
  9303. previous example, two optional variables related to signing
  9304. exist:
  9305. <itemizedlist>
  9306. <listitem><para>
  9307. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  9308. Specifies a <filename>gpg</filename> binary/wrapper
  9309. that is executed when the package is signed.
  9310. </para></listitem>
  9311. <listitem><para>
  9312. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  9313. Specifies the <filename>gpg</filename> home
  9314. directory used when the package is signed.
  9315. </para></listitem>
  9316. </itemizedlist>
  9317. </para>
  9318. </section>
  9319. <section id='processing-package-feeds'>
  9320. <title>Processing Package Feeds</title>
  9321. <para>
  9322. In addition to being able to sign RPM packages, you can
  9323. also enable signed package feeds for IPK and RPM packages.
  9324. </para>
  9325. <para>
  9326. The steps you need to take to enable signed package feed
  9327. use are similar to the steps used to sign RPM packages.
  9328. You must define the following in your
  9329. <filename>local.config</filename> or
  9330. <filename>distro.config</filename> file:
  9331. <literallayout class='monospaced'>
  9332. INHERIT += "sign_package_feed"
  9333. PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>"
  9334. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>"
  9335. </literallayout>
  9336. For signed package feeds, the passphrase must exist in a
  9337. separate file, which is pointed to by the
  9338. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  9339. variable.
  9340. Regarding security, keeping a plain text passphrase out of
  9341. the configuration is more secure.
  9342. </para>
  9343. <para>
  9344. Aside from the
  9345. <filename>PACKAGE_FEED_GPG_NAME</filename> and
  9346. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  9347. variables, three optional variables related to signed
  9348. package feeds exist:
  9349. <itemizedlist>
  9350. <listitem><para>
  9351. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  9352. Specifies a <filename>gpg</filename> binary/wrapper
  9353. that is executed when the package is signed.
  9354. </para></listitem>
  9355. <listitem><para>
  9356. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  9357. Specifies the <filename>gpg</filename> home
  9358. directory used when the package is signed.
  9359. </para></listitem>
  9360. <listitem><para>
  9361. <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis>
  9362. Specifies the type of <filename>gpg</filename>
  9363. signature.
  9364. This variable applies only to RPM and IPK package
  9365. feeds.
  9366. Allowable values for the
  9367. <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>
  9368. are "ASC", which is the default and specifies ascii
  9369. armored, and "BIN", which specifies binary.
  9370. </para></listitem>
  9371. </itemizedlist>
  9372. </para>
  9373. </section>
  9374. </section>
  9375. <section id='testing-packages-with-ptest'>
  9376. <title>Testing Packages With ptest</title>
  9377. <para>
  9378. A Package Test (ptest) runs tests against packages built
  9379. by the OpenEmbedded build system on the target machine.
  9380. A ptest contains at least two items: the actual test, and
  9381. a shell script (<filename>run-ptest</filename>) that starts
  9382. the test.
  9383. The shell script that starts the test must not contain
  9384. the actual test - the script only starts the test.
  9385. On the other hand, the test can be anything from a simple
  9386. shell script that runs a binary and checks the output to
  9387. an elaborate system of test binaries and data files.
  9388. </para>
  9389. <para>
  9390. The test generates output in the format used by
  9391. Automake:
  9392. <literallayout class='monospaced'>
  9393. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  9394. </literallayout>
  9395. where the result can be <filename>PASS</filename>,
  9396. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  9397. and the testname can be any identifying string.
  9398. </para>
  9399. <para>
  9400. For a list of Yocto Project recipes that are already
  9401. enabled with ptest, see the
  9402. <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink>
  9403. wiki page.
  9404. <note>
  9405. A recipe is "ptest-enabled" if it inherits the
  9406. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  9407. class.
  9408. </note>
  9409. </para>
  9410. <section id='adding-ptest-to-your-build'>
  9411. <title>Adding ptest to Your Build</title>
  9412. <para>
  9413. To add package testing to your build, add the
  9414. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  9415. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  9416. variables to your <filename>local.conf</filename> file,
  9417. which is found in the
  9418. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  9419. <literallayout class='monospaced'>
  9420. DISTRO_FEATURES_append = " ptest"
  9421. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  9422. </literallayout>
  9423. Once your build is complete, the ptest files are installed
  9424. into the
  9425. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  9426. directory within the image, where
  9427. <filename><replaceable>package</replaceable></filename>
  9428. is the name of the package.
  9429. </para>
  9430. </section>
  9431. <section id='running-ptest'>
  9432. <title>Running ptest</title>
  9433. <para>
  9434. The <filename>ptest-runner</filename> package installs a
  9435. shell script that loops through all installed ptest test
  9436. suites and runs them in sequence.
  9437. Consequently, you might want to add this package to
  9438. your image.
  9439. </para>
  9440. </section>
  9441. <section id='getting-your-package-ready'>
  9442. <title>Getting Your Package Ready</title>
  9443. <para>
  9444. In order to enable a recipe to run installed ptests
  9445. on target hardware,
  9446. you need to prepare the recipes that build the packages
  9447. you want to test.
  9448. Here is what you have to do for each recipe:
  9449. <itemizedlist>
  9450. <listitem><para><emphasis>Be sure the recipe
  9451. inherits the
  9452. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  9453. class:</emphasis>
  9454. Include the following line in each recipe:
  9455. <literallayout class='monospaced'>
  9456. inherit ptest
  9457. </literallayout>
  9458. </para></listitem>
  9459. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  9460. This script starts your test.
  9461. Locate the script where you will refer to it
  9462. using
  9463. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  9464. Here is an example that starts a test for
  9465. <filename>dbus</filename>:
  9466. <literallayout class='monospaced'>
  9467. #!/bin/sh
  9468. cd test
  9469. make -k runtest-TESTS
  9470. </literallayout>
  9471. </para></listitem>
  9472. <listitem><para><emphasis>Ensure dependencies are
  9473. met:</emphasis>
  9474. If the test adds build or runtime dependencies
  9475. that normally do not exist for the package
  9476. (such as requiring "make" to run the test suite),
  9477. use the
  9478. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  9479. and
  9480. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  9481. variables in your recipe in order for the package
  9482. to meet the dependencies.
  9483. Here is an example where the package has a runtime
  9484. dependency on "make":
  9485. <literallayout class='monospaced'>
  9486. RDEPENDS_${PN}-ptest += "make"
  9487. </literallayout>
  9488. </para></listitem>
  9489. <listitem><para><emphasis>Add a function to build the
  9490. test suite:</emphasis>
  9491. Not many packages support cross-compilation of
  9492. their test suites.
  9493. Consequently, you usually need to add a
  9494. cross-compilation function to the package.
  9495. </para>
  9496. <para>Many packages based on Automake compile and
  9497. run the test suite by using a single command
  9498. such as <filename>make check</filename>.
  9499. However, the host <filename>make check</filename>
  9500. builds and runs on the same computer, while
  9501. cross-compiling requires that the package is built
  9502. on the host but executed for the target
  9503. architecture (though often, as in the case for
  9504. ptest, the execution occurs on the host).
  9505. The built version of Automake that ships with the
  9506. Yocto Project includes a patch that separates
  9507. building and execution.
  9508. Consequently, packages that use the unaltered,
  9509. patched version of <filename>make check</filename>
  9510. automatically cross-compiles.</para>
  9511. <para>Regardless, you still must add a
  9512. <filename>do_compile_ptest</filename> function to
  9513. build the test suite.
  9514. Add a function similar to the following to your
  9515. recipe:
  9516. <literallayout class='monospaced'>
  9517. do_compile_ptest() {
  9518. oe_runmake buildtest-TESTS
  9519. }
  9520. </literallayout>
  9521. </para></listitem>
  9522. <listitem><para><emphasis>Ensure special configurations
  9523. are set:</emphasis>
  9524. If the package requires special configurations
  9525. prior to compiling the test code, you must
  9526. insert a <filename>do_configure_ptest</filename>
  9527. function into the recipe.
  9528. </para></listitem>
  9529. <listitem><para><emphasis>Install the test
  9530. suite:</emphasis>
  9531. The <filename>ptest</filename> class
  9532. automatically copies the file
  9533. <filename>run-ptest</filename> to the target and
  9534. then runs make <filename>install-ptest</filename>
  9535. to run the tests.
  9536. If this is not enough, you need to create a
  9537. <filename>do_install_ptest</filename> function and
  9538. make sure it gets called after the
  9539. "make install-ptest" completes.
  9540. </para></listitem>
  9541. </itemizedlist>
  9542. </para>
  9543. </section>
  9544. </section>
  9545. </section>
  9546. <section id='efficiently-fetching-source-files-during-a-build'>
  9547. <title>Efficiently Fetching Source Files During a Build</title>
  9548. <para>
  9549. The OpenEmbedded build system works with source files located
  9550. through the
  9551. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  9552. variable.
  9553. When you build something using BitBake, a big part of the operation
  9554. is locating and downloading all the source tarballs.
  9555. For images, downloading all the source for various packages can
  9556. take a significant amount of time.
  9557. </para>
  9558. <para>
  9559. This section shows you how you can use mirrors to speed up
  9560. fetching source files and how you can pre-fetch files all of which
  9561. leads to more efficient use of resources and time.
  9562. </para>
  9563. <section id='setting-up-effective-mirrors'>
  9564. <title>Setting up Effective Mirrors</title>
  9565. <para>
  9566. A good deal that goes into a Yocto Project
  9567. build is simply downloading all of the source tarballs.
  9568. Maybe you have been working with another build system
  9569. (OpenEmbedded or Angstrom) for which you have built up a
  9570. sizable directory of source tarballs.
  9571. Or, perhaps someone else has such a directory for which you
  9572. have read access.
  9573. If so, you can save time by adding statements to your
  9574. configuration file so that the build process checks local
  9575. directories first for existing tarballs before checking the
  9576. Internet.
  9577. </para>
  9578. <para>
  9579. Here is an efficient way to set it up in your
  9580. <filename>local.conf</filename> file:
  9581. <literallayout class='monospaced'>
  9582. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  9583. INHERIT += "own-mirrors"
  9584. BB_GENERATE_MIRROR_TARBALLS = "1"
  9585. # BB_NO_NETWORK = "1"
  9586. </literallayout>
  9587. </para>
  9588. <para>
  9589. In the previous example, the
  9590. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  9591. variable causes the OpenEmbedded build system to generate
  9592. tarballs of the Git repositories and store them in the
  9593. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  9594. directory.
  9595. Due to performance reasons, generating and storing these
  9596. tarballs is not the build system's default behavior.
  9597. </para>
  9598. <para>
  9599. You can also use the
  9600. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  9601. variable.
  9602. For an example, see the variable's glossary entry in the
  9603. Yocto Project Reference Manual.
  9604. </para>
  9605. </section>
  9606. <section id='getting-source-files-and-suppressing-the-build'>
  9607. <title>Getting Source Files and Suppressing the Build</title>
  9608. <para>
  9609. Another technique you can use to ready yourself for a
  9610. successive string of build operations, is to pre-fetch
  9611. all the source files without actually starting a build.
  9612. This technique lets you work through any download issues
  9613. and ultimately gathers all the source files into your
  9614. download directory
  9615. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  9616. which is located with
  9617. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  9618. </para>
  9619. <para>
  9620. Use the following BitBake command form to fetch all the
  9621. necessary sources without starting the build:
  9622. <literallayout class='monospaced'>
  9623. $ bitbake -c <replaceable>target</replaceable> runall="fetch"
  9624. </literallayout>
  9625. This variation of the BitBake command guarantees that you
  9626. have all the sources for that BitBake target should you
  9627. disconnect from the Internet and want to do the build
  9628. later offline.
  9629. </para>
  9630. </section>
  9631. </section>
  9632. <section id="selecting-an-initialization-manager">
  9633. <title>Selecting an Initialization Manager</title>
  9634. <para>
  9635. By default, the Yocto Project uses SysVinit as the initialization
  9636. manager.
  9637. However, support also exists for systemd,
  9638. which is a full replacement for init with
  9639. parallel starting of services, reduced shell overhead and other
  9640. features that are used by many distributions.
  9641. </para>
  9642. <para>
  9643. If you want to use SysVinit, you do
  9644. not have to do anything.
  9645. But, if you want to use systemd, you must
  9646. take some steps as described in the following sections.
  9647. </para>
  9648. <section id='using-systemd-exclusively'>
  9649. <title>Using systemd Exclusively</title>
  9650. <para>
  9651. Set the these variables in your distribution configuration
  9652. file as follows:
  9653. <literallayout class='monospaced'>
  9654. DISTRO_FEATURES_append = " systemd"
  9655. VIRTUAL-RUNTIME_init_manager = "systemd"
  9656. </literallayout>
  9657. You can also prevent the SysVinit
  9658. distribution feature from
  9659. being automatically enabled as follows:
  9660. <literallayout class='monospaced'>
  9661. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  9662. </literallayout>
  9663. Doing so removes any redundant SysVinit scripts.
  9664. </para>
  9665. <para>
  9666. To remove initscripts from your image altogether,
  9667. set this variable also:
  9668. <literallayout class='monospaced'>
  9669. VIRTUAL-RUNTIME_initscripts = ""
  9670. </literallayout>
  9671. </para>
  9672. <para>
  9673. For information on the backfill variable, see
  9674. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  9675. </para>
  9676. </section>
  9677. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  9678. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  9679. <para>
  9680. Set these variables in your distribution configuration
  9681. file as follows:
  9682. <literallayout class='monospaced'>
  9683. DISTRO_FEATURES_append = " systemd"
  9684. VIRTUAL-RUNTIME_init_manager = "systemd"
  9685. </literallayout>
  9686. Doing so causes your main image to use the
  9687. <filename>packagegroup-core-boot.bb</filename> recipe and
  9688. systemd.
  9689. The rescue/minimal image cannot use this package group.
  9690. However, it can install SysVinit
  9691. and the appropriate packages will have support for both
  9692. systemd and SysVinit.
  9693. </para>
  9694. </section>
  9695. </section>
  9696. <section id="selecting-dev-manager">
  9697. <title>Selecting a Device Manager</title>
  9698. <para>
  9699. The Yocto Project provides multiple ways to manage the device
  9700. manager (<filename>/dev</filename>):
  9701. <itemizedlist>
  9702. <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis>
  9703. For this case, the <filename>/dev</filename> directory
  9704. is persistent and the required device nodes are created
  9705. during the build.
  9706. </para></listitem>
  9707. <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis>
  9708. For this case, the <filename>/dev</filename> directory
  9709. is provided by the kernel as an in-memory file system and
  9710. is automatically populated by the kernel at runtime.
  9711. Additional configuration of device nodes is done in user
  9712. space by a device manager like
  9713. <filename>udev</filename> or
  9714. <filename>busybox-mdev</filename>.
  9715. </para></listitem>
  9716. </itemizedlist>
  9717. </para>
  9718. <section id="static-dev-management">
  9719. <title>Using Persistent and Pre-Populated<filename>/dev</filename></title>
  9720. <para>
  9721. To use the static method for device population, you need to
  9722. set the
  9723. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  9724. variable to "0" as follows:
  9725. <literallayout class='monospaced'>
  9726. USE_DEVFS = "0"
  9727. </literallayout>
  9728. </para>
  9729. <para>
  9730. The content of the resulting <filename>/dev</filename>
  9731. directory is defined in a Device Table file.
  9732. The
  9733. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink>
  9734. variable defines the Device Table to use and should be set
  9735. in the machine or distro configuration file.
  9736. Alternatively, you can set this variable in your
  9737. <filename>local.conf</filename> configuration file.
  9738. </para>
  9739. <para>
  9740. If you do not define the
  9741. <filename>IMAGE_DEVICE_TABLES</filename> variable, the default
  9742. <filename>device_table-minimal.txt</filename> is used:
  9743. <literallayout class='monospaced'>
  9744. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  9745. </literallayout>
  9746. </para>
  9747. <para>
  9748. The population is handled by the <filename>makedevs</filename>
  9749. utility during image creation:
  9750. </para>
  9751. </section>
  9752. <section id="devtmpfs-dev-management">
  9753. <title>Using <filename>devtmpfs</filename> and a Device Manager</title>
  9754. <para>
  9755. To use the dynamic method for device population, you need to
  9756. use (or be sure to set) the
  9757. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  9758. variable to "1", which is the default:
  9759. <literallayout class='monospaced'>
  9760. USE_DEVFS = "1"
  9761. </literallayout>
  9762. With this setting, the resulting <filename>/dev</filename>
  9763. directory is populated by the kernel using
  9764. <filename>devtmpfs</filename>.
  9765. Make sure the corresponding kernel configuration variable
  9766. <filename>CONFIG_DEVTMPFS</filename> is set when building
  9767. you build a Linux kernel.
  9768. </para>
  9769. <para>
  9770. All devices created by <filename>devtmpfs</filename> will be
  9771. owned by <filename>root</filename> and have permissions
  9772. <filename>0600</filename>.
  9773. </para>
  9774. <para>
  9775. To have more control over the device nodes, you can use a
  9776. device manager like <filename>udev</filename> or
  9777. <filename>busybox-mdev</filename>.
  9778. You choose the device manager by defining the
  9779. <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable
  9780. in your machine or distro configuration file.
  9781. Alternatively, you can set this variable in your
  9782. <filename>local.conf</filename> configuration file:
  9783. <literallayout class='monospaced'>
  9784. VIRTUAL-RUNTIME_dev_manager = "udev"
  9785. # Some alternative values
  9786. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  9787. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  9788. </literallayout>
  9789. </para>
  9790. </section>
  9791. </section>
  9792. <section id="platdev-appdev-srcrev">
  9793. <title>Using an External SCM</title>
  9794. <para>
  9795. If you're working on a recipe that pulls from an external Source
  9796. Code Manager (SCM), it is possible to have the OpenEmbedded build
  9797. system notice new recipe changes added to the SCM and then build
  9798. the resulting packages that depend on the new recipes by using
  9799. the latest versions.
  9800. This only works for SCMs from which it is possible to get a
  9801. sensible revision number for changes.
  9802. Currently, you can do this with Apache Subversion (SVN), Git, and
  9803. Bazaar (BZR) repositories.
  9804. </para>
  9805. <para>
  9806. To enable this behavior, the
  9807. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  9808. of the recipe needs to reference
  9809. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  9810. Here is an example:
  9811. <literallayout class='monospaced'>
  9812. PV = "1.2.3+git${SRCPV}"
  9813. </literallayout>
  9814. Then, you can add the following to your
  9815. <filename>local.conf</filename>:
  9816. <literallayout class='monospaced'>
  9817. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  9818. </literallayout>
  9819. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  9820. is the name of the recipe for which you want to enable automatic source
  9821. revision updating.
  9822. </para>
  9823. <para>
  9824. If you do not want to update your local configuration file, you can
  9825. add the following directly to the recipe to finish enabling
  9826. the feature:
  9827. <literallayout class='monospaced'>
  9828. SRCREV = "${AUTOREV}"
  9829. </literallayout>
  9830. </para>
  9831. <para>
  9832. The Yocto Project provides a distribution named
  9833. <filename>poky-bleeding</filename>, whose configuration
  9834. file contains the line:
  9835. <literallayout class='monospaced'>
  9836. require conf/distro/include/poky-floating-revisions.inc
  9837. </literallayout>
  9838. This line pulls in the listed include file that contains
  9839. numerous lines of exactly that form:
  9840. <literallayout class='monospaced'>
  9841. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  9842. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  9843. #SRCREV_pn-opkg ?= "${AUTOREV}"
  9844. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  9845. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  9846. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  9847. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  9848. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  9849. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  9850. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  9851. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  9852. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  9853. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  9854. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  9855. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  9856. SRCREV_pn-screenshot ?= "${AUTOREV}"
  9857. .
  9858. .
  9859. .
  9860. </literallayout>
  9861. These lines allow you to experiment with building a
  9862. distribution that tracks the latest development source
  9863. for numerous packages.
  9864. <note><title>Caution</title>
  9865. The <filename>poky-bleeding</filename> distribution
  9866. is not tested on a regular basis.
  9867. Keep this in mind if you use it.
  9868. </note>
  9869. </para>
  9870. </section>
  9871. <section id='creating-a-read-only-root-filesystem'>
  9872. <title>Creating a Read-Only Root Filesystem</title>
  9873. <para>
  9874. Suppose, for security reasons, you need to disable
  9875. your target device's root filesystem's write permissions
  9876. (i.e. you need a read-only root filesystem).
  9877. Or, perhaps you are running the device's operating system
  9878. from a read-only storage device.
  9879. For either case, you can customize your image for
  9880. that behavior.
  9881. </para>
  9882. <note>
  9883. Supporting a read-only root filesystem requires that the system and
  9884. applications do not try to write to the root filesystem.
  9885. You must configure all parts of the target system to write
  9886. elsewhere, or to gracefully fail in the event of attempting to
  9887. write to the root filesystem.
  9888. </note>
  9889. <section id='creating-the-root-filesystem'>
  9890. <title>Creating the Root Filesystem</title>
  9891. <para>
  9892. To create the read-only root filesystem, simply add the
  9893. "read-only-rootfs" feature to your image.
  9894. Using either of the following statements in your
  9895. image recipe or from within the
  9896. <filename>local.conf</filename> file found in the
  9897. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9898. causes the build system to create a read-only root filesystem:
  9899. <literallayout class='monospaced'>
  9900. IMAGE_FEATURES = "read-only-rootfs"
  9901. </literallayout>
  9902. or
  9903. <literallayout class='monospaced'>
  9904. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  9905. </literallayout>
  9906. </para>
  9907. <para>
  9908. For more information on how to use these variables, see the
  9909. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  9910. section.
  9911. For information on the variables, see
  9912. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  9913. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  9914. </para>
  9915. </section>
  9916. <section id='post-installation-scripts'>
  9917. <title>Post-Installation Scripts</title>
  9918. <para>
  9919. It is very important that you make sure all
  9920. post-Installation (<filename>pkg_postinst</filename>) scripts
  9921. for packages that are installed into the image can be run
  9922. at the time when the root filesystem is created during the
  9923. build on the host system.
  9924. These scripts cannot attempt to run during first-boot on the
  9925. target device.
  9926. With the "read-only-rootfs" feature enabled,
  9927. the build system checks during root filesystem creation to make
  9928. sure all post-installation scripts succeed.
  9929. If any of these scripts still need to be run after the root
  9930. filesystem is created, the build immediately fails.
  9931. These build-time checks ensure that the build fails
  9932. rather than the target device fails later during its
  9933. initial boot operation.
  9934. </para>
  9935. <para>
  9936. Most of the common post-installation scripts generated by the
  9937. build system for the out-of-the-box Yocto Project are engineered
  9938. so that they can run during root filesystem creation
  9939. (e.g. post-installation scripts for caching fonts).
  9940. However, if you create and add custom scripts, you need
  9941. to be sure they can be run during this file system creation.
  9942. </para>
  9943. <para>
  9944. Here are some common problems that prevent
  9945. post-installation scripts from running during root filesystem
  9946. creation:
  9947. <itemizedlist>
  9948. <listitem><para>
  9949. <emphasis>Not using $D in front of absolute
  9950. paths:</emphasis>
  9951. The build system defines
  9952. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  9953. when the root filesystem is created.
  9954. Furthermore, <filename>$D</filename> is blank when the
  9955. script is run on the target device.
  9956. This implies two purposes for <filename>$D</filename>:
  9957. ensuring paths are valid in both the host and target
  9958. environments, and checking to determine which
  9959. environment is being used as a method for taking
  9960. appropriate actions.
  9961. </para></listitem>
  9962. <listitem><para>
  9963. <emphasis>Attempting to run processes that are
  9964. specific to or dependent on the target
  9965. architecture:</emphasis>
  9966. You can work around these attempts by using native
  9967. tools, which run on the host system,
  9968. to accomplish the same tasks, or
  9969. by alternatively running the processes under QEMU,
  9970. which has the <filename>qemu_run_binary</filename>
  9971. function.
  9972. For more information, see the
  9973. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  9974. class.</para></listitem>
  9975. </itemizedlist>
  9976. </para>
  9977. </section>
  9978. <section id='areas-with-write-access'>
  9979. <title>Areas With Write Access</title>
  9980. <para>
  9981. With the "read-only-rootfs" feature enabled,
  9982. any attempt by the target to write to the root filesystem at
  9983. runtime fails.
  9984. Consequently, you must make sure that you configure processes
  9985. and applications that attempt these types of writes do so
  9986. to directories with write access (e.g.
  9987. <filename>/tmp</filename> or <filename>/var/run</filename>).
  9988. </para>
  9989. </section>
  9990. </section>
  9991. <section id='maintaining-build-output-quality'>
  9992. <title>Maintaining Build Output Quality</title>
  9993. <para>
  9994. Many factors can influence the quality of a build.
  9995. For example, if you upgrade a recipe to use a new version of an
  9996. upstream software package or you experiment with some new
  9997. configuration options, subtle changes can occur that you might
  9998. not detect until later.
  9999. Consider the case where your recipe is using a newer version of
  10000. an upstream package.
  10001. In this case, a new version of a piece of software might
  10002. introduce an optional dependency on another library, which is
  10003. auto-detected.
  10004. If that library has already been built when the software is
  10005. building, the software will link to the built library and that
  10006. library will be pulled into your image along with the new
  10007. software even if you did not want the library.
  10008. </para>
  10009. <para>
  10010. The
  10011. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-buildhistory'><filename>buildhistory</filename></ulink>
  10012. class exists to help you maintain the quality of your build
  10013. output.
  10014. You can use the class to highlight unexpected and possibly
  10015. unwanted changes in the build output.
  10016. When you enable build history, it records information about the
  10017. contents of each package and image and then commits that
  10018. information to a local Git repository where you can examine
  10019. the information.
  10020. </para>
  10021. <para>
  10022. The remainder of this section describes the following:
  10023. <itemizedlist>
  10024. <listitem><para>
  10025. How you can enable and disable build history
  10026. </para></listitem>
  10027. <listitem><para>
  10028. How to understand what the build history contains
  10029. </para></listitem>
  10030. <listitem><para>
  10031. How to limit the information used for build history
  10032. </para></listitem>
  10033. <listitem><para>
  10034. How to examine the build history from both a
  10035. command-line and web interface
  10036. </para></listitem>
  10037. </itemizedlist>
  10038. </para>
  10039. <section id='enabling-and-disabling-build-history'>
  10040. <title>Enabling and Disabling Build History</title>
  10041. <para>
  10042. Build history is disabled by default.
  10043. To enable it, add the following <filename>INHERIT</filename>
  10044. statement and set the
  10045. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink>
  10046. variable to "1" at the end of your
  10047. <filename>conf/local.conf</filename> file found in the
  10048. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  10049. <literallayout class='monospaced'>
  10050. INHERIT += "buildhistory"
  10051. BUILDHISTORY_COMMIT = "1"
  10052. </literallayout>
  10053. Enabling build history as previously described causes the
  10054. OpenEmbedded build system to collect build output information
  10055. and commit it as a single commit to a local
  10056. <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>
  10057. repository.
  10058. <note>
  10059. Enabling build history increases your build times slightly,
  10060. particularly for images, and increases the amount of disk
  10061. space used during the build.
  10062. </note>
  10063. </para>
  10064. <para>
  10065. You can disable build history by removing the previous
  10066. statements from your <filename>conf/local.conf</filename>
  10067. file.
  10068. </para>
  10069. </section>
  10070. <section id='understanding-what-the-build-history-contains'>
  10071. <title>Understanding What the Build History Contains</title>
  10072. <para>
  10073. Build history information is kept in
  10074. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink><filename>}/buildhistory</filename>
  10075. in the Build Directory as defined by the
  10076. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></ulink>
  10077. variable.
  10078. The following is an example abbreviated listing:
  10079. <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" />
  10080. </para>
  10081. <para>
  10082. At the top level, a <filename>metadata-revs</filename>
  10083. file exists that lists the revisions of the repositories for
  10084. the enabled layers when the build was produced.
  10085. The rest of the data splits into separate
  10086. <filename>packages</filename>, <filename>images</filename>
  10087. and <filename>sdk</filename> directories, the contents of
  10088. which are described as follows.
  10089. </para>
  10090. <section id='build-history-package-information'>
  10091. <title>Build History Package Information</title>
  10092. <para>
  10093. The history for each package contains a text file that has
  10094. name-value pairs with information about the package.
  10095. For example,
  10096. <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename>
  10097. contains the following:
  10098. <literallayout class='monospaced'>
  10099. PV = 1.22.1
  10100. PR = r32
  10101. RPROVIDES =
  10102. RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
  10103. RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
  10104. PKGSIZE = 540168
  10105. FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
  10106. /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
  10107. /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
  10108. /usr/share/pixmaps /usr/share/applications /usr/share/idl \
  10109. /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
  10110. FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
  10111. /etc/busybox.links.nosuid /etc/busybox.links.suid
  10112. </literallayout>
  10113. Most of these name-value pairs correspond to variables
  10114. used to produce the package.
  10115. The exceptions are <filename>FILELIST</filename>, which
  10116. is the actual list of files in the package, and
  10117. <filename>PKGSIZE</filename>, which is the total size of
  10118. files in the package in bytes.
  10119. </para>
  10120. <para>
  10121. A file also exists that corresponds to the recipe from
  10122. which the package came (e.g.
  10123. <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>):
  10124. <literallayout class='monospaced'>
  10125. PV = 1.22.1
  10126. PR = r32
  10127. DEPENDS = initscripts kern-tools-native update-rc.d-native \
  10128. virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
  10129. virtual/libc virtual/update-alternatives
  10130. PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
  10131. busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
  10132. busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
  10133. </literallayout>
  10134. </para>
  10135. <para>
  10136. Finally, for those recipes fetched from a version control
  10137. system (e.g., Git), a file exists that lists source
  10138. revisions that are specified in the recipe and lists
  10139. the actual revisions used during the build.
  10140. Listed and actual revisions might differ when
  10141. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  10142. is set to
  10143. ${<ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>}.
  10144. Here is an example assuming
  10145. <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>):
  10146. <literallayout class='monospaced'>
  10147. # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  10148. SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  10149. # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  10150. SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  10151. </literallayout>
  10152. You can use the
  10153. <filename>buildhistory-collect-srcrevs</filename>
  10154. command with the <filename>-a</filename> option to
  10155. collect the stored <filename>SRCREV</filename> values
  10156. from build history and report them in a format suitable for
  10157. use in global configuration (e.g.,
  10158. <filename>local.conf</filename> or a distro include file)
  10159. to override floating <filename>AUTOREV</filename> values
  10160. to a fixed set of revisions.
  10161. Here is some example output from this command:
  10162. <literallayout class='monospaced'>
  10163. $ buildhistory-collect-srcrevs -a
  10164. # i586-poky-linux
  10165. SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
  10166. SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
  10167. SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
  10168. SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  10169. # x86_64-linux
  10170. SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
  10171. SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
  10172. SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
  10173. SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
  10174. SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
  10175. SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
  10176. SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
  10177. SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
  10178. SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  10179. # qemux86-poky-linux
  10180. SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  10181. SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
  10182. # all-poky-linux
  10183. SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
  10184. </literallayout>
  10185. <note>
  10186. Here are some notes on using the
  10187. <filename>buildhistory-collect-srcrevs</filename>
  10188. command:
  10189. <itemizedlist>
  10190. <listitem><para>
  10191. By default, only values where the
  10192. <filename>SRCREV</filename> was not hardcoded
  10193. (usually when <filename>AUTOREV</filename>
  10194. is used) are reported.
  10195. Use the <filename>-a</filename> option to
  10196. see all <filename>SRCREV</filename> values.
  10197. </para></listitem>
  10198. <listitem><para>
  10199. The output statements might not have any effect
  10200. if overrides are applied elsewhere in the
  10201. build system configuration.
  10202. Use the <filename>-f</filename> option to add
  10203. the <filename>forcevariable</filename> override
  10204. to each output line if you need to work around
  10205. this restriction.
  10206. </para></listitem>
  10207. <listitem><para>
  10208. The script does apply special handling when
  10209. building for multiple machines.
  10210. However, the script does place a comment before
  10211. each set of values that specifies which
  10212. triplet to which they belong as previously
  10213. shown (e.g.,
  10214. <filename>i586-poky-linux</filename>).
  10215. </para></listitem>
  10216. </itemizedlist>
  10217. </note>
  10218. </para>
  10219. </section>
  10220. <section id='build-history-image-information'>
  10221. <title>Build History Image Information</title>
  10222. <para>
  10223. The files produced for each image are as follows:
  10224. <itemizedlist>
  10225. <listitem><para>
  10226. <filename>image-files:</filename>
  10227. A directory containing selected files from the root
  10228. filesystem.
  10229. The files are defined by
  10230. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></ulink>.
  10231. </para></listitem>
  10232. <listitem><para>
  10233. <filename>build-id.txt:</filename>
  10234. Human-readable information about the build
  10235. configuration and metadata source revisions.
  10236. This file contains the full build header as printed
  10237. by BitBake.
  10238. </para></listitem>
  10239. <listitem><para>
  10240. <filename>*.dot:</filename>
  10241. Dependency graphs for the image that are
  10242. compatible with <filename>graphviz</filename>.
  10243. </para></listitem>
  10244. <listitem><para>
  10245. <filename>files-in-image.txt:</filename>
  10246. A list of files in the image with permissions,
  10247. owner, group, size, and symlink information.
  10248. </para></listitem>
  10249. <listitem><para>
  10250. <filename>image-info.txt:</filename>
  10251. A text file containing name-value pairs with
  10252. information about the image.
  10253. See the following listing example for more
  10254. information.
  10255. </para></listitem>
  10256. <listitem><para>
  10257. <filename>installed-package-names.txt:</filename>
  10258. A list of installed packages by name only.
  10259. </para></listitem>
  10260. <listitem><para>
  10261. <filename>installed-package-sizes.txt:</filename>
  10262. A list of installed packages ordered by size.
  10263. </para></listitem>
  10264. <listitem><para>
  10265. <filename>installed-packages.txt:</filename>
  10266. A list of installed packages with full package
  10267. filenames.
  10268. </para></listitem>
  10269. </itemizedlist>
  10270. <note>
  10271. Installed package information is able to be gathered
  10272. and produced even if package management is disabled
  10273. for the final image.
  10274. </note>
  10275. </para>
  10276. <para>
  10277. Here is an example of <filename>image-info.txt</filename>:
  10278. <literallayout class='monospaced'>
  10279. DISTRO = poky
  10280. DISTRO_VERSION = 1.7
  10281. USER_CLASSES = buildstats image-mklibs image-prelink
  10282. IMAGE_CLASSES = image_types
  10283. IMAGE_FEATURES = debug-tweaks
  10284. IMAGE_LINGUAS =
  10285. IMAGE_INSTALL = packagegroup-core-boot run-postinsts
  10286. BAD_RECOMMENDATIONS =
  10287. NO_RECOMMENDATIONS =
  10288. PACKAGE_EXCLUDE =
  10289. ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
  10290. write_image_manifest ; buildhistory_list_installed_image ; \
  10291. buildhistory_get_image_installed ; ssh_allow_empty_password; \
  10292. postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
  10293. IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
  10294. IMAGESIZE = 6900
  10295. </literallayout>
  10296. Other than <filename>IMAGESIZE</filename>, which is the
  10297. total size of the files in the image in Kbytes, the
  10298. name-value pairs are variables that may have influenced the
  10299. content of the image.
  10300. This information is often useful when you are trying to
  10301. determine why a change in the package or file
  10302. listings has occurred.
  10303. </para>
  10304. </section>
  10305. <section id='using-build-history-to-gather-image-information-only'>
  10306. <title>Using Build History to Gather Image Information Only</title>
  10307. <para>
  10308. As you can see, build history produces image information,
  10309. including dependency graphs, so you can see why something
  10310. was pulled into the image.
  10311. If you are just interested in this information and not
  10312. interested in collecting specific package or SDK
  10313. information, you can enable writing only image information
  10314. without any history by adding the following to your
  10315. <filename>conf/local.conf</filename> file found in the
  10316. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  10317. <literallayout class='monospaced'>
  10318. INHERIT += "buildhistory"
  10319. BUILDHISTORY_COMMIT = "0"
  10320. BUILDHISTORY_FEATURES = "image"
  10321. </literallayout>
  10322. Here, you set the
  10323. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></ulink>
  10324. variable to use the image feature only.
  10325. </para>
  10326. </section>
  10327. <section id='build-history-sdk-information'>
  10328. <title>Build History SDK Information</title>
  10329. <para>
  10330. Build history collects similar information on the contents
  10331. of SDKs
  10332. (e.g. <filename>bitbake -c populate_sdk imagename</filename>)
  10333. as compared to information it collects for images.
  10334. Furthermore, this information differs depending on whether
  10335. an extensible or standard SDK is being produced.
  10336. </para>
  10337. <para>
  10338. The following list shows the files produced for SDKs:
  10339. <itemizedlist>
  10340. <listitem><para>
  10341. <filename>files-in-sdk.txt:</filename>
  10342. A list of files in the SDK with permissions,
  10343. owner, group, size, and symlink information.
  10344. This list includes both the host and target parts
  10345. of the SDK.
  10346. </para></listitem>
  10347. <listitem><para>
  10348. <filename>sdk-info.txt:</filename>
  10349. A text file containing name-value pairs with
  10350. information about the SDK.
  10351. See the following listing example for more
  10352. information.
  10353. </para></listitem>
  10354. <listitem><para>
  10355. <filename>sstate-task-sizes.txt:</filename>
  10356. A text file containing name-value pairs with
  10357. information about task group sizes
  10358. (e.g. <filename>do_populate_sysroot</filename>
  10359. tasks have a total size).
  10360. The <filename>sstate-task-sizes.txt</filename> file
  10361. exists only when an extensible SDK is created.
  10362. </para></listitem>
  10363. <listitem><para>
  10364. <filename>sstate-package-sizes.txt:</filename>
  10365. A text file containing name-value pairs with
  10366. information for the shared-state packages and
  10367. sizes in the SDK.
  10368. The <filename>sstate-package-sizes.txt</filename>
  10369. file exists only when an extensible SDK is created.
  10370. </para></listitem>
  10371. <listitem><para>
  10372. <filename>sdk-files:</filename>
  10373. A folder that contains copies of the files
  10374. mentioned in
  10375. <filename>BUILDHISTORY_SDK_FILES</filename> if the
  10376. files are present in the output.
  10377. Additionally, the default value of
  10378. <filename>BUILDHISTORY_SDK_FILES</filename> is
  10379. specific to the extensible SDK although you can
  10380. set it differently if you would like to pull in
  10381. specific files from the standard SDK.</para>
  10382. <para>The default files are
  10383. <filename>conf/local.conf</filename>,
  10384. <filename>conf/bblayers.conf</filename>,
  10385. <filename>conf/auto.conf</filename>,
  10386. <filename>conf/locked-sigs.inc</filename>, and
  10387. <filename>conf/devtool.conf</filename>.
  10388. Thus, for an extensible SDK, these files get
  10389. copied into the <filename>sdk-files</filename>
  10390. directory.
  10391. </para></listitem>
  10392. <listitem><para>
  10393. The following information appears under
  10394. each of the <filename>host</filename>
  10395. and <filename>target</filename> directories
  10396. for the portions of the SDK that run on the host
  10397. and on the target, respectively:
  10398. <note>
  10399. The following files for the most part are empty
  10400. when producing an extensible SDK because this
  10401. type of SDK is not constructed from packages
  10402. as is the standard SDK.
  10403. </note>
  10404. <itemizedlist>
  10405. <listitem><para>
  10406. <filename>depends.dot:</filename>
  10407. Dependency graph for the SDK that is
  10408. compatible with
  10409. <filename>graphviz</filename>.
  10410. </para></listitem>
  10411. <listitem><para>
  10412. <filename>installed-package-names.txt:</filename>
  10413. A list of installed packages by name only.
  10414. </para></listitem>
  10415. <listitem><para>
  10416. <filename>installed-package-sizes.txt:</filename>
  10417. A list of installed packages ordered by size.
  10418. </para></listitem>
  10419. <listitem><para>
  10420. <filename>installed-packages.txt:</filename>
  10421. A list of installed packages with full
  10422. package filenames.
  10423. </para></listitem>
  10424. </itemizedlist>
  10425. </para></listitem>
  10426. </itemizedlist>
  10427. </para>
  10428. <para>
  10429. Here is an example of <filename>sdk-info.txt</filename>:
  10430. <literallayout class='monospaced'>
  10431. DISTRO = poky
  10432. DISTRO_VERSION = 1.3+snapshot-20130327
  10433. SDK_NAME = poky-glibc-i686-arm
  10434. SDK_VERSION = 1.3+snapshot
  10435. SDKMACHINE =
  10436. SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
  10437. BAD_RECOMMENDATIONS =
  10438. SDKSIZE = 352712
  10439. </literallayout>
  10440. Other than <filename>SDKSIZE</filename>, which is the
  10441. total size of the files in the SDK in Kbytes, the
  10442. name-value pairs are variables that might have influenced
  10443. the content of the SDK.
  10444. This information is often useful when you are trying to
  10445. determine why a change in the package or file listings
  10446. has occurred.
  10447. </para>
  10448. </section>
  10449. <section id='examining-build-history-information'>
  10450. <title>Examining Build History Information</title>
  10451. <para>
  10452. You can examine build history output from the command
  10453. line or from a web interface.
  10454. </para>
  10455. <para>
  10456. To see any changes that have occurred (assuming you have
  10457. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink><filename>&nbsp;= "1"</filename>),
  10458. you can simply use any Git command that allows you to
  10459. view the history of a repository.
  10460. Here is one method:
  10461. <literallayout class='monospaced'>
  10462. $ git log -p
  10463. </literallayout>
  10464. You need to realize, however, that this method does show
  10465. changes that are not significant (e.g. a package's size
  10466. changing by a few bytes).
  10467. </para>
  10468. <para>
  10469. A command-line tool called
  10470. <filename>buildhistory-diff</filename> does exist, though,
  10471. that queries the Git repository and prints just the
  10472. differences that might be significant in human-readable
  10473. form.
  10474. Here is an example:
  10475. <literallayout class='monospaced'>
  10476. $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
  10477. Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
  10478. /etc/anotherpkg.conf was added
  10479. /sbin/anotherpkg was added
  10480. * (installed-package-names.txt):
  10481. * anotherpkg was added
  10482. Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
  10483. anotherpkg was added
  10484. packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
  10485. * PR changed from "r0" to "r1"
  10486. * PV changed from "0.1.10" to "0.1.12"
  10487. packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
  10488. * PR changed from "r0" to "r1"
  10489. * PV changed from "0.1.10" to "0.1.12"
  10490. </literallayout>
  10491. <note>
  10492. The <filename>buildhistory-diff</filename> tool
  10493. requires the <filename>GitPython</filename> package.
  10494. Be sure to install it using Pip3 as follows:
  10495. <literallayout class='monospaced'>
  10496. $ pip3 install GitPython --user
  10497. </literallayout>
  10498. Alternatively, you can install
  10499. <filename>python3-git</filename> using the appropriate
  10500. distribution package manager (e.g.
  10501. <filename>apt-get</filename>, <filename>dnf</filename>,
  10502. or <filename>zipper</filename>).
  10503. </note>
  10504. </para>
  10505. <para>
  10506. To see changes to the build history using a web interface,
  10507. follow the instruction in the <filename>README</filename>
  10508. file here.
  10509. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>.
  10510. </para>
  10511. <para>
  10512. Here is a sample screenshot of the interface:
  10513. <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" />
  10514. </para>
  10515. </section>
  10516. </section>
  10517. </section>
  10518. <section id="performing-automated-runtime-testing">
  10519. <title>Performing Automated Runtime Testing</title>
  10520. <para>
  10521. The OpenEmbedded build system makes available a series of automated
  10522. tests for images to verify runtime functionality.
  10523. You can run these tests on either QEMU or actual target hardware.
  10524. Tests are written in Python making use of the
  10525. <filename>unittest</filename> module, and the majority of them
  10526. run commands on the target system over SSH.
  10527. This section describes how you set up the environment to use these
  10528. tests, run available tests, and write and add your own tests.
  10529. </para>
  10530. <para>
  10531. For information on the test and QA infrastructure available
  10532. within the Yocto Project, see the
  10533. "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>"
  10534. section in the Yocto Project Reference Manual.
  10535. </para>
  10536. <section id='enabling-tests'>
  10537. <title>Enabling Tests</title>
  10538. <para>
  10539. Depending on whether you are planning to run tests using
  10540. QEMU or on the hardware, you have to take
  10541. different steps to enable the tests.
  10542. See the following subsections for information on how to
  10543. enable both types of tests.
  10544. </para>
  10545. <section id='qemu-image-enabling-tests'>
  10546. <title>Enabling Runtime Tests on QEMU</title>
  10547. <para>
  10548. In order to run tests, you need to do the following:
  10549. <itemizedlist>
  10550. <listitem><para><emphasis>Set up to avoid interaction
  10551. with <filename>sudo</filename> for networking:</emphasis>
  10552. To accomplish this, you must do one of the
  10553. following:
  10554. <itemizedlist>
  10555. <listitem><para>Add
  10556. <filename>NOPASSWD</filename> for your user
  10557. in <filename>/etc/sudoers</filename> either for
  10558. all commands or just for
  10559. <filename>runqemu-ifup</filename>.
  10560. You must provide the full path as that can
  10561. change if you are using multiple clones of the
  10562. source repository.
  10563. <note>
  10564. On some distributions, you also need to
  10565. comment out "Defaults requiretty" in
  10566. <filename>/etc/sudoers</filename>.
  10567. </note></para></listitem>
  10568. <listitem><para>Manually configure a tap interface
  10569. for your system.</para></listitem>
  10570. <listitem><para>Run as root the script in
  10571. <filename>scripts/runqemu-gen-tapdevs</filename>,
  10572. which should generate a list of tap devices.
  10573. This is the option typically chosen for
  10574. Autobuilder-type environments.
  10575. <note><title>Notes</title>
  10576. <itemizedlist>
  10577. <listitem><para>
  10578. Be sure to use an absolute path
  10579. when calling this script
  10580. with sudo.
  10581. </para></listitem>
  10582. <listitem><para>
  10583. The package recipe
  10584. <filename>qemu-helper-native</filename>
  10585. is required to run this script.
  10586. Build the package using the
  10587. following command:
  10588. <literallayout class='monospaced'>
  10589. $ bitbake qemu-helper-native
  10590. </literallayout>
  10591. </para></listitem>
  10592. </itemizedlist>
  10593. </note>
  10594. </para></listitem>
  10595. </itemizedlist></para></listitem>
  10596. <listitem><para><emphasis>Set the
  10597. <filename>DISPLAY</filename> variable:</emphasis>
  10598. You need to set this variable so that you have an X
  10599. server available (e.g. start
  10600. <filename>vncserver</filename> for a headless machine).
  10601. </para></listitem>
  10602. <listitem><para><emphasis>Be sure your host's firewall
  10603. accepts incoming connections from
  10604. 192.168.7.0/24:</emphasis>
  10605. Some of the tests (in particular DNF tests) start
  10606. an HTTP server on a random high number port,
  10607. which is used to serve files to the target.
  10608. The DNF module serves
  10609. <filename>${WORKDIR}/oe-rootfs-repo</filename>
  10610. so it can run DNF channel commands.
  10611. That means your host's firewall
  10612. must accept incoming connections from 192.168.7.0/24,
  10613. which is the default IP range used for tap devices
  10614. by <filename>runqemu</filename>.</para></listitem>
  10615. <listitem><para><emphasis>Be sure your host has the
  10616. correct packages installed:</emphasis>
  10617. Depending your host's distribution, you need
  10618. to have the following packages installed:
  10619. <itemizedlist>
  10620. <listitem><para>Ubuntu and Debian:
  10621. <filename>sysstat</filename> and
  10622. <filename>iproute2</filename>
  10623. </para></listitem>
  10624. <listitem><para>OpenSUSE:
  10625. <filename>sysstat</filename> and
  10626. <filename>iproute2</filename>
  10627. </para></listitem>
  10628. <listitem><para>Fedora:
  10629. <filename>sysstat</filename> and
  10630. <filename>iproute</filename>
  10631. </para></listitem>
  10632. <listitem><para>CentOS:
  10633. <filename>sysstat</filename> and
  10634. <filename>iproute</filename>
  10635. </para></listitem>
  10636. </itemizedlist>
  10637. </para></listitem>
  10638. </itemizedlist>
  10639. </para>
  10640. <para>
  10641. Once you start running the tests, the following happens:
  10642. <orderedlist>
  10643. <listitem><para>A copy of the root filesystem is written
  10644. to <filename>${WORKDIR}/testimage</filename>.
  10645. </para></listitem>
  10646. <listitem><para>The image is booted under QEMU using the
  10647. standard <filename>runqemu</filename> script.
  10648. </para></listitem>
  10649. <listitem><para>A default timeout of 500 seconds occurs
  10650. to allow for the boot process to reach the login prompt.
  10651. You can change the timeout period by setting
  10652. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  10653. in the <filename>local.conf</filename> file.
  10654. </para></listitem>
  10655. <listitem><para>Once the boot process is reached and the
  10656. login prompt appears, the tests run.
  10657. The full boot log is written to
  10658. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  10659. </para></listitem>
  10660. <listitem><para>Each test module loads in the order found
  10661. in <filename>TEST_SUITES</filename>.
  10662. You can find the full output of the commands run over
  10663. SSH in
  10664. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  10665. </para></listitem>
  10666. <listitem><para>If no failures occur, the task running the
  10667. tests ends successfully.
  10668. You can find the output from the
  10669. <filename>unittest</filename> in the task log at
  10670. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  10671. </para></listitem>
  10672. </orderedlist>
  10673. </para>
  10674. </section>
  10675. <section id='hardware-image-enabling-tests'>
  10676. <title>Enabling Runtime Tests on Hardware</title>
  10677. <para>
  10678. The OpenEmbedded build system can run tests on real
  10679. hardware, and for certain devices it can also deploy
  10680. the image to be tested onto the device beforehand.
  10681. </para>
  10682. <para>
  10683. For automated deployment, a "master image" is installed
  10684. onto the hardware once as part of setup.
  10685. Then, each time tests are to be run, the following
  10686. occurs:
  10687. <orderedlist>
  10688. <listitem><para>The master image is booted into and
  10689. used to write the image to be tested to
  10690. a second partition.
  10691. </para></listitem>
  10692. <listitem><para>The device is then rebooted using an
  10693. external script that you need to provide.
  10694. </para></listitem>
  10695. <listitem><para>The device boots into the image to be
  10696. tested.
  10697. </para></listitem>
  10698. </orderedlist>
  10699. </para>
  10700. <para>
  10701. When running tests (independent of whether the image
  10702. has been deployed automatically or not), the device is
  10703. expected to be connected to a network on a
  10704. pre-determined IP address.
  10705. You can either use static IP addresses written into
  10706. the image, or set the image to use DHCP and have your
  10707. DHCP server on the test network assign a known IP address
  10708. based on the MAC address of the device.
  10709. </para>
  10710. <para>
  10711. In order to run tests on hardware, you need to set
  10712. <filename>TEST_TARGET</filename> to an appropriate value.
  10713. For QEMU, you do not have to change anything, the default
  10714. value is "QemuTarget".
  10715. For running tests on hardware, the following options exist:
  10716. <itemizedlist>
  10717. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  10718. Choose "SimpleRemoteTarget" if you are going to
  10719. run tests on a target system that is already
  10720. running the image to be tested and is available
  10721. on the network.
  10722. You can use "SimpleRemoteTarget" in conjunction
  10723. with either real hardware or an image running
  10724. within a separately started QEMU or any
  10725. other virtual machine manager.
  10726. </para></listitem>
  10727. <listitem><para><emphasis>"SystemdbootTarget":</emphasis>
  10728. Choose "SystemdbootTarget" if your hardware is
  10729. an EFI-based machine with
  10730. <filename>systemd-boot</filename> as bootloader and
  10731. <filename>core-image-testmaster</filename>
  10732. (or something similar) is installed.
  10733. Also, your hardware under test must be in a
  10734. DHCP-enabled network that gives it the same IP
  10735. address for each reboot.</para>
  10736. <para>If you choose "SystemdbootTarget", there are
  10737. additional requirements and considerations.
  10738. See the
  10739. "<link linkend='selecting-systemdboottarget'>Selecting SystemdbootTarget</link>"
  10740. section, which follows, for more information.
  10741. </para></listitem>
  10742. <listitem><para><emphasis>"BeagleBoneTarget":</emphasis>
  10743. Choose "BeagleBoneTarget" if you are deploying
  10744. images and running tests on the BeagleBone
  10745. "Black" or original "White" hardware.
  10746. For information on how to use these tests, see the
  10747. comments at the top of the BeagleBoneTarget
  10748. <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename>
  10749. file.
  10750. </para></listitem>
  10751. <listitem><para><emphasis>"EdgeRouterTarget":</emphasis>
  10752. Choose "EdgeRouterTarget" is you are deploying
  10753. images and running tests on the Ubiquiti Networks
  10754. EdgeRouter Lite.
  10755. For information on how to use these tests, see the
  10756. comments at the top of the EdgeRouterTarget
  10757. <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename>
  10758. file.
  10759. </para></listitem>
  10760. <listitem><para><emphasis>"GrubTarget":</emphasis>
  10761. Choose the "supports deploying images and running
  10762. tests on any generic PC that boots using GRUB.
  10763. For information on how to use these tests, see the
  10764. comments at the top of the GrubTarget
  10765. <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename>
  10766. file.
  10767. </para></listitem>
  10768. <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis>
  10769. Create your own custom target if you want to run
  10770. tests when you are deploying images and running
  10771. tests on a custom machine within your BSP layer.
  10772. To do this, you need to add a Python unit that
  10773. defines the target class under
  10774. <filename>lib/oeqa/controllers/</filename> within
  10775. your layer.
  10776. You must also provide an empty
  10777. <filename>__init__.py</filename>.
  10778. For examples, see files in
  10779. <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>.
  10780. </para></listitem>
  10781. </itemizedlist>
  10782. </para>
  10783. </section>
  10784. <section id='selecting-systemdboottarget'>
  10785. <title>Selecting SystemdbootTarget</title>
  10786. <para>
  10787. If you did not set <filename>TEST_TARGET</filename> to
  10788. "SystemdbootTarget", then you do not need any information
  10789. in this section.
  10790. You can skip down to the
  10791. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  10792. section.
  10793. </para>
  10794. <para>
  10795. If you did set <filename>TEST_TARGET</filename> to
  10796. "SystemdbootTarget", you also need to perform a one-time
  10797. setup of your master image by doing the following:
  10798. <orderedlist>
  10799. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  10800. Be sure that <filename>EFI_PROVIDER</filename>
  10801. is as follows:
  10802. <literallayout class='monospaced'>
  10803. EFI_PROVIDER = "systemd-boot"
  10804. </literallayout>
  10805. </para></listitem>
  10806. <listitem><para><emphasis>Build the master image:</emphasis>
  10807. Build the <filename>core-image-testmaster</filename>
  10808. image.
  10809. The <filename>core-image-testmaster</filename>
  10810. recipe is provided as an example for a
  10811. "master" image and you can customize the image
  10812. recipe as you would any other recipe.
  10813. </para>
  10814. <para>Here are the image recipe requirements:
  10815. <itemizedlist>
  10816. <listitem><para>Inherits
  10817. <filename>core-image</filename>
  10818. so that kernel modules are installed.
  10819. </para></listitem>
  10820. <listitem><para>Installs normal linux utilities
  10821. not busybox ones (e.g.
  10822. <filename>bash</filename>,
  10823. <filename>coreutils</filename>,
  10824. <filename>tar</filename>,
  10825. <filename>gzip</filename>, and
  10826. <filename>kmod</filename>).
  10827. </para></listitem>
  10828. <listitem><para>Uses a custom
  10829. Initial RAM Disk (initramfs) image with a
  10830. custom installer.
  10831. A normal image that you can install usually
  10832. creates a single rootfs partition.
  10833. This image uses another installer that
  10834. creates a specific partition layout.
  10835. Not all Board Support Packages (BSPs)
  10836. can use an installer.
  10837. For such cases, you need to manually create
  10838. the following partition layout on the
  10839. target:
  10840. <itemizedlist>
  10841. <listitem><para>First partition mounted
  10842. under <filename>/boot</filename>,
  10843. labeled "boot".
  10844. </para></listitem>
  10845. <listitem><para>The main rootfs
  10846. partition where this image gets
  10847. installed, which is mounted under
  10848. <filename>/</filename>.
  10849. </para></listitem>
  10850. <listitem><para>Another partition
  10851. labeled "testrootfs" where test
  10852. images get deployed.
  10853. </para></listitem>
  10854. </itemizedlist>
  10855. </para></listitem>
  10856. </itemizedlist>
  10857. </para></listitem>
  10858. <listitem><para><emphasis>Install image:</emphasis>
  10859. Install the image that you just built on the target
  10860. system.
  10861. </para></listitem>
  10862. </orderedlist>
  10863. </para>
  10864. <para>
  10865. The final thing you need to do when setting
  10866. <filename>TEST_TARGET</filename> to "SystemdbootTarget" is
  10867. to set up the test image:
  10868. <orderedlist>
  10869. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  10870. Make sure you have the following statements in
  10871. your <filename>local.conf</filename> file:
  10872. <literallayout class='monospaced'>
  10873. IMAGE_FSTYPES += "tar.gz"
  10874. INHERIT += "testimage"
  10875. TEST_TARGET = "SystemdbootTarget"
  10876. TEST_TARGET_IP = "192.168.2.3"
  10877. </literallayout>
  10878. </para></listitem>
  10879. <listitem><para><emphasis>Build your test image:</emphasis>
  10880. Use BitBake to build the image:
  10881. <literallayout class='monospaced'>
  10882. $ bitbake core-image-sato
  10883. </literallayout>
  10884. </para></listitem>
  10885. </orderedlist>
  10886. </para>
  10887. </section>
  10888. <section id='power-control'>
  10889. <title>Power Control</title>
  10890. <para>
  10891. For most hardware targets other than SimpleRemoteTarget,
  10892. you can control power:
  10893. <itemizedlist>
  10894. <listitem><para>
  10895. You can use
  10896. <filename>TEST_POWERCONTROL_CMD</filename>
  10897. together with
  10898. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  10899. as a command that runs on the host and does power
  10900. cycling.
  10901. The test code passes one argument to that command:
  10902. off, on or cycle (off then on).
  10903. Here is an example that could appear in your
  10904. <filename>local.conf</filename> file:
  10905. <literallayout class='monospaced'>
  10906. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  10907. </literallayout>
  10908. In this example, the expect script does the
  10909. following:
  10910. <literallayout class='monospaced'>
  10911. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  10912. </literallayout>
  10913. It then runs a Python script that controls power
  10914. for a label called <filename>nuc1</filename>.
  10915. <note>
  10916. You need to customize
  10917. <filename>TEST_POWERCONTROL_CMD</filename>
  10918. and
  10919. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  10920. for your own setup.
  10921. The one requirement is that it accepts
  10922. "on", "off", and "cycle" as the last argument.
  10923. </note>
  10924. </para></listitem>
  10925. <listitem><para>
  10926. When no command is defined, it connects to the
  10927. device over SSH and uses the classic reboot command
  10928. to reboot the device.
  10929. Classic reboot is fine as long as the machine
  10930. actually reboots (i.e. the SSH test has not
  10931. failed).
  10932. It is useful for scenarios where you have a simple
  10933. setup, typically with a single board, and where
  10934. some manual interaction is okay from time to time.
  10935. </para></listitem>
  10936. </itemizedlist>
  10937. If you have no hardware to automatically perform power
  10938. control but still wish to experiment with automated
  10939. hardware testing, you can use the dialog-power-control
  10940. script that shows a dialog prompting you to perform the
  10941. required power action.
  10942. This script requires either KDialog or Zenity to be
  10943. installed.
  10944. To use this script, set the
  10945. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink>
  10946. variable as follows:
  10947. <literallayout class='monospaced'>
  10948. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  10949. </literallayout>
  10950. </para>
  10951. </section>
  10952. <section id='serial-console-connection'>
  10953. <title>Serial Console Connection</title>
  10954. <para>
  10955. For test target classes requiring a serial console
  10956. to interact with the bootloader (e.g. BeagleBoneTarget,
  10957. EdgeRouterTarget, and GrubTarget), you need to
  10958. specify a command to use to connect to the serial console
  10959. of the target machine by using the
  10960. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink>
  10961. variable and optionally the
  10962. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink>
  10963. variable.
  10964. </para>
  10965. <para>
  10966. These cases could be a serial terminal program if the
  10967. machine is connected to a local serial port, or a
  10968. <filename>telnet</filename> or
  10969. <filename>ssh</filename> command connecting to a remote
  10970. console server.
  10971. Regardless of the case, the command simply needs to
  10972. connect to the serial console and forward that connection
  10973. to standard input and output as any normal terminal
  10974. program does.
  10975. For example, to use the picocom terminal program on
  10976. serial device <filename>/dev/ttyUSB0</filename>
  10977. at 115200bps, you would set the variable as follows:
  10978. <literallayout class='monospaced'>
  10979. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  10980. </literallayout>
  10981. For local devices where the serial port device disappears
  10982. when the device reboots, an additional "serdevtry" wrapper
  10983. script is provided.
  10984. To use this wrapper, simply prefix the terminal command
  10985. with
  10986. <filename>${COREBASE}/scripts/contrib/serdevtry</filename>:
  10987. <literallayout class='monospaced'>
  10988. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b
  10989. 115200 /dev/ttyUSB0"
  10990. </literallayout>
  10991. </para>
  10992. </section>
  10993. </section>
  10994. <section id="qemu-image-running-tests">
  10995. <title>Running Tests</title>
  10996. <para>
  10997. You can start the tests automatically or manually:
  10998. <itemizedlist>
  10999. <listitem><para><emphasis>Automatically running tests:</emphasis>
  11000. To run the tests automatically after the
  11001. OpenEmbedded build system successfully creates an image,
  11002. first set the
  11003. <ulink url='&YOCTO_DOCS_REF_URL;#var-TESTIMAGE_AUTO'><filename>TESTIMAGE_AUTO</filename></ulink>
  11004. variable to "1" in your <filename>local.conf</filename>
  11005. file in the
  11006. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  11007. <literallayout class='monospaced'>
  11008. TESTIMAGE_AUTO = "1"
  11009. </literallayout>
  11010. Next, build your image.
  11011. If the image successfully builds, the tests run:
  11012. <literallayout class='monospaced'>
  11013. bitbake core-image-sato
  11014. </literallayout></para></listitem>
  11015. <listitem><para><emphasis>Manually running tests:</emphasis>
  11016. To manually run the tests, first globally inherit the
  11017. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  11018. class by editing your <filename>local.conf</filename>
  11019. file:
  11020. <literallayout class='monospaced'>
  11021. INHERIT += "testimage"
  11022. </literallayout>
  11023. Next, use BitBake to run the tests:
  11024. <literallayout class='monospaced'>
  11025. bitbake -c testimage <replaceable>image</replaceable>
  11026. </literallayout></para></listitem>
  11027. </itemizedlist>
  11028. </para>
  11029. <para>
  11030. All test files reside in
  11031. <filename>meta/lib/oeqa/runtime</filename> in the
  11032. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  11033. A test name maps directly to a Python module.
  11034. Each test module may contain a number of individual tests.
  11035. Tests are usually grouped together by the area
  11036. tested (e.g tests for systemd reside in
  11037. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  11038. </para>
  11039. <para>
  11040. You can add tests to any layer provided you place them in the
  11041. proper area and you extend
  11042. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  11043. in the <filename>local.conf</filename> file as normal.
  11044. Be sure that tests reside in
  11045. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  11046. <note>
  11047. Be sure that module names do not collide with module names
  11048. used in the default set of test modules in
  11049. <filename>meta/lib/oeqa/runtime</filename>.
  11050. </note>
  11051. </para>
  11052. <para>
  11053. You can change the set of tests run by appending or overriding
  11054. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  11055. variable in <filename>local.conf</filename>.
  11056. Each name in <filename>TEST_SUITES</filename> represents a
  11057. required test for the image.
  11058. Test modules named within <filename>TEST_SUITES</filename>
  11059. cannot be skipped even if a test is not suitable for an image
  11060. (e.g. running the RPM tests on an image without
  11061. <filename>rpm</filename>).
  11062. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  11063. build system to try to run all tests that are suitable for the
  11064. image (i.e. each test module may elect to skip itself).
  11065. </para>
  11066. <para>
  11067. The order you list tests in <filename>TEST_SUITES</filename>
  11068. is important and influences test dependencies.
  11069. Consequently, tests that depend on other tests should be added
  11070. after the test on which they depend.
  11071. For example, since the <filename>ssh</filename> test
  11072. depends on the
  11073. <filename>ping</filename> test, "ssh" needs to come after
  11074. "ping" in the list.
  11075. The test class provides no re-ordering or dependency handling.
  11076. <note>
  11077. Each module can have multiple classes with multiple test
  11078. methods.
  11079. And, Python <filename>unittest</filename> rules apply.
  11080. </note>
  11081. </para>
  11082. <para>
  11083. Here are some things to keep in mind when running tests:
  11084. <itemizedlist>
  11085. <listitem><para>The default tests for the image are defined
  11086. as:
  11087. <literallayout class='monospaced'>
  11088. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  11089. </literallayout></para></listitem>
  11090. <listitem><para>Add your own test to the list of the
  11091. by using the following:
  11092. <literallayout class='monospaced'>
  11093. TEST_SUITES_append = " mytest"
  11094. </literallayout></para></listitem>
  11095. <listitem><para>Run a specific list of tests as follows:
  11096. <literallayout class='monospaced'>
  11097. TEST_SUITES = "test1 test2 test3"
  11098. </literallayout>
  11099. Remember, order is important.
  11100. Be sure to place a test that is dependent on another test
  11101. later in the order.</para></listitem>
  11102. </itemizedlist>
  11103. </para>
  11104. </section>
  11105. <section id="exporting-tests">
  11106. <title>Exporting Tests</title>
  11107. <para>
  11108. You can export tests so that they can run independently of
  11109. the build system.
  11110. Exporting tests is required if you want to be able to hand
  11111. the test execution off to a scheduler.
  11112. You can only export tests that are defined in
  11113. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  11114. </para>
  11115. <para>
  11116. If your image is already built, make sure the following are set
  11117. in your <filename>local.conf</filename> file:
  11118. <literallayout class='monospaced'>
  11119. INHERIT +="testexport"
  11120. TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>"
  11121. TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>"
  11122. </literallayout>
  11123. You can then export the tests with the following BitBake
  11124. command form:
  11125. <literallayout class='monospaced'>
  11126. $ bitbake <replaceable>image</replaceable> -c testexport
  11127. </literallayout>
  11128. Exporting the tests places them in the
  11129. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  11130. in
  11131. <filename>tmp/testexport/</filename><replaceable>image</replaceable>,
  11132. which is controlled by the
  11133. <filename>TEST_EXPORT_DIR</filename> variable.
  11134. </para>
  11135. <para>
  11136. You can now run the tests outside of the build environment:
  11137. <literallayout class='monospaced'>
  11138. $ cd tmp/testexport/<replaceable>image</replaceable>
  11139. $ ./runexported.py testdata.json
  11140. </literallayout>
  11141. </para>
  11142. <para>
  11143. Here is a complete example that shows IP addresses and uses
  11144. the <filename>core-image-sato</filename> image:
  11145. <literallayout class='monospaced'>
  11146. INHERIT +="testexport"
  11147. TEST_TARGET_IP = "192.168.7.2"
  11148. TEST_SERVER_IP = "192.168.7.1"
  11149. </literallayout>
  11150. Use BitBake to export the tests:
  11151. <literallayout class='monospaced'>
  11152. $ bitbake core-image-sato -c testexport
  11153. </literallayout>
  11154. Run the tests outside of the build environment using the
  11155. following:
  11156. <literallayout class='monospaced'>
  11157. $ cd tmp/testexport/core-image-sato
  11158. $ ./runexported.py testdata.json
  11159. </literallayout>
  11160. </para>
  11161. </section>
  11162. <section id="qemu-image-writing-new-tests">
  11163. <title>Writing New Tests</title>
  11164. <para>
  11165. As mentioned previously, all new test files need to be in the
  11166. proper place for the build system to find them.
  11167. New tests for additional functionality outside of the core
  11168. should be added to the layer that adds the functionality, in
  11169. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  11170. (as long as
  11171. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  11172. is extended in the layer's
  11173. <filename>layer.conf</filename> file as normal).
  11174. Just remember the following:
  11175. <itemizedlist>
  11176. <listitem><para>Filenames need to map directly to test
  11177. (module) names.
  11178. </para></listitem>
  11179. <listitem><para>Do not use module names that
  11180. collide with existing core tests.
  11181. </para></listitem>
  11182. <listitem><para>Minimally, an empty
  11183. <filename>__init__.py</filename> file must exist
  11184. in the runtime directory.
  11185. </para></listitem>
  11186. </itemizedlist>
  11187. </para>
  11188. <para>
  11189. To create a new test, start by copying an existing module
  11190. (e.g. <filename>syslog.py</filename> or
  11191. <filename>gcc.py</filename> are good ones to use).
  11192. Test modules can use code from
  11193. <filename>meta/lib/oeqa/utils</filename>, which are helper
  11194. classes.
  11195. </para>
  11196. <note>
  11197. Structure shell commands such that you rely on them and they
  11198. return a single code for success.
  11199. Be aware that sometimes you will need to parse the output.
  11200. See the <filename>df.py</filename> and
  11201. <filename>date.py</filename> modules for examples.
  11202. </note>
  11203. <para>
  11204. You will notice that all test classes inherit
  11205. <filename>oeRuntimeTest</filename>, which is found in
  11206. <filename>meta/lib/oetest.py</filename>.
  11207. This base class offers some helper attributes, which are
  11208. described in the following sections:
  11209. </para>
  11210. <section id='qemu-image-writing-tests-class-methods'>
  11211. <title>Class Methods</title>
  11212. <para>
  11213. Class methods are as follows:
  11214. <itemizedlist>
  11215. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  11216. Returns "True" if <filename>pkg</filename> is in the
  11217. installed package list of the image, which is based
  11218. on the manifest file that is generated during the
  11219. <filename>do_rootfs</filename> task.
  11220. </para></listitem>
  11221. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  11222. Returns "True" if the feature is in
  11223. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  11224. or
  11225. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  11226. </para></listitem>
  11227. </itemizedlist>
  11228. </para>
  11229. </section>
  11230. <section id='qemu-image-writing-tests-class-attributes'>
  11231. <title>Class Attributes</title>
  11232. <para>
  11233. Class attributes are as follows:
  11234. <itemizedlist>
  11235. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  11236. Equals "ps -ef" if <filename>procps</filename> is
  11237. installed in the image.
  11238. Otherwise, <filename>pscmd</filename> equals
  11239. "ps" (busybox).
  11240. </para></listitem>
  11241. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  11242. The called test context, which gives access to the
  11243. following attributes:
  11244. <itemizedlist>
  11245. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  11246. The BitBake datastore, which allows you to
  11247. use stuff such as
  11248. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  11249. </para></listitem>
  11250. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  11251. Used internally.
  11252. The tests do not need these.
  11253. </para></listitem>
  11254. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  11255. The absolute path to
  11256. <filename>meta/lib/oeqa/runtime/files</filename>,
  11257. which contains helper files for tests meant
  11258. for copying on the target such as small
  11259. files written in C for compilation.
  11260. </para></listitem>
  11261. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  11262. The target controller object used to deploy
  11263. and start an image on a particular target
  11264. (e.g. QemuTarget, SimpleRemote, and
  11265. SystemdbootTarget).
  11266. Tests usually use the following:
  11267. <itemizedlist>
  11268. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  11269. The target's IP address.
  11270. </para></listitem>
  11271. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  11272. The host's IP address, which is
  11273. usually used by the DNF test
  11274. suite.
  11275. </para></listitem>
  11276. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  11277. The single, most used method.
  11278. This command is a wrapper for:
  11279. <filename>ssh root@host "cmd"</filename>.
  11280. The command returns a tuple:
  11281. (status, output), which are what
  11282. their names imply - the return code
  11283. of "cmd" and whatever output
  11284. it produces.
  11285. The optional timeout argument
  11286. represents the number of seconds the
  11287. test should wait for "cmd" to
  11288. return.
  11289. If the argument is "None", the
  11290. test uses the default instance's
  11291. timeout period, which is 300
  11292. seconds.
  11293. If the argument is "0", the test
  11294. runs until the command returns.
  11295. </para></listitem>
  11296. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  11297. <filename>scp localpath root@ip:remotepath</filename>.
  11298. </para></listitem>
  11299. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  11300. <filename>scp root@host:remotepath localpath</filename>.
  11301. </para></listitem>
  11302. </itemizedlist></para></listitem>
  11303. </itemizedlist></para></listitem>
  11304. </itemizedlist>
  11305. </para>
  11306. </section>
  11307. <section id='qemu-image-writing-tests-instance-attributes'>
  11308. <title>Instance Attributes</title>
  11309. <para>
  11310. A single instance attribute exists, which is
  11311. <filename>target</filename>.
  11312. The <filename>target</filename> instance attribute is
  11313. identical to the class attribute of the same name, which
  11314. is described in the previous section.
  11315. This attribute exists as both an instance and class
  11316. attribute so tests can use
  11317. <filename>self.target.run(cmd)</filename> in instance
  11318. methods instead of
  11319. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  11320. </para>
  11321. </section>
  11322. </section>
  11323. <section id='installing-packages-in-the-dut-without-the-package-manager'>
  11324. <title>Installing Packages in the DUT Without the Package Manager</title>
  11325. <para>
  11326. When a test requires a package built by BitBake, it is possible
  11327. to install that package.
  11328. Installing the package does not require a package manager be
  11329. installed in the device under test (DUT).
  11330. It does, however, require an SSH connection and the target must
  11331. be using the <filename>sshcontrol</filename> class.
  11332. <note>
  11333. This method uses <filename>scp</filename> to copy files
  11334. from the host to the target, which causes permissions and
  11335. special attributes to be lost.
  11336. </note>
  11337. </para>
  11338. <para>
  11339. A JSON file is used to define the packages needed by a test.
  11340. This file must be in the same path as the file used to define
  11341. the tests.
  11342. Furthermore, the filename must map directly to the test
  11343. module name with a <filename>.json</filename> extension.
  11344. </para>
  11345. <para>
  11346. The JSON file must include an object with the test name as
  11347. keys of an object or an array.
  11348. This object (or array of objects) uses the following data:
  11349. <itemizedlist>
  11350. <listitem><para>"pkg" - A mandatory string that is the
  11351. name of the package to be installed.
  11352. </para></listitem>
  11353. <listitem><para>"rm" - An optional boolean, which defaults
  11354. to "false", that specifies to remove the package after
  11355. the test.
  11356. </para></listitem>
  11357. <listitem><para>"extract" - An optional boolean, which
  11358. defaults to "false", that specifies if the package must
  11359. be extracted from the package format.
  11360. When set to "true", the package is not automatically
  11361. installed into the DUT.
  11362. </para></listitem>
  11363. </itemizedlist>
  11364. </para>
  11365. <para>
  11366. Following is an example JSON file that handles test "foo"
  11367. installing package "bar" and test "foobar" installing
  11368. packages "foo" and "bar".
  11369. Once the test is complete, the packages are removed from the
  11370. DUT.
  11371. <literallayout class='monospaced'>
  11372. {
  11373. "foo": {
  11374. "pkg": "bar"
  11375. },
  11376. "foobar": [
  11377. {
  11378. "pkg": "foo",
  11379. "rm": true
  11380. },
  11381. {
  11382. "pkg": "bar",
  11383. "rm": true
  11384. }
  11385. ]
  11386. }
  11387. </literallayout>
  11388. </para>
  11389. </section>
  11390. </section>
  11391. <section id='usingpoky-debugging-tools-and-techniques'>
  11392. <title>Debugging Tools and Techniques</title>
  11393. <para>
  11394. The exact method for debugging build failures depends on the nature
  11395. of the problem and on the system's area from which the bug
  11396. originates.
  11397. Standard debugging practices such as comparison against the last
  11398. known working version with examination of the changes and the
  11399. re-application of steps to identify the one causing the problem are
  11400. valid for the Yocto Project just as they are for any other system.
  11401. Even though it is impossible to detail every possible potential
  11402. failure, this section provides some general tips to aid in
  11403. debugging given a variety of situations.
  11404. <note><title>Tip</title>
  11405. A useful feature for debugging is the error reporting tool.
  11406. Configuring the Yocto Project to use this tool causes the
  11407. OpenEmbedded build system to produce error reporting commands as
  11408. part of the console output.
  11409. You can enter the commands after the build completes to log
  11410. error information into a common database, that can help you
  11411. figure out what might be going wrong.
  11412. For information on how to enable and use this feature, see the
  11413. "<link linkend='using-the-error-reporting-tool'>Using the Error Reporting Tool</link>"
  11414. section.
  11415. </note>
  11416. </para>
  11417. <para>
  11418. The following list shows the debugging topics in the remainder of
  11419. this section:
  11420. <itemizedlist>
  11421. <listitem><para>
  11422. "<link linkend='dev-debugging-viewing-logs-from-failed-tasks'>Viewing Logs from Failed Tasks</link>"
  11423. describes how to find and view logs from tasks that
  11424. failed during the build process.
  11425. </para></listitem>
  11426. <listitem><para>
  11427. "<link linkend='dev-debugging-viewing-variable-values'>Viewing Variable Values</link>"
  11428. describes how to use the BitBake <filename>-e</filename>
  11429. option to examine variable values after a recipe has been
  11430. parsed.
  11431. </para></listitem>
  11432. <listitem><para>
  11433. "<link linkend='viewing-package-information-with-oe-pkgdata-util'>Viewing Package Information with <filename>oe-pkgdata-util</filename></link>"
  11434. describes how to use the
  11435. <filename>oe-pkgdata-util</filename> utility to query
  11436. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  11437. and display package-related information for built
  11438. packages.
  11439. </para></listitem>
  11440. <listitem><para>
  11441. "<link linkend='dev-viewing-dependencies-between-recipes-and-tasks'>Viewing Dependencies Between Recipes and Tasks</link>"
  11442. describes how to use the BitBake <filename>-g</filename>
  11443. option to display recipe dependency information used
  11444. during the build.
  11445. </para></listitem>
  11446. <listitem><para>
  11447. "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  11448. describes how to use the
  11449. <filename>bitbake-dumpsig</filename> command in
  11450. conjunction with key subdirectories in the
  11451. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  11452. to determine variable dependencies.
  11453. </para></listitem>
  11454. <listitem><para>
  11455. "<link linkend='dev-debugging-taskrunning'>Running Specific Tasks</link>"
  11456. describes how to use several BitBake options (e.g.
  11457. <filename>-c</filename>, <filename>-C</filename>, and
  11458. <filename>-f</filename>) to run specific tasks in the
  11459. build chain.
  11460. It can be useful to run tasks "out-of-order" when trying
  11461. isolate build issues.
  11462. </para></listitem>
  11463. <listitem><para>
  11464. "<link linkend='dev-debugging-bitbake'>General BitBake Problems</link>"
  11465. describes how to use BitBake's <filename>-D</filename>
  11466. debug output option to reveal more about what BitBake is
  11467. doing during the build.
  11468. </para></listitem>
  11469. <listitem><para>
  11470. "<link linkend='dev-debugging-buildfile'>Building with No Dependencies</link>"
  11471. describes how to use the BitBake <filename>-b</filename>
  11472. option to build a recipe while ignoring dependencies.
  11473. </para></listitem>
  11474. <listitem><para>
  11475. "<link linkend='recipe-logging-mechanisms'>Recipe Logging Mechanisms</link>"
  11476. describes how to use the many recipe logging functions
  11477. to produce debugging output and report errors and warnings.
  11478. </para></listitem>
  11479. <listitem><para>
  11480. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  11481. describes how to debug situations where the build consists
  11482. of several parts that are run simultaneously and when the
  11483. output or result of one part is not ready for use with a
  11484. different part of the build that depends on that output.
  11485. </para></listitem>
  11486. <listitem><para>
  11487. "<link linkend='platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</link>"
  11488. describes how to use GDB to allow you to examine running
  11489. programs, which can help you fix problems.
  11490. </para></listitem>
  11491. <listitem><para>
  11492. "<link linkend='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>Debugging with the GNU Project Debugger (GDB) on the Target</link>"
  11493. describes how to use GDB directly on target hardware for
  11494. debugging.
  11495. </para></listitem>
  11496. <listitem><para>
  11497. "<link linkend='dev-other-debugging-others'>Other Debugging Tips</link>"
  11498. describes miscellaneous debugging tips that can be useful.
  11499. </para></listitem>
  11500. </itemizedlist>
  11501. </para>
  11502. <para>
  11503. For debugging information within the popular
  11504. <trademark class='trade'>Eclipse</trademark> IDE, see the
  11505. "<ulink url='&YOCTO_DOCS_SDK_URL;#adt-eclipse'>Working within Eclipse</ulink>"
  11506. section in the Yocto Project Application Development and the
  11507. Extensible Software Development Kit (eSDK) manual.
  11508. </para>
  11509. <section id='dev-debugging-viewing-logs-from-failed-tasks'>
  11510. <title>Viewing Logs from Failed Tasks</title>
  11511. <para>
  11512. You can find the log for a task in the file
  11513. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>.
  11514. For example, the log for the
  11515. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  11516. task of the QEMU minimal image for the x86 machine
  11517. (<filename>qemux86</filename>) might be in
  11518. <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>.
  11519. To see the commands
  11520. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  11521. ran to generate a log, look at the corresponding
  11522. <filename>run.do_</filename><replaceable>taskname</replaceable>
  11523. file in the same directory.
  11524. </para>
  11525. <para>
  11526. <filename>log.do_</filename><replaceable>taskname</replaceable>
  11527. and
  11528. <filename>run.do_</filename><replaceable>taskname</replaceable>
  11529. are actually symbolic links to
  11530. <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>
  11531. and
  11532. <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>,
  11533. where <replaceable>pid</replaceable> is the PID the task had
  11534. when it ran.
  11535. The symlinks always point to the files corresponding to the most
  11536. recent run.
  11537. </para>
  11538. </section>
  11539. <section id='dev-debugging-viewing-variable-values'>
  11540. <title>Viewing Variable Values</title>
  11541. <para>
  11542. BitBake's <filename>-e</filename> option is used to display
  11543. variable values after parsing.
  11544. The following command displays the variable values after the
  11545. configuration files (i.e. <filename>local.conf</filename>,
  11546. <filename>bblayers.conf</filename>,
  11547. <filename>bitbake.conf</filename> and so forth) have been
  11548. parsed:
  11549. <literallayout class='monospaced'>
  11550. $ bitbake -e
  11551. </literallayout>
  11552. The following command displays variable values after a specific
  11553. recipe has been parsed.
  11554. The variables include those from the configuration as well:
  11555. <literallayout class='monospaced'>
  11556. $ bitbake -e recipename
  11557. </literallayout>
  11558. <note><para>
  11559. Each recipe has its own private set of variables
  11560. (datastore).
  11561. Internally, after parsing the configuration, a copy of the
  11562. resulting datastore is made prior to parsing each recipe.
  11563. This copying implies that variables set in one recipe will
  11564. not be visible to other recipes.</para>
  11565. <para>Likewise, each task within a recipe gets a private
  11566. datastore based on the recipe datastore, which means that
  11567. variables set within one task will not be visible to
  11568. other tasks.</para>
  11569. </note>
  11570. </para>
  11571. <para>
  11572. In the output of <filename>bitbake -e</filename>, each
  11573. variable is preceded by a description of how the variable
  11574. got its value, including temporary values that were later
  11575. overriden.
  11576. This description also includes variable flags (varflags) set on
  11577. the variable.
  11578. The output can be very helpful during debugging.
  11579. </para>
  11580. <para>
  11581. Variables that are exported to the environment are preceded by
  11582. <filename>export</filename> in the output of
  11583. <filename>bitbake -e</filename>.
  11584. See the following example:
  11585. <literallayout class='monospaced'>
  11586. export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
  11587. </literallayout>
  11588. </para>
  11589. <para>
  11590. In addition to variable values, the output of the
  11591. <filename>bitbake -e</filename> and
  11592. <filename>bitbake -e</filename>&nbsp;<replaceable>recipe</replaceable>
  11593. commands includes the following information:
  11594. <itemizedlist>
  11595. <listitem><para>
  11596. The output starts with a tree listing all configuration
  11597. files and classes included globally, recursively listing
  11598. the files they include or inherit in turn.
  11599. Much of the behavior of the OpenEmbedded build system
  11600. (including the behavior of the
  11601. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>)
  11602. is implemented in the
  11603. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink>
  11604. class and the classes it inherits, rather than being
  11605. built into BitBake itself.
  11606. </para></listitem>
  11607. <listitem><para>
  11608. After the variable values, all functions appear in the
  11609. output.
  11610. For shell functions, variables referenced within the
  11611. function body are expanded.
  11612. If a function has been modified using overrides or
  11613. using override-style operators like
  11614. <filename>_append</filename> and
  11615. <filename>_prepend</filename>, then the final assembled
  11616. function body appears in the output.
  11617. </para></listitem>
  11618. </itemizedlist>
  11619. </para>
  11620. </section>
  11621. <section id='viewing-package-information-with-oe-pkgdata-util'>
  11622. <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title>
  11623. <para>
  11624. You can use the <filename>oe-pkgdata-util</filename>
  11625. command-line utility to query
  11626. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  11627. and display various package-related information.
  11628. When you use the utility, you must use it to view information
  11629. on packages that have already been built.
  11630. </para>
  11631. <para>
  11632. Following are a few of the available
  11633. <filename>oe-pkgdata-util</filename> subcommands.
  11634. <note>
  11635. You can use the standard * and ? globbing wildcards as part
  11636. of package names and paths.
  11637. </note>
  11638. <itemizedlist>
  11639. <listitem><para>
  11640. <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>:
  11641. Lists all packages that have been built, optionally
  11642. limiting the match to packages that match
  11643. <replaceable>pattern</replaceable>.
  11644. </para></listitem>
  11645. <listitem><para>
  11646. <filename>oe-pkgdata-util list-pkg-files&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  11647. Lists the files and directories contained in the given
  11648. packages.
  11649. <note>
  11650. <para>
  11651. A different way to view the contents of a package is
  11652. to look at the
  11653. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  11654. directory of the recipe that generates the
  11655. package.
  11656. This directory is created by the
  11657. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  11658. task and has one subdirectory for each package the
  11659. recipe generates, which contains the files stored in
  11660. that package.</para>
  11661. <para>
  11662. If you want to inspect the
  11663. <filename>${WORKDIR}/packages-split</filename>
  11664. directory, make sure that
  11665. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  11666. is not enabled when you build the recipe.
  11667. </para>
  11668. </note>
  11669. </para></listitem>
  11670. <listitem><para>
  11671. <filename>oe-pkgdata-util find-path&nbsp;</filename><replaceable>path</replaceable><filename>&nbsp;...</filename>:
  11672. Lists the names of the packages that contain the given
  11673. paths.
  11674. For example, the following tells us that
  11675. <filename>/usr/share/man/man1/make.1</filename>
  11676. is contained in the <filename>make-doc</filename>
  11677. package:
  11678. <literallayout class='monospaced'>
  11679. $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
  11680. make-doc: /usr/share/man/man1/make.1
  11681. </literallayout>
  11682. </para></listitem>
  11683. <listitem><para>
  11684. <filename>oe-pkgdata-util lookup-recipe&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  11685. Lists the name of the recipes that
  11686. produce the given packages.
  11687. </para></listitem>
  11688. </itemizedlist>
  11689. </para>
  11690. <para>
  11691. For more information on the <filename>oe-pkgdata-util</filename>
  11692. command, use the help facility:
  11693. <literallayout class='monospaced'>
  11694. $ oe-pkgdata-util &dash;&dash;help
  11695. $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help
  11696. </literallayout>
  11697. </para>
  11698. </section>
  11699. <section id='dev-viewing-dependencies-between-recipes-and-tasks'>
  11700. <title>Viewing Dependencies Between Recipes and Tasks</title>
  11701. <para>
  11702. Sometimes it can be hard to see why BitBake wants to build other
  11703. recipes before the one you have specified.
  11704. Dependency information can help you understand why a recipe is
  11705. built.
  11706. </para>
  11707. <para>
  11708. To generate dependency information for a recipe, run the
  11709. following command:
  11710. <literallayout class='monospaced'>
  11711. $ bitbake -g <replaceable>recipename</replaceable>
  11712. </literallayout>
  11713. This command writes the following files in the current
  11714. directory:
  11715. <itemizedlist>
  11716. <listitem><para>
  11717. <filename>pn-buildlist</filename>: A list of
  11718. recipes/targets involved in building
  11719. <replaceable>recipename</replaceable>.
  11720. "Involved" here means that at least one task from the
  11721. recipe needs to run when building
  11722. <replaceable>recipename</replaceable> from scratch.
  11723. Targets that are in
  11724. <ulink url='&YOCTO_DOCS_REF_URL;#var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></ulink>
  11725. are not listed.
  11726. </para></listitem>
  11727. <listitem><para>
  11728. <filename>task-depends.dot</filename>: A graph showing
  11729. dependencies between tasks.
  11730. </para></listitem>
  11731. </itemizedlist>
  11732. </para>
  11733. <para>
  11734. The graphs are in
  11735. <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink>
  11736. format and can be converted to images (e.g. using the
  11737. <filename>dot</filename> tool from
  11738. <ulink url='http://www.graphviz.org/'>Graphviz</ulink>).
  11739. <note><title>Notes</title>
  11740. <itemizedlist>
  11741. <listitem><para>
  11742. DOT files use a plain text format.
  11743. The graphs generated using the
  11744. <filename>bitbake -g</filename> command are often so
  11745. large as to be difficult to read without special
  11746. pruning (e.g. with Bitbake's
  11747. <filename>-I</filename> option) and processing.
  11748. Despite the form and size of the graphs, the
  11749. corresponding <filename>.dot</filename> files can
  11750. still be possible to read and provide useful
  11751. information.
  11752. </para>
  11753. <para>As an example, the
  11754. <filename>task-depends.dot</filename> file contains
  11755. lines such as the following:
  11756. <literallayout class='monospaced'>
  11757. "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
  11758. </literallayout>
  11759. The above example line reveals that the
  11760. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  11761. task in <filename>libxslt</filename> depends on the
  11762. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  11763. task in <filename>libxml2</filename>, which is a
  11764. normal
  11765. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  11766. dependency between the two recipes.
  11767. </para></listitem>
  11768. <listitem><para>
  11769. For an example of how <filename>.dot</filename>
  11770. files can be processed, see the
  11771. <filename>scripts/contrib/graph-tool</filename>
  11772. Python script, which finds and displays paths
  11773. between graph nodes.
  11774. </para></listitem>
  11775. </itemizedlist>
  11776. </note>
  11777. </para>
  11778. <para>
  11779. You can use a different method to view dependency information
  11780. by using the following command:
  11781. <literallayout class='monospaced'>
  11782. $ bitbake -g -u taskexp <replaceable>recipename</replaceable>
  11783. </literallayout>
  11784. This command displays a GUI window from which you can view
  11785. build-time and runtime dependencies for the recipes involved in
  11786. building <replaceable>recipename</replaceable>.
  11787. </para>
  11788. </section>
  11789. <section id='dev-viewing-task-variable-dependencies'>
  11790. <title>Viewing Task Variable Dependencies</title>
  11791. <para>
  11792. As mentioned in the
  11793. "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>"
  11794. section of the BitBake User Manual, BitBake tries to
  11795. automatically determine what variables a task depends on so
  11796. that it can rerun the task if any values of the variables
  11797. change.
  11798. This determination is usually reliable.
  11799. However, if you do things like construct variable names at
  11800. runtime, then you might have to manually declare dependencies
  11801. on those variables using <filename>vardeps</filename> as
  11802. described in the
  11803. "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
  11804. section of the BitBake User Manual.
  11805. </para>
  11806. <para>
  11807. If you are unsure whether a variable dependency is being
  11808. picked up automatically for a given task, you can list the
  11809. variable dependencies BitBake has determined by doing the
  11810. following:
  11811. <orderedlist>
  11812. <listitem><para>
  11813. Build the recipe containing the task:
  11814. <literallayout class='monospaced'>
  11815. $ bitbake <replaceable>recipename</replaceable>
  11816. </literallayout>
  11817. </para></listitem>
  11818. <listitem><para>
  11819. Inside the
  11820. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink>
  11821. directory, find the signature data
  11822. (<filename>sigdata</filename>) file that corresponds
  11823. to the task.
  11824. The <filename>sigdata</filename> files contain a pickled
  11825. Python database of all the metadata that went into
  11826. creating the input checksum for the task.
  11827. As an example, for the
  11828. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  11829. task of the <filename>db</filename> recipe, the
  11830. <filename>sigdata</filename> file might be found in the
  11831. following location:
  11832. <literallayout class='monospaced'>
  11833. ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  11834. </literallayout>
  11835. For tasks that are accelerated through the shared state
  11836. (<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>sstate</ulink>)
  11837. cache, an additional <filename>siginfo</filename> file
  11838. is written into
  11839. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  11840. along with the cached task output.
  11841. The <filename>siginfo</filename> files contain exactly
  11842. the same information as <filename>sigdata</filename>
  11843. files.
  11844. </para></listitem>
  11845. <listitem><para>
  11846. Run <filename>bitbake-dumpsig</filename> on the
  11847. <filename>sigdata</filename> or
  11848. <filename>siginfo</filename> file.
  11849. Here is an example:
  11850. <literallayout class='monospaced'>
  11851. $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  11852. </literallayout>
  11853. In the output of the above command, you will find a
  11854. line like the following, which lists all the (inferred)
  11855. variable dependencies for the task.
  11856. This list also includes indirect dependencies from
  11857. variables depending on other variables, recursively.
  11858. <literallayout class='monospaced'>
  11859. Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
  11860. </literallayout>
  11861. <note>
  11862. Functions (e.g. <filename>base_do_fetch</filename>)
  11863. also count as variable dependencies.
  11864. These functions in turn depend on the variables they
  11865. reference.
  11866. </note>
  11867. The output of <filename>bitbake-dumpsig</filename> also
  11868. includes the value each variable had, a list of
  11869. dependencies for each variable, and
  11870. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink>
  11871. information.
  11872. </para></listitem>
  11873. </orderedlist>
  11874. </para>
  11875. <para>
  11876. There is also a <filename>bitbake-diffsigs</filename> command
  11877. for comparing two <filename>siginfo</filename> or
  11878. <filename>sigdata</filename> files.
  11879. This command can be helpful when trying to figure out what
  11880. changed between two versions of a task.
  11881. If you call <filename>bitbake-diffsigs</filename> with just one
  11882. file, the command behaves like
  11883. <filename>bitbake-dumpsig</filename>.
  11884. </para>
  11885. <para>
  11886. You can also use BitBake to dump out the signature construction
  11887. information without executing tasks by using either of the
  11888. following BitBake command-line options:
  11889. <literallayout class='monospaced'>
  11890. &dash;&dash;dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable>
  11891. -S <replaceable>SIGNATURE_HANDLER</replaceable>
  11892. </literallayout>
  11893. <note>
  11894. Two common values for
  11895. <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and
  11896. "printdiff", which dump only the signature or compare the
  11897. dumped signature with the cached one, respectively.
  11898. </note>
  11899. Using BitBake with either of these options causes BitBake to
  11900. dump out <filename>sigdata</filename> files in the
  11901. <filename>stamps</filename> directory for every task it would
  11902. have executed instead of building the specified target package.
  11903. </para>
  11904. </section>
  11905. <section id='dev-viewing-metadata-used-to-create-the-input-signature-of-a-shared-state-task'>
  11906. <title>Viewing Metadata Used to Create the Input Signature of a Shared State Task</title>
  11907. <para>
  11908. Seeing what metadata went into creating the input signature
  11909. of a shared state (sstate) task can be a useful debugging
  11910. aid.
  11911. This information is available in signature information
  11912. (<filename>siginfo</filename>) files in
  11913. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>.
  11914. For information on how to view and interpret information in
  11915. <filename>siginfo</filename> files, see the
  11916. "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  11917. section.
  11918. </para>
  11919. <para>
  11920. For conceptual information on shared state, see the
  11921. "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>Shared State</ulink>"
  11922. section in the Yocto Project Overview and Concepts Manual.
  11923. </para>
  11924. </section>
  11925. <section id='dev-invalidating-shared-state-to-force-a-task-to-run'>
  11926. <title>Invalidating Shared State to Force a Task to Run</title>
  11927. <para>
  11928. The OpenEmbedded build system uses
  11929. <ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>checksums</ulink>
  11930. and
  11931. <ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>shared state</ulink>
  11932. cache to avoid unnecessarily rebuilding tasks.
  11933. Collectively, this scheme is known as "shared state code."
  11934. </para>
  11935. <para>
  11936. As with all schemes, this one has some drawbacks.
  11937. It is possible that you could make implicit changes to your
  11938. code that the checksum calculations do not take into
  11939. account.
  11940. These implicit changes affect a task's output but do not
  11941. trigger the shared state code into rebuilding a recipe.
  11942. Consider an example during which a tool changes its output.
  11943. Assume that the output of <filename>rpmdeps</filename>
  11944. changes.
  11945. The result of the change should be that all the
  11946. <filename>package</filename> and
  11947. <filename>package_write_rpm</filename> shared state cache
  11948. items become invalid.
  11949. However, because the change to the output is
  11950. external to the code and therefore implicit,
  11951. the associated shared state cache items do not become
  11952. invalidated.
  11953. In this case, the build process uses the cached items
  11954. rather than running the task again.
  11955. Obviously, these types of implicit changes can cause
  11956. problems.
  11957. </para>
  11958. <para>
  11959. To avoid these problems during the build, you need to
  11960. understand the effects of any changes you make.
  11961. Realize that changes you make directly to a function
  11962. are automatically factored into the checksum calculation.
  11963. Thus, these explicit changes invalidate the associated
  11964. area of shared state cache.
  11965. However, you need to be aware of any implicit changes that
  11966. are not obvious changes to the code and could affect
  11967. the output of a given task.
  11968. </para>
  11969. <para>
  11970. When you identify an implicit change, you can easily
  11971. take steps to invalidate the cache and force the tasks
  11972. to run.
  11973. The steps you can take are as simple as changing a
  11974. function's comments in the source code.
  11975. For example, to invalidate package shared state files,
  11976. change the comment statements of
  11977. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  11978. or the comments of one of the functions it calls.
  11979. Even though the change is purely cosmetic, it causes the
  11980. checksum to be recalculated and forces the build system to
  11981. run the task again.
  11982. <note>
  11983. For an example of a commit that makes a cosmetic
  11984. change to invalidate shared state, see this
  11985. <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54'>commit</ulink>.
  11986. </note>
  11987. </para>
  11988. </section>
  11989. <section id='dev-debugging-taskrunning'>
  11990. <title>Running Specific Tasks</title>
  11991. <para>
  11992. Any given recipe consists of a set of tasks.
  11993. The standard BitBake behavior in most cases is:
  11994. <filename>do_fetch</filename>,
  11995. <filename>do_unpack</filename>,
  11996. <filename>do_patch</filename>,
  11997. <filename>do_configure</filename>,
  11998. <filename>do_compile</filename>,
  11999. <filename>do_install</filename>,
  12000. <filename>do_package</filename>,
  12001. <filename>do_package_write_*</filename>, and
  12002. <filename>do_build</filename>.
  12003. The default task is <filename>do_build</filename> and any tasks
  12004. on which it depends build first.
  12005. Some tasks, such as <filename>do_devshell</filename>, are not
  12006. part of the default build chain.
  12007. If you wish to run a task that is not part of the default build
  12008. chain, you can use the <filename>-c</filename> option in
  12009. BitBake.
  12010. Here is an example:
  12011. <literallayout class='monospaced'>
  12012. $ bitbake matchbox-desktop -c devshell
  12013. </literallayout>
  12014. </para>
  12015. <para>
  12016. The <filename>-c</filename> option respects task dependencies,
  12017. which means that all other tasks (including tasks from other
  12018. recipes) that the specified task depends on will be run before
  12019. the task.
  12020. Even when you manually specify a task to run with
  12021. <filename>-c</filename>, BitBake will only run the task if it
  12022. considers it "out of date".
  12023. See the
  12024. "<ulink url='&YOCTO_DOCS_OM_URL;#stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</ulink>"
  12025. section in the Yocto Project Overview and Concepts Manual for
  12026. how BitBake determines whether a task is "out of date".
  12027. </para>
  12028. <para>
  12029. If you want to force an up-to-date task to be rerun (e.g.
  12030. because you made manual modifications to the recipe's
  12031. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  12032. that you want to try out), then you can use the
  12033. <filename>-f</filename> option.
  12034. <note>
  12035. The reason <filename>-f</filename> is never required when
  12036. running the
  12037. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-devshell'><filename>do_devshell</filename></ulink>
  12038. task is because the
  12039. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename>
  12040. variable flag is already set for the task.
  12041. </note>
  12042. The following example shows one way you can use the
  12043. <filename>-f</filename> option:
  12044. <literallayout class='monospaced'>
  12045. $ bitbake matchbox-desktop
  12046. .
  12047. .
  12048. make some changes to the source code in the work directory
  12049. .
  12050. .
  12051. $ bitbake matchbox-desktop -c compile -f
  12052. $ bitbake matchbox-desktop
  12053. </literallayout>
  12054. </para>
  12055. <para>
  12056. This sequence first builds and then recompiles
  12057. <filename>matchbox-desktop</filename>.
  12058. The last command reruns all tasks (basically the packaging
  12059. tasks) after the compile.
  12060. BitBake recognizes that the <filename>do_compile</filename>
  12061. task was rerun and therefore understands that the other tasks
  12062. also need to be run again.
  12063. </para>
  12064. <para>
  12065. Another, shorter way to rerun a task and all
  12066. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>
  12067. that depend on it is to use the <filename>-C</filename>
  12068. option.
  12069. <note>
  12070. This option is upper-cased and is separate from the
  12071. <filename>-c</filename> option, which is lower-cased.
  12072. </note>
  12073. Using this option invalidates the given task and then runs the
  12074. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-build'><filename>do_build</filename></ulink>
  12075. task, which is the default task if no task is given, and the
  12076. tasks on which it depends.
  12077. You could replace the final two commands in the previous example
  12078. with the following single command:
  12079. <literallayout class='monospaced'>
  12080. $ bitbake matchbox-desktop -C compile
  12081. </literallayout>
  12082. Internally, the <filename>-f</filename> and
  12083. <filename>-C</filename> options work by tainting (modifying) the
  12084. input checksum of the specified task.
  12085. This tainting indirectly causes the task and its
  12086. dependent tasks to be rerun through the normal task dependency
  12087. mechanisms.
  12088. <note>
  12089. BitBake explicitly keeps track of which tasks have been
  12090. tainted in this fashion, and will print warnings such as the
  12091. following for builds involving such tasks:
  12092. <literallayout class='monospaced'>
  12093. WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
  12094. </literallayout>
  12095. The purpose of the warning is to let you know that the work
  12096. directory and build output might not be in the clean state
  12097. they would be in for a "normal" build, depending on what
  12098. actions you took.
  12099. To get rid of such warnings, you can remove the work
  12100. directory and rebuild the recipe, as follows:
  12101. <literallayout class='monospaced'>
  12102. $ bitbake matchbox-desktop -c clean
  12103. $ bitbake matchbox-desktop
  12104. </literallayout>
  12105. </note>
  12106. </para>
  12107. <para>
  12108. You can view a list of tasks in a given package by running the
  12109. <filename>do_listtasks</filename> task as follows:
  12110. <literallayout class='monospaced'>
  12111. $ bitbake matchbox-desktop -c listtasks
  12112. </literallayout>
  12113. The results appear as output to the console and are also in the
  12114. file <filename>${WORKDIR}/temp/log.do_listtasks</filename>.
  12115. </para>
  12116. </section>
  12117. <section id='dev-debugging-bitbake'>
  12118. <title>General BitBake Problems</title>
  12119. <para>
  12120. You can see debug output from BitBake by using the
  12121. <filename>-D</filename> option.
  12122. The debug output gives more information about what BitBake
  12123. is doing and the reason behind it.
  12124. Each <filename>-D</filename> option you use increases the
  12125. logging level.
  12126. The most common usage is <filename>-DDD</filename>.
  12127. </para>
  12128. <para>
  12129. The output from
  12130. <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable>
  12131. can reveal why BitBake chose a certain version of a package or
  12132. why BitBake picked a certain provider.
  12133. This command could also help you in a situation where you think
  12134. BitBake did something unexpected.
  12135. </para>
  12136. </section>
  12137. <section id='dev-debugging-buildfile'>
  12138. <title>Building with No Dependencies</title>
  12139. <para>
  12140. To build a specific recipe (<filename>.bb</filename> file),
  12141. you can use the following command form:
  12142. <literallayout class='monospaced'>
  12143. $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb
  12144. </literallayout>
  12145. This command form does not check for dependencies.
  12146. Consequently, you should use it only when you know existing
  12147. dependencies have been met.
  12148. <note>
  12149. You can also specify fragments of the filename.
  12150. In this case, BitBake checks for a unique match.
  12151. </note>
  12152. </para>
  12153. </section>
  12154. <section id='recipe-logging-mechanisms'>
  12155. <title>Recipe Logging Mechanisms</title>
  12156. <para>
  12157. The Yocto Project provides several logging functions for
  12158. producing debugging output and reporting errors and warnings.
  12159. For Python functions, the following logging functions exist.
  12160. All of these functions log to
  12161. <filename>${T}/log.do_</filename><replaceable>task</replaceable>,
  12162. and can also log to standard output (stdout) with the right
  12163. settings:
  12164. <itemizedlist>
  12165. <listitem><para>
  12166. <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12167. Writes <replaceable>msg</replaceable> as is to the
  12168. log while also logging to stdout.
  12169. </para></listitem>
  12170. <listitem><para>
  12171. <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12172. Writes "NOTE: <replaceable>msg</replaceable>" to the
  12173. log.
  12174. Also logs to stdout if BitBake is called with "-v".
  12175. </para></listitem>
  12176. <listitem><para>
  12177. <filename>bb.debug(</filename><replaceable>level</replaceable><filename>,&nbsp;</filename><replaceable>msg</replaceable><filename>)</filename>:
  12178. Writes "DEBUG: <replaceable>msg</replaceable>" to the
  12179. log.
  12180. Also logs to stdout if the log level is greater than or
  12181. equal to <replaceable>level</replaceable>.
  12182. See the
  12183. "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>"
  12184. option in the BitBake User Manual for more information.
  12185. </para></listitem>
  12186. <listitem><para>
  12187. <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12188. Writes "WARNING: <replaceable>msg</replaceable>" to the
  12189. log while also logging to stdout.
  12190. </para></listitem>
  12191. <listitem><para>
  12192. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12193. Writes "ERROR: <replaceable>msg</replaceable>" to the
  12194. log while also logging to standard out (stdout).
  12195. <note>
  12196. Calling this function does not cause the task to fail.
  12197. </note>
  12198. </para></listitem>
  12199. <listitem><para>
  12200. <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12201. This logging function is similar to
  12202. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>
  12203. but also causes the calling task to fail.
  12204. <note>
  12205. <filename>bb.fatal()</filename> raises an exception,
  12206. which means you do not need to put a "return"
  12207. statement after the function.
  12208. </note>
  12209. </para></listitem>
  12210. </itemizedlist>
  12211. </para>
  12212. <para>
  12213. The same logging functions are also available in shell
  12214. functions, under the names
  12215. <filename>bbplain</filename>, <filename>bbnote</filename>,
  12216. <filename>bbdebug</filename>, <filename>bbwarn</filename>,
  12217. <filename>bberror</filename>, and <filename>bbfatal</filename>.
  12218. The
  12219. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-logging'><filename>logging</filename></ulink>
  12220. class implements these functions.
  12221. See that class in the
  12222. <filename>meta/classes</filename> folder of the
  12223. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  12224. for information.
  12225. </para>
  12226. <section id='logging-with-python'>
  12227. <title>Logging With Python</title>
  12228. <para>
  12229. When creating recipes using Python and inserting code that
  12230. handles build logs, keep in mind the goal is to have
  12231. informative logs while keeping the console as "silent" as
  12232. possible.
  12233. Also, if you want status messages in the log, use the
  12234. "debug" loglevel.
  12235. </para>
  12236. <para>
  12237. Following is an example written in Python.
  12238. The code handles logging for a function that determines the
  12239. number of tasks needed to be run.
  12240. See the
  12241. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-listtasks'><filename>do_listtasks</filename></ulink>"
  12242. section for additional information:
  12243. <literallayout class='monospaced'>
  12244. python do_listtasks() {
  12245. bb.debug(2, "Starting to figure out the task list")
  12246. if noteworthy_condition:
  12247. bb.note("There are 47 tasks to run")
  12248. bb.debug(2, "Got to point xyz")
  12249. if warning_trigger:
  12250. bb.warn("Detected warning_trigger, this might be a problem later.")
  12251. if recoverable_error:
  12252. bb.error("Hit recoverable_error, you really need to fix this!")
  12253. if fatal_error:
  12254. bb.fatal("fatal_error detected, unable to print the task list")
  12255. bb.plain("The tasks present are abc")
  12256. bb.debug(2, "Finished figuring out the tasklist")
  12257. }
  12258. </literallayout>
  12259. </para>
  12260. </section>
  12261. <section id='logging-with-bash'>
  12262. <title>Logging With Bash</title>
  12263. <para>
  12264. When creating recipes using Bash and inserting code that
  12265. handles build logs, you have the same goals - informative
  12266. with minimal console output.
  12267. The syntax you use for recipes written in Bash is similar
  12268. to that of recipes written in Python described in the
  12269. previous section.
  12270. </para>
  12271. <para>
  12272. Following is an example written in Bash.
  12273. The code logs the progress of the <filename>do_my_function</filename> function.
  12274. <literallayout class='monospaced'>
  12275. do_my_function() {
  12276. bbdebug 2 "Running do_my_function"
  12277. if [ exceptional_condition ]; then
  12278. bbnote "Hit exceptional_condition"
  12279. fi
  12280. bbdebug 2 "Got to point xyz"
  12281. if [ warning_trigger ]; then
  12282. bbwarn "Detected warning_trigger, this might cause a problem later."
  12283. fi
  12284. if [ recoverable_error ]; then
  12285. bberror "Hit recoverable_error, correcting"
  12286. fi
  12287. if [ fatal_error ]; then
  12288. bbfatal "fatal_error detected"
  12289. fi
  12290. bbdebug 2 "Completed do_my_function"
  12291. }
  12292. </literallayout>
  12293. </para>
  12294. </section>
  12295. </section>
  12296. <section id='debugging-parallel-make-races'>
  12297. <title>Debugging Parallel Make Races</title>
  12298. <para>
  12299. A parallel <filename>make</filename> race occurs when the build
  12300. consists of several parts that are run simultaneously and
  12301. a situation occurs when the output or result of one
  12302. part is not ready for use with a different part of the build
  12303. that depends on that output.
  12304. Parallel make races are annoying and can sometimes be difficult
  12305. to reproduce and fix.
  12306. However, some simple tips and tricks exist that can help
  12307. you debug and fix them.
  12308. This section presents a real-world example of an error
  12309. encountered on the Yocto Project autobuilder and the process
  12310. used to fix it.
  12311. <note>
  12312. If you cannot properly fix a <filename>make</filename> race
  12313. condition, you can work around it by clearing either the
  12314. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  12315. or
  12316. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  12317. variables.
  12318. </note>
  12319. </para>
  12320. <section id='the-failure'>
  12321. <title>The Failure</title>
  12322. <para>
  12323. For this example, assume that you are building an image that
  12324. depends on the "neard" package.
  12325. And, during the build, BitBake runs into problems and
  12326. creates the following output.
  12327. <note>
  12328. This example log file has longer lines artificially
  12329. broken to make the listing easier to read.
  12330. </note>
  12331. If you examine the output or the log file, you see the
  12332. failure during <filename>make</filename>:
  12333. <literallayout class='monospaced'>
  12334. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  12335. | DEBUG: Executing shell function do_compile
  12336. | NOTE: make -j 16
  12337. | make --no-print-directory all-am
  12338. | /bin/mkdir -p include/near
  12339. | /bin/mkdir -p include/near
  12340. | /bin/mkdir -p include/near
  12341. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12342. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  12343. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12344. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  12345. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12346. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  12347. | /bin/mkdir -p include/near
  12348. | /bin/mkdir -p include/near
  12349. | /bin/mkdir -p include/near
  12350. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12351. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  12352. | /bin/mkdir -p include/near
  12353. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12354. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  12355. | /bin/mkdir -p include/near
  12356. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12357. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  12358. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12359. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  12360. | /bin/mkdir -p include/near
  12361. | /bin/mkdir -p include/near
  12362. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12363. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  12364. | /bin/mkdir -p include/near
  12365. | /bin/mkdir -p include/near
  12366. | /bin/mkdir -p include/near
  12367. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12368. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  12369. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12370. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  12371. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12372. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  12373. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12374. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  12375. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12376. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  12377. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  12378. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  12379. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  12380. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  12381. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  12382. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  12383. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  12384. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  12385. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  12386. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  12387. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  12388. -o tools/snep-send.o tools/snep-send.c
  12389. | In file included from tools/snep-send.c:16:0:
  12390. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  12391. | #include &lt;near/dbus.h&gt;
  12392. | ^
  12393. | compilation terminated.
  12394. | make[1]: *** [tools/snep-send.o] Error 1
  12395. | make[1]: *** Waiting for unfinished jobs....
  12396. | make: *** [all] Error 2
  12397. | ERROR: oe_runmake failed
  12398. </literallayout>
  12399. </para>
  12400. </section>
  12401. <section id='reproducing-the-error'>
  12402. <title>Reproducing the Error</title>
  12403. <para>
  12404. Because race conditions are intermittent, they do not
  12405. manifest themselves every time you do the build.
  12406. In fact, most times the build will complete without problems
  12407. even though the potential race condition exists.
  12408. Thus, once the error surfaces, you need a way to reproduce
  12409. it.
  12410. </para>
  12411. <para>
  12412. In this example, compiling the "neard" package is causing
  12413. the problem.
  12414. So the first thing to do is build "neard" locally.
  12415. Before you start the build, set the
  12416. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  12417. variable in your <filename>local.conf</filename> file to
  12418. a high number (e.g. "-j 20").
  12419. Using a high value for <filename>PARALLEL_MAKE</filename>
  12420. increases the chances of the race condition showing up:
  12421. <literallayout class='monospaced'>
  12422. $ bitbake neard
  12423. </literallayout>
  12424. </para>
  12425. <para>
  12426. Once the local build for "neard" completes, start a
  12427. <filename>devshell</filename> build:
  12428. <literallayout class='monospaced'>
  12429. $ bitbake neard -c devshell
  12430. </literallayout>
  12431. For information on how to use a
  12432. <filename>devshell</filename>, see the
  12433. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  12434. section.
  12435. </para>
  12436. <para>
  12437. In the <filename>devshell</filename>, do the following:
  12438. <literallayout class='monospaced'>
  12439. $ make clean
  12440. $ make tools/snep-send.o
  12441. </literallayout>
  12442. The <filename>devshell</filename> commands cause the failure
  12443. to clearly be visible.
  12444. In this case, a missing dependency exists for the "neard"
  12445. Makefile target.
  12446. Here is some abbreviated, sample output with the
  12447. missing dependency clearly visible at the end:
  12448. <literallayout class='monospaced'>
  12449. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  12450. .
  12451. .
  12452. .
  12453. tools/snep-send.c
  12454. In file included from tools/snep-send.c:16:0:
  12455. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  12456. #include &lt;near/dbus.h&gt;
  12457. ^
  12458. compilation terminated.
  12459. make: *** [tools/snep-send.o] Error 1
  12460. $
  12461. </literallayout>
  12462. </para>
  12463. </section>
  12464. <section id='creating-a-patch-for-the-fix'>
  12465. <title>Creating a Patch for the Fix</title>
  12466. <para>
  12467. Because there is a missing dependency for the Makefile
  12468. target, you need to patch the
  12469. <filename>Makefile.am</filename> file, which is generated
  12470. from <filename>Makefile.in</filename>.
  12471. You can use Quilt to create the patch:
  12472. <literallayout class='monospaced'>
  12473. $ quilt new parallelmake.patch
  12474. Patch patches/parallelmake.patch is now on top
  12475. $ quilt add Makefile.am
  12476. File Makefile.am added to patch patches/parallelmake.patch
  12477. </literallayout>
  12478. For more information on using Quilt, see the
  12479. "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
  12480. section.
  12481. </para>
  12482. <para>
  12483. At this point you need to make the edits to
  12484. <filename>Makefile.am</filename> to add the missing
  12485. dependency.
  12486. For our example, you have to add the following line
  12487. to the file:
  12488. <literallayout class='monospaced'>
  12489. tools/snep-send.$(OBJEXT): include/near/dbus.h
  12490. </literallayout>
  12491. </para>
  12492. <para>
  12493. Once you have edited the file, use the
  12494. <filename>refresh</filename> command to create the patch:
  12495. <literallayout class='monospaced'>
  12496. $ quilt refresh
  12497. Refreshed patch patches/parallelmake.patch
  12498. </literallayout>
  12499. Once the patch file exists, you need to add it back to the
  12500. originating recipe folder.
  12501. Here is an example assuming a top-level
  12502. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  12503. named <filename>poky</filename>:
  12504. <literallayout class='monospaced'>
  12505. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  12506. </literallayout>
  12507. The final thing you need to do to implement the fix in the
  12508. build is to update the "neard" recipe (i.e.
  12509. <filename>neard-0.14.bb</filename>) so that the
  12510. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  12511. statement includes the patch file.
  12512. The recipe file is in the folder above the patch.
  12513. Here is what the edited <filename>SRC_URI</filename>
  12514. statement would look like:
  12515. <literallayout class='monospaced'>
  12516. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  12517. file://neard.in \
  12518. file://neard.service.in \
  12519. file://parallelmake.patch \
  12520. "
  12521. </literallayout>
  12522. </para>
  12523. <para>
  12524. With the patch complete and moved to the correct folder and
  12525. the <filename>SRC_URI</filename> statement updated, you can
  12526. exit the <filename>devshell</filename>:
  12527. <literallayout class='monospaced'>
  12528. $ exit
  12529. </literallayout>
  12530. </para>
  12531. </section>
  12532. <section id='testing-the-build'>
  12533. <title>Testing the Build</title>
  12534. <para>
  12535. With everything in place, you can get back to trying the
  12536. build again locally:
  12537. <literallayout class='monospaced'>
  12538. $ bitbake neard
  12539. </literallayout>
  12540. This build should succeed.
  12541. </para>
  12542. <para>
  12543. Now you can open up a <filename>devshell</filename> again
  12544. and repeat the clean and make operations as follows:
  12545. <literallayout class='monospaced'>
  12546. $ bitbake neard -c devshell
  12547. $ make clean
  12548. $ make tools/snep-send.o
  12549. </literallayout>
  12550. The build should work without issue.
  12551. </para>
  12552. <para>
  12553. As with all solved problems, if they originated upstream,
  12554. you need to submit the fix for the recipe in OE-Core and
  12555. upstream so that the problem is taken care of at its
  12556. source.
  12557. See the
  12558. "<link linkend='how-to-submit-a-change'>Submitting a Change to the Yocto Project</link>"
  12559. section for more information.
  12560. </para>
  12561. </section>
  12562. </section>
  12563. <section id="platdev-gdb-remotedebug">
  12564. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  12565. <para>
  12566. GDB allows you to examine running programs, which in turn helps
  12567. you to understand and fix problems.
  12568. It also allows you to perform post-mortem style analysis of
  12569. program crashes.
  12570. GDB is available as a package within the Yocto Project and is
  12571. installed in SDK images by default.
  12572. See the
  12573. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  12574. chapter in the Yocto Project Reference Manual for a description of
  12575. these images.
  12576. You can find information on GDB at
  12577. <ulink url="http://sourceware.org/gdb/"/>.
  12578. <note><title>Tip</title>
  12579. For best results, install debug (<filename>-dbg</filename>)
  12580. packages for the applications you are going to debug.
  12581. Doing so makes extra debug symbols available that give you
  12582. more meaningful output.
  12583. </note>
  12584. </para>
  12585. <para>
  12586. Sometimes, due to memory or disk space constraints, it is not
  12587. possible to use GDB directly on the remote target to debug
  12588. applications.
  12589. These constraints arise because GDB needs to load the debugging
  12590. information and the binaries of the process being debugged.
  12591. Additionally, GDB needs to perform many computations to locate
  12592. information such as function names, variable names and values,
  12593. stack traces and so forth - even before starting the debugging
  12594. process.
  12595. These extra computations place more load on the target system
  12596. and can alter the characteristics of the program being debugged.
  12597. </para>
  12598. <para>
  12599. To help get past the previously mentioned constraints, you can
  12600. use gdbserver, which runs on the remote target and does not
  12601. load any debugging information from the debugged process.
  12602. Instead, a GDB instance processes the debugging information that
  12603. is run on a remote computer - the host GDB.
  12604. The host GDB then sends control commands to gdbserver to make
  12605. it stop or start the debugged program, as well as read or write
  12606. memory regions of that debugged program.
  12607. All the debugging information loaded and processed as well
  12608. as all the heavy debugging is done by the host GDB.
  12609. Offloading these processes gives the gdbserver running on the
  12610. target a chance to remain small and fast.
  12611. </para>
  12612. <para>
  12613. Because the host GDB is responsible for loading the debugging
  12614. information and for doing the necessary processing to make
  12615. actual debugging happen, you have to make sure the host can
  12616. access the unstripped binaries complete with their debugging
  12617. information and also be sure the target is compiled with no
  12618. optimizations.
  12619. The host GDB must also have local access to all the libraries
  12620. used by the debugged program.
  12621. Because gdbserver does not need any local debugging information,
  12622. the binaries on the remote target can remain stripped.
  12623. However, the binaries must also be compiled without optimization
  12624. so they match the host's binaries.
  12625. </para>
  12626. <para>
  12627. To remain consistent with GDB documentation and terminology,
  12628. the binary being debugged on the remote target machine is
  12629. referred to as the "inferior" binary.
  12630. For documentation on GDB see the
  12631. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  12632. </para>
  12633. <para>
  12634. The following steps show you how to debug using the GNU project
  12635. debugger.
  12636. <orderedlist>
  12637. <listitem><para>
  12638. <emphasis>Configure your build system to construct the
  12639. companion debug filesystem:</emphasis></para>
  12640. <para>In your <filename>local.conf</filename> file, set
  12641. the following:
  12642. <literallayout class='monospaced'>
  12643. IMAGE_GEN_DEBUGFS = "1"
  12644. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  12645. </literallayout>
  12646. These options cause the OpenEmbedded build system
  12647. to generate a special companion filesystem fragment,
  12648. which contains the matching source and debug symbols to
  12649. your deployable filesystem.
  12650. The build system does this by looking at what is in the
  12651. deployed filesystem, and pulling the corresponding
  12652. <filename>-dbg</filename> packages.</para>
  12653. <para>The companion debug filesystem is not a complete
  12654. filesystem, but only contains the debug fragments.
  12655. This filesystem must be combined with the full filesystem
  12656. for debugging.
  12657. Subsequent steps in this procedure show how to combine
  12658. the partial filesystem with the full filesystem.
  12659. </para></listitem>
  12660. <listitem><para>
  12661. <emphasis>Configure the system to include gdbserver in
  12662. the target filesystem:</emphasis></para>
  12663. <para>Make the following addition in either your
  12664. <filename>local.conf</filename> file or in an image
  12665. recipe:
  12666. <literallayout class='monospaced'>
  12667. IMAGE_INSTALL_append = “ gdbserver"
  12668. </literallayout>
  12669. The change makes sure the <filename>gdbserver</filename>
  12670. package is included.
  12671. </para></listitem>
  12672. <listitem><para>
  12673. <emphasis>Build the environment:</emphasis></para>
  12674. <para>Use the following command to construct the image
  12675. and the companion Debug Filesystem:
  12676. <literallayout class='monospaced'>
  12677. $ bitbake <replaceable>image</replaceable>
  12678. </literallayout>
  12679. Build the cross GDB component and make it available
  12680. for debugging.
  12681. Build the SDK that matches the image.
  12682. Building the SDK is best for a production build
  12683. that can be used later for debugging, especially
  12684. during long term maintenance:
  12685. <literallayout class='monospaced'>
  12686. $ bitbake -c populate_sdk <replaceable>image</replaceable>
  12687. </literallayout></para>
  12688. <para>Alternatively, you can build the minimal
  12689. toolchain components that match the target.
  12690. Doing so creates a smaller than typical SDK and only
  12691. contains a minimal set of components with which to
  12692. build simple test applications, as well as run the
  12693. debugger:
  12694. <literallayout class='monospaced'>
  12695. $ bitbake meta-toolchain
  12696. </literallayout></para>
  12697. <para>A final method is to build Gdb itself within
  12698. the build system:
  12699. <literallayout class='monospaced'>
  12700. $ bitbake gdb-cross-<replaceable>architecture</replaceable>
  12701. </literallayout>
  12702. Doing so produces a temporary copy of
  12703. <filename>cross-gdb</filename> you can use for
  12704. debugging during development.
  12705. While this is the quickest approach, the two previous
  12706. methods in this step are better when considering
  12707. long-term maintenance strategies.
  12708. <note>
  12709. If you run
  12710. <filename>bitbake gdb-cross</filename>, the
  12711. OpenEmbedded build system suggests the actual
  12712. image (e.g. <filename>gdb-cross-i586</filename>).
  12713. The suggestion is usually the actual name you want
  12714. to use.
  12715. </note>
  12716. </para></listitem>
  12717. <listitem><para>
  12718. <emphasis>Set up the</emphasis>&nbsp;<filename>debugfs</filename></para>
  12719. <para>Run the following commands to set up the
  12720. <filename>debugfs</filename>:
  12721. <literallayout class='monospaced'>
  12722. $ mkdir debugfs
  12723. $ cd debugfs
  12724. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2
  12725. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2
  12726. </literallayout>
  12727. </para></listitem>
  12728. <listitem><para>
  12729. <emphasis>Set up GDB</emphasis></para>
  12730. <para>Install the SDK (if you built one) and then
  12731. source the correct environment file.
  12732. Sourcing the environment file puts the SDK in your
  12733. <filename>PATH</filename> environment variable.</para>
  12734. <para>If you are using the build system, Gdb is
  12735. located in
  12736. <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb
  12737. </para></listitem>
  12738. <listitem><para>
  12739. <emphasis>Boot the target:</emphasis></para>
  12740. <para>For information on how to run QEMU, see the
  12741. <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>.
  12742. <note>
  12743. Be sure to verify that your host can access the
  12744. target via TCP.
  12745. </note>
  12746. </para></listitem>
  12747. <listitem><para>
  12748. <emphasis>Debug a program:</emphasis></para>
  12749. <para>Debugging a program involves running gdbserver
  12750. on the target and then running Gdb on the host.
  12751. The example in this step debugs
  12752. <filename>gzip</filename>:
  12753. <literallayout class='monospaced'>
  12754. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  12755. </literallayout>
  12756. For additional gdbserver options, see the
  12757. <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>.
  12758. </para>
  12759. <para>After running gdbserver on the target, you need
  12760. to run Gdb on the host and configure it and connect to
  12761. the target.
  12762. Use these commands:
  12763. <literallayout class='monospaced'>
  12764. $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable>
  12765. $ <replaceable>arch</replaceable>-gdb
  12766. (gdb) set sysroot debugfs
  12767. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  12768. (gdb) target remote <replaceable>IP-of-target</replaceable>:1234
  12769. </literallayout>
  12770. At this point, everything should automatically load
  12771. (i.e. matching binaries, symbols and headers).
  12772. <note>
  12773. The Gdb <filename>set</filename> commands in the
  12774. previous example can be placed into the users
  12775. <filename>~/.gdbinit</filename> file.
  12776. Upon starting, Gdb automatically runs whatever
  12777. commands are in that file.
  12778. </note>
  12779. </para></listitem>
  12780. <listitem><para>
  12781. <emphasis>Deploying without a full image
  12782. rebuild:</emphasis></para>
  12783. <para>In many cases, during development you want a
  12784. quick method to deploy a new binary to the target and
  12785. debug it, without waiting for a full image build.
  12786. </para>
  12787. <para>One approach to solving this situation is to
  12788. just build the component you want to debug.
  12789. Once you have built the component, copy the
  12790. executable directly to both the target and the
  12791. host <filename>debugfs</filename>.</para>
  12792. <para>If the binary is processed through the debug
  12793. splitting in OpenEmbedded, you should also
  12794. copy the debug items (i.e. <filename>.debug</filename>
  12795. contents and corresponding
  12796. <filename>/usr/src/debug</filename> files)
  12797. from the work directory.
  12798. Here is an example:
  12799. <literallayout class='monospaced'>
  12800. $ bitbake bash
  12801. $ bitbake -c devshell bash
  12802. $ cd ..
  12803. $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash
  12804. $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs
  12805. </literallayout>
  12806. </para></listitem>
  12807. </orderedlist>
  12808. </para>
  12809. </section>
  12810. <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>
  12811. <title>Debugging with the GNU Project Debugger (GDB) on the Target</title>
  12812. <para>
  12813. The previous section addressed using GDB remotely for debugging
  12814. purposes, which is the most usual case due to the inherent
  12815. hardware limitations on many embedded devices.
  12816. However, debugging in the target hardware itself is also
  12817. possible with more powerful devices.
  12818. This section describes what you need to do in order to support
  12819. using GDB to debug on the target hardware.
  12820. </para>
  12821. <para>
  12822. To support this kind of debugging, you need do the following:
  12823. <itemizedlist>
  12824. <listitem><para>
  12825. Ensure that GDB is on the target.
  12826. You can do this by adding "gdb" to
  12827. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  12828. <literallayout class='monospaced'>
  12829. IMAGE_INSTALL_append = " gdb"
  12830. </literallayout>
  12831. Alternatively, you can add "tools-debug" to
  12832. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  12833. <literallayout class='monospaced'>
  12834. IMAGE_FEATURES_append = " tools-debug"
  12835. </literallayout>
  12836. </para></listitem>
  12837. <listitem><para>
  12838. Ensure that debug symbols are present.
  12839. You can make sure these symbols are present by
  12840. installing <filename>-dbg</filename>:
  12841. <literallayout class='monospaced'>
  12842. IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg"
  12843. </literallayout>
  12844. Alternatively, you can do the following to include all
  12845. the debug symbols:
  12846. <literallayout class='monospaced'>
  12847. IMAGE_FEATURES_append = " dbg-pkgs"
  12848. </literallayout>
  12849. </para></listitem>
  12850. </itemizedlist>
  12851. <note>
  12852. To improve the debug information accuracy, you can reduce
  12853. the level of optimization used by the compiler.
  12854. For example, when adding the following line to your
  12855. <filename>local.conf</filename> file, you will reduce
  12856. optimization from
  12857. <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink>
  12858. of "-O2" to
  12859. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink>
  12860. of "-O -fno-omit-frame-pointer":
  12861. <literallayout class='monospaced'>
  12862. DEBUG_BUILD = "1"
  12863. </literallayout>
  12864. Consider that this will reduce the application's performance
  12865. and is recommended only for debugging purposes.
  12866. </note>
  12867. </para>
  12868. </section>
  12869. <section id='dev-other-debugging-others'>
  12870. <title>Other Debugging Tips</title>
  12871. <para>
  12872. Here are some other tips that you might find useful:
  12873. <itemizedlist>
  12874. <listitem><para>
  12875. When adding new packages, it is worth watching for
  12876. undesirable items making their way into compiler command
  12877. lines.
  12878. For example, you do not want references to local system
  12879. files like
  12880. <filename>/usr/lib/</filename> or
  12881. <filename>/usr/include/</filename>.
  12882. </para></listitem>
  12883. <listitem><para>
  12884. If you want to remove the <filename>psplash</filename>
  12885. boot splashscreen,
  12886. add <filename>psplash=false</filename> to the kernel
  12887. command line.
  12888. Doing so prevents <filename>psplash</filename> from
  12889. loading and thus allows you to see the console.
  12890. It is also possible to switch out of the splashscreen by
  12891. switching the virtual console (e.g. Fn+Left or Fn+Right
  12892. on a Zaurus).
  12893. </para></listitem>
  12894. <listitem><para>
  12895. Removing
  12896. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  12897. (usually <filename>tmp/</filename>, within the
  12898. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>)
  12899. can often fix temporary build issues.
  12900. Removing <filename>TMPDIR</filename> is usually a
  12901. relatively cheap operation, because task output will be
  12902. cached in
  12903. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  12904. (usually <filename>sstate-cache/</filename>, which is
  12905. also in the Build Directory).
  12906. <note>
  12907. Removing <filename>TMPDIR</filename> might be a
  12908. workaround rather than a fix.
  12909. Consequently, trying to determine the underlying
  12910. cause of an issue before removing the directory is
  12911. a good idea.
  12912. </note>
  12913. </para></listitem>
  12914. <listitem><para>
  12915. Understanding how a feature is used in practice within
  12916. existing recipes can be very helpful.
  12917. It is recommended that you configure some method that
  12918. allows you to quickly search through files.</para>
  12919. <para>Using GNU Grep, you can use the following shell
  12920. function to recursively search through common
  12921. recipe-related files, skipping binary files,
  12922. <filename>.git</filename> directories, and the
  12923. Build Directory (assuming its name starts with
  12924. "build"):
  12925. <literallayout class='monospaced'>
  12926. g() {
  12927. grep -Ir \
  12928. --exclude-dir=.git \
  12929. --exclude-dir='build*' \
  12930. --include='*.bb*' \
  12931. --include='*.inc*' \
  12932. --include='*.conf*' \
  12933. --include='*.py*' \
  12934. "$@"
  12935. }
  12936. </literallayout>
  12937. Following are some usage examples:
  12938. <literallayout class='monospaced'>
  12939. $ g FOO # Search recursively for "FOO"
  12940. $ g -i foo # Search recursively for "foo", ignoring case
  12941. $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
  12942. </literallayout>
  12943. If figuring out how some feature works requires a lot of
  12944. searching, it might indicate that the documentation
  12945. should be extended or improved.
  12946. In such cases, consider filing a documentation bug using
  12947. the Yocto Project implementation of
  12948. <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>.
  12949. For information on how to submit a bug against
  12950. the Yocto Project, see the Yocto Project Bugzilla
  12951. <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink>
  12952. and the
  12953. "<link linkend='submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</link>"
  12954. section.
  12955. <note>
  12956. The manuals might not be the right place to document
  12957. variables that are purely internal and have a
  12958. limited scope (e.g. internal variables used to
  12959. implement a single <filename>.bbclass</filename>
  12960. file).
  12961. </note>
  12962. </para></listitem>
  12963. </itemizedlist>
  12964. </para>
  12965. </section>
  12966. </section>
  12967. <section id='making-changes-to-the-yocto-project'>
  12968. <title>Making Changes to the Yocto Project</title>
  12969. <para>
  12970. Because the Yocto Project is an open-source, community-based
  12971. project, you can effect changes to the project.
  12972. This section presents procedures that show you how to submit
  12973. a defect against the project and how to submit a change.
  12974. </para>
  12975. <section id='submitting-a-defect-against-the-yocto-project'>
  12976. <title>Submitting a Defect Against the Yocto Project</title>
  12977. <para>
  12978. Use the Yocto Project implementation of
  12979. <ulink url='http://www.bugzilla.org/about/'>Bugzilla</ulink>
  12980. to submit a defect (bug) against the Yocto Project.
  12981. For additional information on this implementation of Bugzilla see the
  12982. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-bugtracker'>Yocto Project Bugzilla</ulink>"
  12983. section in the Yocto Project Reference Manual.
  12984. For more detail on any of the following steps, see the Yocto Project
  12985. <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>Bugzilla wiki page</ulink>.
  12986. </para>
  12987. <para>
  12988. Use the following general steps to submit a bug"
  12989. <orderedlist>
  12990. <listitem><para>
  12991. Open the Yocto Project implementation of
  12992. <ulink url='&YOCTO_BUGZILLA_URL;'>Bugzilla</ulink>.
  12993. </para></listitem>
  12994. <listitem><para>
  12995. Click "File a Bug" to enter a new bug.
  12996. </para></listitem>
  12997. <listitem><para>
  12998. Choose the appropriate "Classification", "Product", and
  12999. "Component" for which the bug was found.
  13000. Bugs for the Yocto Project fall into one of several
  13001. classifications, which in turn break down into several
  13002. products and components.
  13003. For example, for a bug against the
  13004. <filename>meta-intel</filename> layer, you would choose
  13005. "Build System, Metadata &amp; Runtime", "BSPs", and
  13006. "bsps-meta-intel", respectively.
  13007. </para></listitem>
  13008. <listitem><para>
  13009. Choose the "Version" of the Yocto Project for which you found
  13010. the bug (e.g. &DISTRO;).
  13011. </para></listitem>
  13012. <listitem><para>
  13013. Determine and select the "Severity" of the bug.
  13014. The severity indicates how the bug impacted your work.
  13015. </para></listitem>
  13016. <listitem><para>
  13017. Choose the "Hardware" that the bug impacts.
  13018. </para></listitem>
  13019. <listitem><para>
  13020. Choose the "Architecture" that the bug impacts.
  13021. </para></listitem>
  13022. <listitem><para>
  13023. Choose a "Documentation change" item for the bug.
  13024. Fixing a bug might or might not affect the Yocto Project
  13025. documentation.
  13026. If you are unsure of the impact to the documentation, select
  13027. "Don't Know".
  13028. </para></listitem>
  13029. <listitem><para>
  13030. Provide a brief "Summary" of the bug.
  13031. Try to limit your summary to just a line or two and be sure
  13032. to capture the essence of the bug.
  13033. </para></listitem>
  13034. <listitem><para>
  13035. Provide a detailed "Description" of the bug.
  13036. You should provide as much detail as you can about the context,
  13037. behavior, output, and so forth that surrounds the bug.
  13038. You can even attach supporting files for output from logs by
  13039. using the "Add an attachment" button.
  13040. </para></listitem>
  13041. <listitem><para>
  13042. Click the "Submit Bug" button submit the bug.
  13043. A new Bugzilla number is assigned to the bug and the defect
  13044. is logged in the bug tracking system.
  13045. </para></listitem>
  13046. </orderedlist>
  13047. Once you file a bug, the bug is processed by the Yocto Project Bug
  13048. Triage Team and further details concerning the bug are assigned
  13049. (e.g. priority and owner).
  13050. You are the "Submitter" of the bug and any further categorization,
  13051. progress, or comments on the bug result in Bugzilla sending you an
  13052. automated email concerning the particular change or progress to the
  13053. bug.
  13054. </para>
  13055. </section>
  13056. <section id='how-to-submit-a-change'>
  13057. <title>Submitting a Change to the Yocto Project</title>
  13058. <para>
  13059. Contributions to the Yocto Project and OpenEmbedded are very welcome.
  13060. Because the system is extremely configurable and flexible, we recognize
  13061. that developers will want to extend, configure or optimize it for
  13062. their specific uses.
  13063. </para>
  13064. <para>
  13065. The Yocto Project uses a mailing list and a patch-based workflow
  13066. that is similar to the Linux kernel but contains important
  13067. differences.
  13068. In general, a mailing list exists through which you can submit
  13069. patches.
  13070. You should send patches to the appropriate mailing list so that they
  13071. can be reviewed and merged by the appropriate maintainer.
  13072. The specific mailing list you need to use depends on the
  13073. location of the code you are changing.
  13074. Each component (e.g. layer) should have a
  13075. <filename>README</filename> file that indicates where to send
  13076. the changes and which process to follow.
  13077. </para>
  13078. <para>
  13079. You can send the patch to the mailing list using whichever approach
  13080. you feel comfortable with to generate the patch.
  13081. Once sent, the patch is usually reviewed by the community at large.
  13082. If somebody has concerns with the patch, they will usually voice
  13083. their concern over the mailing list.
  13084. If a patch does not receive any negative reviews, the maintainer of
  13085. the affected layer typically takes the patch, tests it, and then
  13086. based on successful testing, merges the patch.
  13087. </para>
  13088. <para id='figuring-out-the-mailing-list-to-use'>
  13089. The "poky" repository, which is the Yocto Project's reference build
  13090. environment, is a hybrid repository that contains several
  13091. individual pieces (e.g. BitBake, Metadata, documentation,
  13092. and so forth) built using the combo-layer tool.
  13093. The upstream location used for submitting changes varies by
  13094. component:
  13095. <itemizedlist>
  13096. <listitem><para>
  13097. <emphasis>Core Metadata:</emphasis>
  13098. Send your patch to the
  13099. <ulink url='http://lists.openembedded.org/mailman/listinfo/openembedded-core'>openembedded-core</ulink>
  13100. mailing list. For example, a change to anything under
  13101. the <filename>meta</filename> or
  13102. <filename>scripts</filename> directories should be sent
  13103. to this mailing list.
  13104. </para></listitem>
  13105. <listitem><para>
  13106. <emphasis>BitBake:</emphasis>
  13107. For changes to BitBake (i.e. anything under the
  13108. <filename>bitbake</filename> directory), send your patch
  13109. to the
  13110. <ulink url='http://lists.openembedded.org/mailman/listinfo/bitbake-devel'>bitbake-devel</ulink>
  13111. mailing list.
  13112. </para></listitem>
  13113. <listitem><para>
  13114. <emphasis>"meta-*" trees:</emphasis>
  13115. These trees contain Metadata.
  13116. Use the
  13117. <ulink url='https://lists.yoctoproject.org/listinfo/poky'>poky</ulink>
  13118. mailing list.
  13119. </para></listitem>
  13120. </itemizedlist>
  13121. </para>
  13122. <para>
  13123. For changes to other layers hosted in the Yocto Project source
  13124. repositories (i.e. <filename>yoctoproject.org</filename>), tools,
  13125. and the Yocto Project documentation, use the
  13126. <ulink url='https://lists.yoctoproject.org/listinfo/yocto'>Yocto Project</ulink>
  13127. general mailing list.
  13128. <note>
  13129. Sometimes a layer's documentation specifies to use a
  13130. particular mailing list.
  13131. If so, use that list.
  13132. </note>
  13133. For additional recipes that do not fit into the core Metadata, you
  13134. should determine which layer the recipe should go into and submit
  13135. the change in the manner recommended by the documentation (e.g.
  13136. the <filename>README</filename> file) supplied with the layer.
  13137. If in doubt, please ask on the Yocto general mailing list or on
  13138. the openembedded-devel mailing list.
  13139. </para>
  13140. <para>
  13141. You can also push a change upstream and request a maintainer to
  13142. pull the change into the component's upstream repository.
  13143. You do this by pushing to a contribution repository that is upstream.
  13144. See the
  13145. "<ulink url='&YOCTO_DOCS_OM_URL;#gs-git-workflows-and-the-yocto-project'>Git Workflows and the Yocto Project</ulink>"
  13146. section in the Yocto Project Overview and Concepts Manual for additional
  13147. concepts on working in the Yocto Project development environment.
  13148. </para>
  13149. <para>
  13150. Two commonly used testing repositories exist for
  13151. OpenEmbedded-Core:
  13152. <itemizedlist>
  13153. <listitem><para>
  13154. <emphasis>"ross/mut" branch:</emphasis>
  13155. The "mut" (master-under-test) tree
  13156. exists in the <filename>poky-contrib</filename> repository
  13157. in the
  13158. <ulink url='&YOCTO_GIT_URL;'>Yocto Project source repositories</ulink>.
  13159. </para></listitem>
  13160. <listitem><para>
  13161. <emphasis>"master-next" branch:</emphasis>
  13162. This branch is part of the main
  13163. "poky" repository in the Yocto Project source repositories.
  13164. </para></listitem>
  13165. </itemizedlist>
  13166. Maintainers use these branches to test submissions prior to merging
  13167. patches.
  13168. Thus, you can get an idea of the status of a patch based on
  13169. whether the patch has been merged into one of these branches.
  13170. <note>
  13171. This system is imperfect and changes can sometimes get lost in the
  13172. flow.
  13173. Asking about the status of a patch or change is reasonable if the
  13174. change has been idle for a while with no feedback.
  13175. The Yocto Project does have plans to use
  13176. <ulink url='https://en.wikipedia.org/wiki/Patchwork_(software)'>Patchwork</ulink>
  13177. to track the status of patches and also to automatically preview
  13178. patches.
  13179. </note>
  13180. </para>
  13181. <para>
  13182. The following sections provide procedures for submitting a change.
  13183. </para>
  13184. <section id='pushing-a-change-upstream'>
  13185. <title>Using Scripts to Push a Change Upstream and Request a Pull</title>
  13186. <para>
  13187. Follow this procedure to push a change to an upstream "contrib"
  13188. Git repository:
  13189. <note>
  13190. You can find general Git information on how to push a change
  13191. upstream in the
  13192. <ulink url='http://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows'>Git Community Book</ulink>.
  13193. </note>
  13194. <orderedlist>
  13195. <listitem><para>
  13196. <emphasis>Make Your Changes Locally:</emphasis>
  13197. Make your changes in your local Git repository.
  13198. You should make small, controlled, isolated changes.
  13199. Keeping changes small and isolated aids review,
  13200. makes merging/rebasing easier and keeps the change
  13201. history clean should anyone need to refer to it in
  13202. future.
  13203. </para></listitem>
  13204. <listitem><para>
  13205. <emphasis>Stage Your Changes:</emphasis>
  13206. Stage your changes by using the <filename>git add</filename>
  13207. command on each file you changed.
  13208. </para></listitem>
  13209. <listitem><para id='making-sure-you-have-correct-commit-information'>
  13210. <emphasis>Commit Your Changes:</emphasis>
  13211. Commit the change by using the
  13212. <filename>git commit</filename> command.
  13213. Make sure your commit information follows standards by
  13214. following these accepted conventions:
  13215. <itemizedlist>
  13216. <listitem><para>
  13217. Be sure to include a "Signed-off-by:" line in the
  13218. same style as required by the Linux kernel.
  13219. Adding this line signifies that you, the submitter,
  13220. have agreed to the Developer's Certificate of
  13221. Origin 1.1 as follows:
  13222. <literallayout class='monospaced'>
  13223. Developer's Certificate of Origin 1.1
  13224. By making a contribution to this project, I certify that:
  13225. (a) The contribution was created in whole or in part by me and I
  13226. have the right to submit it under the open source license
  13227. indicated in the file; or
  13228. (b) The contribution is based upon previous work that, to the best
  13229. of my knowledge, is covered under an appropriate open source
  13230. license and I have the right under that license to submit that
  13231. work with modifications, whether created in whole or in part
  13232. by me, under the same open source license (unless I am
  13233. permitted to submit under a different license), as indicated
  13234. in the file; or
  13235. (c) The contribution was provided directly to me by some other
  13236. person who certified (a), (b) or (c) and I have not modified
  13237. it.
  13238. (d) I understand and agree that this project and the contribution
  13239. are public and that a record of the contribution (including all
  13240. personal information I submit with it, including my sign-off) is
  13241. maintained indefinitely and may be redistributed consistent with
  13242. this project or the open source license(s) involved.
  13243. </literallayout>
  13244. </para></listitem>
  13245. <listitem><para>
  13246. Provide a single-line summary of the change.
  13247. and,
  13248. if more explanation is needed, provide more
  13249. detail in the body of the commit.
  13250. This summary is typically viewable in the
  13251. "shortlist" of changes.
  13252. Thus, providing something short and descriptive
  13253. that gives the reader a summary of the change is
  13254. useful when viewing a list of many commits.
  13255. You should prefix this short description with the
  13256. recipe name (if changing a recipe), or else with
  13257. the short form path to the file being changed.
  13258. </para></listitem>
  13259. <listitem><para>
  13260. For the body of the commit message, provide
  13261. detailed information that describes what you
  13262. changed, why you made the change, and the approach
  13263. you used.
  13264. It might also be helpful if you mention how you
  13265. tested the change.
  13266. Provide as much detail as you can in the body of
  13267. the commit message.
  13268. <note>
  13269. You do not need to provide a more detailed
  13270. explanation of a change if the change is
  13271. minor to the point of the single line
  13272. summary providing all the information.
  13273. </note>
  13274. </para></listitem>
  13275. <listitem><para>
  13276. If the change addresses a specific bug or issue
  13277. that is associated with a bug-tracking ID,
  13278. include a reference to that ID in your detailed
  13279. description.
  13280. For example, the Yocto Project uses a specific
  13281. convention for bug references - any commit that
  13282. addresses a specific bug should use the following
  13283. form for the detailed description.
  13284. Be sure to use the actual bug-tracking ID from
  13285. Bugzilla for
  13286. <replaceable>bug-id</replaceable>:
  13287. <literallayout class='monospaced'>
  13288. Fixes [YOCTO #<replaceable>bug-id</replaceable>]
  13289. <replaceable>detailed description of change</replaceable>
  13290. </literallayout>
  13291. </para></listitem>
  13292. </itemizedlist>
  13293. </para></listitem>
  13294. <listitem><para>
  13295. <emphasis>Push Your Commits to a "Contrib" Upstream:</emphasis>
  13296. If you have arranged for permissions to push to an
  13297. upstream contrib repository, push the change to that
  13298. repository:
  13299. <literallayout class='monospaced'>
  13300. $ git push <replaceable>upstream_remote_repo</replaceable> <replaceable>local_branch_name</replaceable>
  13301. </literallayout>
  13302. For example, suppose you have permissions to push into the
  13303. upstream <filename>meta-intel-contrib</filename>
  13304. repository and you are working in a local branch named
  13305. <replaceable>your_name</replaceable><filename>/README</filename>.
  13306. The following command pushes your local commits to the
  13307. <filename>meta-intel-contrib</filename> upstream
  13308. repository and puts the commit in a branch named
  13309. <replaceable>your_name</replaceable><filename>/README</filename>:
  13310. <literallayout class='monospaced'>
  13311. $ git push meta-intel-contrib <replaceable>your_name</replaceable>/README
  13312. </literallayout>
  13313. </para></listitem>
  13314. <listitem><para id='push-determine-who-to-notify'>
  13315. <emphasis>Determine Who to Notify:</emphasis>
  13316. Determine the maintainer or the mailing list
  13317. that you need to notify for the change.</para>
  13318. <para>Before submitting any change, you need to be sure
  13319. who the maintainer is or what mailing list that you need
  13320. to notify.
  13321. Use either these methods to find out:
  13322. <itemizedlist>
  13323. <listitem><para>
  13324. <emphasis>Maintenance File:</emphasis>
  13325. Examine the <filename>maintainers.inc</filename>
  13326. file, which is located in the
  13327. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  13328. at
  13329. <filename>meta/conf/distro/include</filename>,
  13330. to see who is responsible for code.
  13331. </para></listitem>
  13332. <listitem><para>
  13333. <emphasis>Search by File:</emphasis>
  13334. Using <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>,
  13335. you can enter the following command to bring up a
  13336. short list of all commits against a specific file:
  13337. <literallayout class='monospaced'>
  13338. git shortlog -- <replaceable>filename</replaceable>
  13339. </literallayout>
  13340. Just provide the name of the file for which you
  13341. are interested.
  13342. The information returned is not ordered by history
  13343. but does include a list of everyone who has
  13344. committed grouped by name.
  13345. From the list, you can see who is responsible for
  13346. the bulk of the changes against the file.
  13347. </para></listitem>
  13348. <listitem><para>
  13349. <emphasis>Examine the List of Mailing Lists:</emphasis>
  13350. For a list of the Yocto Project and related mailing
  13351. lists, see the
  13352. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>"
  13353. section in the Yocto Project Reference Manual.
  13354. </para></listitem>
  13355. </itemizedlist>
  13356. </para></listitem>
  13357. <listitem><para>
  13358. <emphasis>Make a Pull Request:</emphasis>
  13359. Notify the maintainer or the mailing list that you have
  13360. pushed a change by making a pull request.</para>
  13361. <para>The Yocto Project provides two scripts that
  13362. conveniently let you generate and send pull requests to the
  13363. Yocto Project.
  13364. These scripts are <filename>create-pull-request</filename>
  13365. and <filename>send-pull-request</filename>.
  13366. You can find these scripts in the
  13367. <filename>scripts</filename> directory within the
  13368. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  13369. (e.g. <filename>~/poky/scripts</filename>).
  13370. </para>
  13371. <para>Using these scripts correctly formats the requests
  13372. without introducing any whitespace or HTML formatting.
  13373. The maintainer that receives your patches either directly
  13374. or through the mailing list needs to be able to save and
  13375. apply them directly from your emails.
  13376. Using these scripts is the preferred method for sending
  13377. patches.</para>
  13378. <para>First, create the pull request.
  13379. For example, the following command runs the script,
  13380. specifies the upstream repository in the contrib directory
  13381. into which you pushed the change, and provides a subject
  13382. line in the created patch files:
  13383. <literallayout class='monospaced'>
  13384. $ ~/poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
  13385. </literallayout>
  13386. Running this script forms
  13387. <filename>*.patch</filename> files in a folder named
  13388. <filename>pull-</filename><replaceable>PID</replaceable>
  13389. in the current directory.
  13390. One of the patch files is a cover letter.</para>
  13391. <para>Before running the
  13392. <filename>send-pull-request</filename> script, you must
  13393. edit the cover letter patch to insert information about
  13394. your change.
  13395. After editing the cover letter, send the pull request.
  13396. For example, the following command runs the script and
  13397. specifies the patch directory and email address.
  13398. In this example, the email address is a mailing list:
  13399. <literallayout class='monospaced'>
  13400. $ ~/poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@yoctoproject.org
  13401. </literallayout>
  13402. You need to follow the prompts as the script is
  13403. interactive.
  13404. <note>
  13405. For help on using these scripts, simply provide the
  13406. <filename>-h</filename> argument as follows:
  13407. <literallayout class='monospaced'>
  13408. $ poky/scripts/create-pull-request -h
  13409. $ poky/scripts/send-pull-request -h
  13410. </literallayout>
  13411. </note>
  13412. </para></listitem>
  13413. </orderedlist>
  13414. </para>
  13415. </section>
  13416. <section id='submitting-a-patch'>
  13417. <title>Using Email to Submit a Patch</title>
  13418. <para>
  13419. You can submit patches without using the
  13420. <filename>create-pull-request</filename> and
  13421. <filename>send-pull-request</filename> scripts described in the
  13422. previous section.
  13423. However, keep in mind, the preferred method is to use the scripts.
  13424. </para>
  13425. <para>
  13426. Depending on the components changed, you need to submit the email
  13427. to a specific mailing list.
  13428. For some guidance on which mailing list to use, see the
  13429. <link linkend='figuring-out-the-mailing-list-to-use'>list</link>
  13430. at the beginning of this section.
  13431. For a description of all the available mailing lists, see the
  13432. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing Lists</ulink>"
  13433. section in the Yocto Project Reference Manual.
  13434. </para>
  13435. <para>
  13436. Here is the general procedure on how to submit a patch through
  13437. email without using the scripts:
  13438. <orderedlist>
  13439. <listitem><para>
  13440. <emphasis>Make Your Changes Locally:</emphasis>
  13441. Make your changes in your local Git repository.
  13442. You should make small, controlled, isolated changes.
  13443. Keeping changes small and isolated aids review,
  13444. makes merging/rebasing easier and keeps the change
  13445. history clean should anyone need to refer to it in
  13446. future.
  13447. </para></listitem>
  13448. <listitem><para>
  13449. <emphasis>Stage Your Changes:</emphasis>
  13450. Stage your changes by using the <filename>git add</filename>
  13451. command on each file you changed.
  13452. </para></listitem>
  13453. <listitem><para>
  13454. <emphasis>Commit Your Changes:</emphasis>
  13455. Commit the change by using the
  13456. <filename>git commit --signoff</filename> command.
  13457. Using the <filename>--signoff</filename> option identifies
  13458. you as the person making the change and also satisfies
  13459. the Developer's Certificate of Origin (DCO) shown earlier.
  13460. </para>
  13461. <para>When you form a commit, you must follow certain
  13462. standards established by the Yocto Project development
  13463. team.
  13464. See
  13465. <link linkend='making-sure-you-have-correct-commit-information'>Step 3</link>
  13466. in the previous section for information on how to
  13467. provide commit information that meets Yocto Project
  13468. commit message standards.
  13469. </para></listitem>
  13470. <listitem><para>
  13471. <emphasis>Format the Commit:</emphasis>
  13472. Format the commit into an email message.
  13473. To format commits, use the
  13474. <filename>git format-patch</filename> command.
  13475. When you provide the command, you must include a revision
  13476. list or a number of patches as part of the command.
  13477. For example, either of these two commands takes your most
  13478. recent single commit and formats it as an email message in
  13479. the current directory:
  13480. <literallayout class='monospaced'>
  13481. $ git format-patch -1
  13482. </literallayout>
  13483. or
  13484. <literallayout class='monospaced'>
  13485. $ git format-patch HEAD~
  13486. </literallayout></para>
  13487. <para>After the command is run, the current directory
  13488. contains a numbered <filename>.patch</filename> file for
  13489. the commit.</para>
  13490. <para>If you provide several commits as part of the
  13491. command, the <filename>git format-patch</filename> command
  13492. produces a series of numbered files in the current
  13493. directory – one for each commit.
  13494. If you have more than one patch, you should also use the
  13495. <filename>--cover</filename> option with the command,
  13496. which generates a cover letter as the first "patch" in
  13497. the series.
  13498. You can then edit the cover letter to provide a
  13499. description for the series of patches.
  13500. For information on the
  13501. <filename>git format-patch</filename> command,
  13502. see <filename>GIT_FORMAT_PATCH(1)</filename> displayed
  13503. using the <filename>man git-format-patch</filename>
  13504. command.
  13505. <note>
  13506. If you are or will be a frequent contributor to the
  13507. Yocto Project or to OpenEmbedded, you might consider
  13508. requesting a contrib area and the necessary associated
  13509. rights.
  13510. </note>
  13511. </para></listitem>
  13512. <listitem><para>
  13513. <emphasis>Import the Files Into Your Mail Client:</emphasis>
  13514. Import the files into your mail client by using the
  13515. <filename>git send-email</filename> command.
  13516. <note>
  13517. In order to use <filename>git send-email</filename>,
  13518. you must have the proper Git packages installed on
  13519. your host.
  13520. For Ubuntu, Debian, and Fedora the package is
  13521. <filename>git-email</filename>.
  13522. </note></para>
  13523. <para>The <filename>git send-email</filename> command
  13524. sends email by using a local or remote Mail Transport Agent
  13525. (MTA) such as <filename>msmtp</filename>,
  13526. <filename>sendmail</filename>, or through a direct
  13527. <filename>smtp</filename> configuration in your Git
  13528. <filename>~/.gitconfig</filename> file.
  13529. If you are submitting patches through email only, it is
  13530. very important that you submit them without any whitespace
  13531. or HTML formatting that either you or your mailer
  13532. introduces.
  13533. The maintainer that receives your patches needs to be able
  13534. to save and apply them directly from your emails.
  13535. A good way to verify that what you are sending will be
  13536. applicable by the maintainer is to do a dry run and send
  13537. them to yourself and then save and apply them as the
  13538. maintainer would.</para>
  13539. <para>The <filename>git send-email</filename> command is
  13540. the preferred method for sending your patches using
  13541. email since there is no risk of compromising whitespace
  13542. in the body of the message, which can occur when you use
  13543. your own mail client.
  13544. The command also has several options that let you
  13545. specify recipients and perform further editing of the
  13546. email message.
  13547. For information on how to use the
  13548. <filename>git send-email</filename> command,
  13549. see <filename>GIT-SEND-EMAIL(1)</filename> displayed using
  13550. the <filename>man git-send-email</filename> command.
  13551. </para></listitem>
  13552. </orderedlist>
  13553. </para>
  13554. </section>
  13555. </section>
  13556. </section>
  13557. <section id='working-with-licenses'>
  13558. <title>Working With Licenses</title>
  13559. <para>
  13560. As mentioned in the
  13561. "<ulink url='&YOCTO_DOCS_OM_URL;#licensing'>Licensing</ulink>"
  13562. section in the Yocto Project Overview and Concepts Manual,
  13563. open source projects are open to the public and they
  13564. consequently have different licensing structures in place.
  13565. This section describes the mechanism by which the
  13566. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  13567. tracks changes to licensing text and covers how to maintain open
  13568. source license compliance during your project's lifecycle.
  13569. The section also describes how to enable commercially licensed
  13570. recipes, which by default are disabled.
  13571. </para>
  13572. <section id="usingpoky-configuring-LIC_FILES_CHKSUM">
  13573. <title>Tracking License Changes</title>
  13574. <para>
  13575. The license of an upstream project might change in the future.
  13576. In order to prevent these changes going unnoticed, the
  13577. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  13578. variable tracks changes to the license text. The checksums are
  13579. validated at the end of the configure step, and if the
  13580. checksums do not match, the build will fail.
  13581. </para>
  13582. <section id="usingpoky-specifying-LIC_FILES_CHKSUM">
  13583. <title>Specifying the <filename>LIC_FILES_CHKSUM</filename> Variable</title>
  13584. <para>
  13585. The <filename>LIC_FILES_CHKSUM</filename>
  13586. variable contains checksums of the license text in the
  13587. source code for the recipe.
  13588. Following is an example of how to specify
  13589. <filename>LIC_FILES_CHKSUM</filename>:
  13590. <literallayout class='monospaced'>
  13591. LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \
  13592. file://licfile1.txt;beginline=5;endline=29;md5=yyyy \
  13593. file://licfile2.txt;endline=50;md5=zzzz \
  13594. ..."
  13595. </literallayout>
  13596. <note><title>Notes</title>
  13597. <itemizedlist>
  13598. <listitem><para>
  13599. When using "beginline" and "endline", realize
  13600. that line numbering begins with one and not
  13601. zero.
  13602. Also, the included lines are inclusive (i.e.
  13603. lines five through and including 29 in the
  13604. previous example for
  13605. <filename>licfile1.txt</filename>).
  13606. </para></listitem>
  13607. <listitem><para>
  13608. When a license check fails, the selected license
  13609. text is included as part of the QA message.
  13610. Using this output, you can determine the exact
  13611. start and finish for the needed license text.
  13612. </para></listitem>
  13613. </itemizedlist>
  13614. </note>
  13615. </para>
  13616. <para>
  13617. The build system uses the
  13618. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  13619. variable as the default directory when searching files
  13620. listed in <filename>LIC_FILES_CHKSUM</filename>.
  13621. The previous example employs the default directory.
  13622. </para>
  13623. <para>
  13624. Consider this next example:
  13625. <literallayout class='monospaced'>
  13626. LIC_FILES_CHKSUM = "file://src/ls.c;beginline=5;endline=16;\
  13627. md5=bb14ed3c4cda583abc85401304b5cd4e"
  13628. LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6"
  13629. </literallayout>
  13630. </para>
  13631. <para>
  13632. The first line locates a file in
  13633. <filename>${S}/src/ls.c</filename> and isolates lines five
  13634. through 16 as license text.
  13635. The second line refers to a file in
  13636. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  13637. </para>
  13638. <para>
  13639. Note that <filename>LIC_FILES_CHKSUM</filename> variable is
  13640. mandatory for all recipes, unless the
  13641. <filename>LICENSE</filename> variable is set to "CLOSED".
  13642. </para>
  13643. </section>
  13644. <section id="usingpoky-LIC_FILES_CHKSUM-explanation-of-syntax">
  13645. <title>Explanation of Syntax</title>
  13646. <para>
  13647. As mentioned in the previous section, the
  13648. <filename>LIC_FILES_CHKSUM</filename> variable lists all
  13649. the important files that contain the license text for the
  13650. source code.
  13651. It is possible to specify a checksum for an entire file,
  13652. or a specific section of a file (specified by beginning and
  13653. ending line numbers with the "beginline" and "endline"
  13654. parameters, respectively).
  13655. The latter is useful for source files with a license
  13656. notice header, README documents, and so forth.
  13657. If you do not use the "beginline" parameter, then it is
  13658. assumed that the text begins on the first line of the file.
  13659. Similarly, if you do not use the "endline" parameter,
  13660. it is assumed that the license text ends with the last
  13661. line of the file.
  13662. </para>
  13663. <para>
  13664. The "md5" parameter stores the md5 checksum of the license
  13665. text.
  13666. If the license text changes in any way as compared to
  13667. this parameter then a mismatch occurs.
  13668. This mismatch triggers a build failure and notifies
  13669. the developer.
  13670. Notification allows the developer to review and address
  13671. the license text changes.
  13672. Also note that if a mismatch occurs during the build,
  13673. the correct md5 checksum is placed in the build log and
  13674. can be easily copied to the recipe.
  13675. </para>
  13676. <para>
  13677. There is no limit to how many files you can specify using
  13678. the <filename>LIC_FILES_CHKSUM</filename> variable.
  13679. Generally, however, every project requires a few
  13680. specifications for license tracking.
  13681. Many projects have a "COPYING" file that stores the
  13682. license information for all the source code files.
  13683. This practice allows you to just track the "COPYING"
  13684. file as long as it is kept up to date.
  13685. <note><title>Tips</title>
  13686. <itemizedlist>
  13687. <listitem><para>
  13688. If you specify an empty or invalid "md5"
  13689. parameter,
  13690. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  13691. returns an md5 mis-match
  13692. error and displays the correct "md5" parameter
  13693. value during the build.
  13694. The correct parameter is also captured in
  13695. the build log.
  13696. </para></listitem>
  13697. <listitem><para>
  13698. If the whole file contains only license text,
  13699. you do not need to use the "beginline" and
  13700. "endline" parameters.
  13701. </para></listitem>
  13702. </itemizedlist>
  13703. </note>
  13704. </para>
  13705. </section>
  13706. </section>
  13707. <section id="enabling-commercially-licensed-recipes">
  13708. <title>Enabling Commercially Licensed Recipes</title>
  13709. <para>
  13710. By default, the OpenEmbedded build system disables
  13711. components that have commercial or other special licensing
  13712. requirements.
  13713. Such requirements are defined on a
  13714. recipe-by-recipe basis through the
  13715. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS'><filename>LICENSE_FLAGS</filename></ulink>
  13716. variable definition in the affected recipe.
  13717. For instance, the
  13718. <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename>
  13719. recipe contains the following statement:
  13720. <literallayout class='monospaced'>
  13721. LICENSE_FLAGS = "commercial"
  13722. </literallayout>
  13723. Here is a slightly more complicated example that contains both
  13724. an explicit recipe name and version (after variable expansion):
  13725. <literallayout class='monospaced'>
  13726. LICENSE_FLAGS = "license_${PN}_${PV}"
  13727. </literallayout>
  13728. In order for a component restricted by a
  13729. <filename>LICENSE_FLAGS</filename> definition to be enabled and
  13730. included in an image, it needs to have a matching entry in the
  13731. global
  13732. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS_WHITELIST'><filename>LICENSE_FLAGS_WHITELIST</filename></ulink>
  13733. variable, which is a variable typically defined in your
  13734. <filename>local.conf</filename> file.
  13735. For example, to enable the
  13736. <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename>
  13737. package, you could add either the string
  13738. "commercial_gst-plugins-ugly" or the more general string
  13739. "commercial" to <filename>LICENSE_FLAGS_WHITELIST</filename>.
  13740. See the
  13741. "<link linkend='license-flag-matching'>License Flag Matching</link>"
  13742. section for a full
  13743. explanation of how <filename>LICENSE_FLAGS</filename> matching
  13744. works.
  13745. Here is the example:
  13746. <literallayout class='monospaced'>
  13747. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly"
  13748. </literallayout>
  13749. Likewise, to additionally enable the package built from the
  13750. recipe containing
  13751. <filename>LICENSE_FLAGS = "license_${PN}_${PV}"</filename>,
  13752. and assuming that the actual recipe name was
  13753. <filename>emgd_1.10.bb</filename>, the following string would
  13754. enable that package as well as the original
  13755. <filename>gst-plugins-ugly</filename> package:
  13756. <literallayout class='monospaced'>
  13757. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10"
  13758. </literallayout>
  13759. As a convenience, you do not need to specify the complete
  13760. license string in the whitelist for every package.
  13761. You can use an abbreviated form, which consists
  13762. of just the first portion or portions of the license
  13763. string before the initial underscore character or characters.
  13764. A partial string will match any license that contains the
  13765. given string as the first portion of its license.
  13766. For example, the following whitelist string will also match
  13767. both of the packages previously mentioned as well as any other
  13768. packages that have licenses starting with "commercial" or
  13769. "license".
  13770. <literallayout class='monospaced'>
  13771. LICENSE_FLAGS_WHITELIST = "commercial license"
  13772. </literallayout>
  13773. </para>
  13774. <section id="license-flag-matching">
  13775. <title>License Flag Matching</title>
  13776. <para>
  13777. License flag matching allows you to control what recipes
  13778. the OpenEmbedded build system includes in the build.
  13779. Fundamentally, the build system attempts to match
  13780. <filename>LICENSE_FLAGS</filename> strings found in recipes
  13781. against <filename>LICENSE_FLAGS_WHITELIST</filename>
  13782. strings found in the whitelist.
  13783. A match causes the build system to include a recipe in the
  13784. build, while failure to find a match causes the build
  13785. system to exclude a recipe.
  13786. </para>
  13787. <para>
  13788. In general, license flag matching is simple.
  13789. However, understanding some concepts will help you
  13790. correctly and effectively use matching.
  13791. </para>
  13792. <para>
  13793. Before a flag
  13794. defined by a particular recipe is tested against the
  13795. contents of the whitelist, the expanded string
  13796. <filename>_${PN}</filename> is appended to the flag.
  13797. This expansion makes each
  13798. <filename>LICENSE_FLAGS</filename> value recipe-specific.
  13799. After expansion, the string is then matched against the
  13800. whitelist.
  13801. Thus, specifying
  13802. <filename>LICENSE_FLAGS = "commercial"</filename>
  13803. in recipe "foo", for example, results in the string
  13804. <filename>"commercial_foo"</filename>.
  13805. And, to create a match, that string must appear in the
  13806. whitelist.
  13807. </para>
  13808. <para>
  13809. Judicious use of the <filename>LICENSE_FLAGS</filename>
  13810. strings and the contents of the
  13811. <filename>LICENSE_FLAGS_WHITELIST</filename> variable
  13812. allows you a lot of flexibility for including or excluding
  13813. recipes based on licensing.
  13814. For example, you can broaden the matching capabilities by
  13815. using license flags string subsets in the whitelist.
  13816. <note>
  13817. When using a string subset, be sure to use the part of
  13818. the expanded string that precedes the appended
  13819. underscore character (e.g.
  13820. <filename>usethispart_1.3</filename>,
  13821. <filename>usethispart_1.4</filename>, and so forth).
  13822. </note>
  13823. For example, simply specifying the string "commercial" in
  13824. the whitelist matches any expanded
  13825. <filename>LICENSE_FLAGS</filename> definition that starts
  13826. with the string "commercial" such as "commercial_foo" and
  13827. "commercial_bar", which are the strings the build system
  13828. automatically generates for hypothetical recipes named
  13829. "foo" and "bar" assuming those recipes simply specify the
  13830. following:
  13831. <literallayout class='monospaced'>
  13832. LICENSE_FLAGS = "commercial"
  13833. </literallayout>
  13834. Thus, you can choose to exhaustively
  13835. enumerate each license flag in the whitelist and
  13836. allow only specific recipes into the image, or
  13837. you can use a string subset that causes a broader range of
  13838. matches to allow a range of recipes into the image.
  13839. </para>
  13840. <para>
  13841. This scheme works even if the
  13842. <filename>LICENSE_FLAGS</filename> string already
  13843. has <filename>_${PN}</filename> appended.
  13844. For example, the build system turns the license flag
  13845. "commercial_1.2_foo" into "commercial_1.2_foo_foo" and
  13846. would match both the general "commercial" and the specific
  13847. "commercial_1.2_foo" strings found in the whitelist, as
  13848. expected.
  13849. </para>
  13850. <para>
  13851. Here are some other scenarios:
  13852. <itemizedlist>
  13853. <listitem><para>
  13854. You can specify a versioned string in the recipe
  13855. such as "commercial_foo_1.2" in a "foo" recipe.
  13856. The build system expands this string to
  13857. "commercial_foo_1.2_foo".
  13858. Combine this license flag with a whitelist that has
  13859. the string "commercial" and you match the flag
  13860. along with any other flag that starts with the
  13861. string "commercial".
  13862. </para></listitem>
  13863. <listitem><para>
  13864. Under the same circumstances, you can use
  13865. "commercial_foo" in the whitelist and the build
  13866. system not only matches "commercial_foo_1.2" but
  13867. also matches any license flag with the string
  13868. "commercial_foo", regardless of the version.
  13869. </para></listitem>
  13870. <listitem><para>
  13871. You can be very specific and use both the
  13872. package and version parts in the whitelist (e.g.
  13873. "commercial_foo_1.2") to specifically match a
  13874. versioned recipe.
  13875. </para></listitem>
  13876. </itemizedlist>
  13877. </para>
  13878. </section>
  13879. <section id="other-variables-related-to-commercial-licenses">
  13880. <title>Other Variables Related to Commercial Licenses</title>
  13881. <para>
  13882. Other helpful variables related to commercial
  13883. license handling exist and are defined in the
  13884. <filename>poky/meta/conf/distro/include/default-distrovars.inc</filename> file:
  13885. <literallayout class='monospaced'>
  13886. COMMERCIAL_AUDIO_PLUGINS ?= ""
  13887. COMMERCIAL_VIDEO_PLUGINS ?= ""
  13888. </literallayout>
  13889. If you want to enable these components, you can do so by
  13890. making sure you have statements similar to the following
  13891. in your <filename>local.conf</filename> configuration file:
  13892. <literallayout class='monospaced'>
  13893. COMMERCIAL_AUDIO_PLUGINS = "gst-plugins-ugly-mad \
  13894. gst-plugins-ugly-mpegaudioparse"
  13895. COMMERCIAL_VIDEO_PLUGINS = "gst-plugins-ugly-mpeg2dec \
  13896. gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse"
  13897. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly commercial_gst-plugins-bad commercial_qmmp"
  13898. </literallayout>
  13899. Of course, you could also create a matching whitelist
  13900. for those components using the more general "commercial"
  13901. in the whitelist, but that would also enable all the
  13902. other packages with <filename>LICENSE_FLAGS</filename>
  13903. containing "commercial", which you may or may not want:
  13904. <literallayout class='monospaced'>
  13905. LICENSE_FLAGS_WHITELIST = "commercial"
  13906. </literallayout>
  13907. </para>
  13908. <para>
  13909. Specifying audio and video plug-ins as part of the
  13910. <filename>COMMERCIAL_AUDIO_PLUGINS</filename> and
  13911. <filename>COMMERCIAL_VIDEO_PLUGINS</filename> statements
  13912. (along with the enabling
  13913. <filename>LICENSE_FLAGS_WHITELIST</filename>) includes the
  13914. plug-ins or components into built images, thus adding
  13915. support for media formats or components.
  13916. </para>
  13917. </section>
  13918. </section>
  13919. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  13920. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  13921. <para>
  13922. One of the concerns for a development organization using open source
  13923. software is how to maintain compliance with various open source
  13924. licensing during the lifecycle of the product.
  13925. While this section does not provide legal advice or
  13926. comprehensively cover all scenarios, it does
  13927. present methods that you can use to
  13928. assist you in meeting the compliance requirements during a software
  13929. release.
  13930. </para>
  13931. <para>
  13932. With hundreds of different open source licenses that the Yocto
  13933. Project tracks, it is difficult to know the requirements of each
  13934. and every license.
  13935. However, the requirements of the major FLOSS licenses can begin
  13936. to be covered by
  13937. assuming that three main areas of concern exist:
  13938. <itemizedlist>
  13939. <listitem><para>Source code must be provided.</para></listitem>
  13940. <listitem><para>License text for the software must be
  13941. provided.</para></listitem>
  13942. <listitem><para>Compilation scripts and modifications to the
  13943. source code must be provided.
  13944. </para></listitem>
  13945. </itemizedlist>
  13946. There are other requirements beyond the scope of these
  13947. three and the methods described in this section
  13948. (e.g. the mechanism through which source code is distributed).
  13949. </para>
  13950. <para>
  13951. As different organizations have different methods of complying with
  13952. open source licensing, this section is not meant to imply that
  13953. there is only one single way to meet your compliance obligations,
  13954. but rather to describe one method of achieving compliance.
  13955. The remainder of this section describes methods supported to meet the
  13956. previously mentioned three requirements.
  13957. Once you take steps to meet these requirements,
  13958. and prior to releasing images, sources, and the build system,
  13959. you should audit all artifacts to ensure completeness.
  13960. <note>
  13961. The Yocto Project generates a license manifest during
  13962. image creation that is located
  13963. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  13964. to assist with any audits.
  13965. </note>
  13966. </para>
  13967. <section id='providing-the-source-code'>
  13968. <title>Providing the Source Code</title>
  13969. <para>
  13970. Compliance activities should begin before you generate the
  13971. final image.
  13972. The first thing you should look at is the requirement that
  13973. tops the list for most compliance groups - providing
  13974. the source.
  13975. The Yocto Project has a few ways of meeting this
  13976. requirement.
  13977. </para>
  13978. <para>
  13979. One of the easiest ways to meet this requirement is
  13980. to provide the entire
  13981. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  13982. used by the build.
  13983. This method, however, has a few issues.
  13984. The most obvious is the size of the directory since it includes
  13985. all sources used in the build and not just the source used in
  13986. the released image.
  13987. It will include toolchain source, and other artifacts, which
  13988. you would not generally release.
  13989. However, the more serious issue for most companies is accidental
  13990. release of proprietary software.
  13991. The Yocto Project provides an
  13992. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  13993. class to help avoid some of these concerns.
  13994. </para>
  13995. <para>
  13996. Before you employ <filename>DL_DIR</filename> or the
  13997. <filename>archiver</filename> class, you need to decide how
  13998. you choose to provide source.
  13999. The source <filename>archiver</filename> class can generate
  14000. tarballs and SRPMs and can create them with various levels of
  14001. compliance in mind.
  14002. </para>
  14003. <para>
  14004. One way of doing this (but certainly not the only way) is to
  14005. release just the source as a tarball.
  14006. You can do this by adding the following to the
  14007. <filename>local.conf</filename> file found in the
  14008. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  14009. <literallayout class='monospaced'>
  14010. INHERIT += "archiver"
  14011. ARCHIVER_MODE[src] = "original"
  14012. </literallayout>
  14013. During the creation of your image, the source from all
  14014. recipes that deploy packages to the image is placed within
  14015. subdirectories of
  14016. <filename>DEPLOY_DIR/sources</filename> based on the
  14017. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  14018. for each recipe.
  14019. Releasing the entire directory enables you to comply with
  14020. requirements concerning providing the unmodified source.
  14021. It is important to note that the size of the directory can
  14022. get large.
  14023. </para>
  14024. <para>
  14025. A way to help mitigate the size issue is to only release
  14026. tarballs for licenses that require the release of
  14027. source.
  14028. Let us assume you are only concerned with GPL code as
  14029. identified by running the following script:
  14030. <literallayout class='monospaced'>
  14031. # Script to archive a subset of packages matching specific license(s)
  14032. # Source and license files are copied into sub folders of package folder
  14033. # Must be run from build folder
  14034. #!/bin/bash
  14035. src_release_dir="source-release"
  14036. mkdir -p $src_release_dir
  14037. for a in tmp/deploy/sources/*; do
  14038. for d in $a/*; do
  14039. # Get package name from path
  14040. p=`basename $d`
  14041. p=${p%-*}
  14042. p=${p%-*}
  14043. # Only archive GPL packages (update *GPL* regex for your license check)
  14044. numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
  14045. if [ $numfiles -gt 1 ]; then
  14046. echo Archiving $p
  14047. mkdir -p $src_release_dir/$p/source
  14048. cp $d/* $src_release_dir/$p/source 2> /dev/null
  14049. mkdir -p $src_release_dir/$p/license
  14050. cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
  14051. fi
  14052. done
  14053. done
  14054. </literallayout>
  14055. At this point, you could create a tarball from the
  14056. <filename>gpl_source_release</filename> directory and
  14057. provide that to the end user.
  14058. This method would be a step toward achieving compliance
  14059. with section 3a of GPLv2 and with section 6 of GPLv3.
  14060. </para>
  14061. </section>
  14062. <section id='providing-license-text'>
  14063. <title>Providing License Text</title>
  14064. <para>
  14065. One requirement that is often overlooked is inclusion
  14066. of license text.
  14067. This requirement also needs to be dealt with prior to
  14068. generating the final image.
  14069. Some licenses require the license text to accompany
  14070. the binary.
  14071. You can achieve this by adding the following to your
  14072. <filename>local.conf</filename> file:
  14073. <literallayout class='monospaced'>
  14074. COPY_LIC_MANIFEST = "1"
  14075. COPY_LIC_DIRS = "1"
  14076. LICENSE_CREATE_PACKAGE = "1"
  14077. </literallayout>
  14078. Adding these statements to the configuration file ensures
  14079. that the licenses collected during package generation
  14080. are included on your image.
  14081. <note>
  14082. <para>Setting all three variables to "1" results in the
  14083. image having two copies of the same license file.
  14084. One copy resides in
  14085. <filename>/usr/share/common-licenses</filename> and
  14086. the other resides in
  14087. <filename>/usr/share/license</filename>.</para>
  14088. <para>The reason for this behavior is because
  14089. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink>
  14090. and
  14091. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink>
  14092. add a copy of the license when the image is built but do
  14093. not offer a path for adding licenses for newly installed
  14094. packages to an image.
  14095. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink>
  14096. adds a separate package and an upgrade path for adding
  14097. licenses to an image.</para>
  14098. </note>
  14099. </para>
  14100. <para>
  14101. As the source <filename>archiver</filename> class has already
  14102. archived the original
  14103. unmodified source that contains the license files,
  14104. you would have already met the requirements for inclusion
  14105. of the license information with source as defined by the GPL
  14106. and other open source licenses.
  14107. </para>
  14108. </section>
  14109. <section id='providing-compilation-scripts-and-source-code-modifications'>
  14110. <title>Providing Compilation Scripts and Source Code Modifications</title>
  14111. <para>
  14112. At this point, we have addressed all we need to
  14113. prior to generating the image.
  14114. The next two requirements are addressed during the final
  14115. packaging of the release.
  14116. </para>
  14117. <para>
  14118. By releasing the version of the OpenEmbedded build system
  14119. and the layers used during the build, you will be providing both
  14120. compilation scripts and the source code modifications in one
  14121. step.
  14122. </para>
  14123. <para>
  14124. If the deployment team has a
  14125. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  14126. and a distro layer, and those those layers are used to patch,
  14127. compile, package, or modify (in any way) any open source
  14128. software included in your released images, you
  14129. might be required to release those layers under section 3 of
  14130. GPLv2 or section 1 of GPLv3.
  14131. One way of doing that is with a clean
  14132. checkout of the version of the Yocto Project and layers used
  14133. during your build.
  14134. Here is an example:
  14135. <literallayout class='monospaced'>
  14136. # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo
  14137. $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky
  14138. $ cd poky
  14139. # We built using the release_branch for our layers
  14140. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  14141. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  14142. # clean up the .git repos
  14143. $ find . -name ".git" -type d -exec rm -rf {} \;
  14144. </literallayout>
  14145. One thing a development organization might want to consider
  14146. for end-user convenience is to modify
  14147. <filename>meta-poky/conf/bblayers.conf.sample</filename> to
  14148. ensure that when the end user utilizes the released build
  14149. system to build an image, the development organization's
  14150. layers are included in the <filename>bblayers.conf</filename>
  14151. file automatically:
  14152. <literallayout class='monospaced'>
  14153. # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
  14154. # changes incompatibly
  14155. POKY_BBLAYERS_CONF_VERSION = "2"
  14156. BBPATH = "${TOPDIR}"
  14157. BBFILES ?= ""
  14158. BBLAYERS ?= " \
  14159. ##OEROOT##/meta \
  14160. ##OEROOT##/meta-poky \
  14161. ##OEROOT##/meta-yocto-bsp \
  14162. ##OEROOT##/meta-mylayer \
  14163. "
  14164. </literallayout>
  14165. Creating and providing an archive of the
  14166. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  14167. layers (recipes, configuration files, and so forth)
  14168. enables you to meet your
  14169. requirements to include the scripts to control compilation
  14170. as well as any modifications to the original source.
  14171. </para>
  14172. </section>
  14173. </section>
  14174. <section id='copying-licenses-that-do-not-exist'>
  14175. <title>Copying Licenses that Do Not Exist</title>
  14176. <para>
  14177. Some packages, such as the linux-firmware package, have many
  14178. licenses that are not in any way common.
  14179. You can avoid adding a lot of these types of common license
  14180. files, which are only applicable to a specific package, by using
  14181. the
  14182. <ulink url='&YOCTO_DOCS_REF_URL;#var-NO_GENERIC_LICENSE'><filename>NO_GENERIC_LICENSE</filename></ulink>
  14183. variable.
  14184. Using this variable also avoids QA errors when you use a
  14185. non-common, non-CLOSED license in a recipe.
  14186. </para>
  14187. <para>
  14188. The following is an example that uses the
  14189. <filename>LICENSE.Abilis.txt</filename>
  14190. file as the license from the fetched source:
  14191. <literallayout class='monospaced'>
  14192. NO_GENERIC_LICENSE[Firmware-Abilis] = "LICENSE.Abilis.txt"
  14193. </literallayout>
  14194. </para>
  14195. </section>
  14196. </section>
  14197. <section id='using-the-error-reporting-tool'>
  14198. <title>Using the Error Reporting Tool</title>
  14199. <para>
  14200. The error reporting tool allows you to
  14201. submit errors encountered during builds to a central database.
  14202. Outside of the build environment, you can use a web interface to
  14203. browse errors, view statistics, and query for errors.
  14204. The tool works using a client-server system where the client
  14205. portion is integrated with the installed Yocto Project
  14206. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  14207. (e.g. <filename>poky</filename>).
  14208. The server receives the information collected and saves it in a
  14209. database.
  14210. </para>
  14211. <para>
  14212. A live instance of the error reporting server exists at
  14213. <ulink url='http://errors.yoctoproject.org'></ulink>.
  14214. This server exists so that when you want to get help with
  14215. build failures, you can submit all of the information on the
  14216. failure easily and then point to the URL in your bug report
  14217. or send an email to the mailing list.
  14218. <note>
  14219. If you send error reports to this server, the reports become
  14220. publicly visible.
  14221. </note>
  14222. </para>
  14223. <section id='enabling-and-using-the-tool'>
  14224. <title>Enabling and Using the Tool</title>
  14225. <para>
  14226. By default, the error reporting tool is disabled.
  14227. You can enable it by inheriting the
  14228. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  14229. class by adding the following statement to the end of
  14230. your <filename>local.conf</filename> file in your
  14231. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  14232. <literallayout class='monospaced'>
  14233. INHERIT += "report-error"
  14234. </literallayout>
  14235. </para>
  14236. <para>
  14237. By default, the error reporting feature stores information in
  14238. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  14239. However, you can specify a directory to use by adding the following
  14240. to your <filename>local.conf</filename> file:
  14241. <literallayout class='monospaced'>
  14242. ERR_REPORT_DIR = "path"
  14243. </literallayout>
  14244. Enabling error reporting causes the build process to collect
  14245. the errors and store them in a file as previously described.
  14246. When the build system encounters an error, it includes a
  14247. command as part of the console output.
  14248. You can run the command to send the error file to the server.
  14249. For example, the following command sends the errors to an
  14250. upstream server:
  14251. <literallayout class='monospaced'>
  14252. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  14253. </literallayout>
  14254. In the previous example, the errors are sent to a public
  14255. database available at
  14256. <ulink url='http://errors.yoctoproject.org'></ulink>, which is
  14257. used by the entire community.
  14258. If you specify a particular server, you can send the errors
  14259. to a different database.
  14260. Use the following command for more information on available
  14261. options:
  14262. <literallayout class='monospaced'>
  14263. $ send-error-report --help
  14264. </literallayout>
  14265. </para>
  14266. <para>
  14267. When sending the error file, you are prompted to review the
  14268. data being sent as well as to provide a name and optional
  14269. email address.
  14270. Once you satisfy these prompts, the command returns a link
  14271. from the server that corresponds to your entry in the database.
  14272. For example, here is a typical link:
  14273. <literallayout class='monospaced'>
  14274. http://errors.yoctoproject.org/Errors/Details/9522/
  14275. </literallayout>
  14276. Following the link takes you to a web interface where you can
  14277. browse, query the errors, and view statistics.
  14278. </para>
  14279. </section>
  14280. <section id='disabling-the-tool'>
  14281. <title>Disabling the Tool</title>
  14282. <para>
  14283. To disable the error reporting feature, simply remove or comment
  14284. out the following statement from the end of your
  14285. <filename>local.conf</filename> file in your
  14286. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  14287. <literallayout class='monospaced'>
  14288. INHERIT += "report-error"
  14289. </literallayout>
  14290. </para>
  14291. </section>
  14292. <section id='setting-up-your-own-error-reporting-server'>
  14293. <title>Setting Up Your Own Error Reporting Server</title>
  14294. <para>
  14295. If you want to set up your own error reporting server, you
  14296. can obtain the code from the Git repository at
  14297. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  14298. Instructions on how to set it up are in the README document.
  14299. </para>
  14300. </section>
  14301. </section>
  14302. <section id="dev-using-wayland-and-weston">
  14303. <title>Using Wayland and Weston</title>
  14304. <para>
  14305. <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)'>Wayland</ulink>
  14306. is a computer display server protocol that
  14307. provides a method for compositing window managers to communicate
  14308. directly with applications and video hardware and expects them to
  14309. communicate with input hardware using other libraries.
  14310. Using Wayland with supporting targets can result in better control
  14311. over graphics frame rendering than an application might otherwise
  14312. achieve.
  14313. </para>
  14314. <para>
  14315. The Yocto Project provides the Wayland protocol libraries and the
  14316. reference
  14317. <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston'>Weston</ulink>
  14318. compositor as part of its release.
  14319. You can find the integrated packages in the
  14320. <filename>meta</filename> layer of the
  14321. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  14322. Specifically, you can find the recipes that build both Wayland
  14323. and Weston at <filename>meta/recipes-graphics/wayland</filename>.
  14324. </para>
  14325. <para>
  14326. You can build both the Wayland and Weston packages for use only
  14327. with targets that accept the
  14328. <ulink url='https://en.wikipedia.org/wiki/Mesa_(computer_graphics)'>Mesa 3D and Direct Rendering Infrastructure</ulink>,
  14329. which is also known as Mesa DRI.
  14330. This implies that you cannot build and use the packages if your
  14331. target uses, for example, the
  14332. <trademark class='registered'>Intel</trademark> Embedded Media
  14333. and Graphics Driver
  14334. (<trademark class='registered'>Intel</trademark> EMGD) that
  14335. overrides Mesa DRI.
  14336. <note>
  14337. Due to lack of EGL support, Weston 1.0.3 will not run
  14338. directly on the emulated QEMU hardware.
  14339. However, this version of Weston will run under X emulation
  14340. without issues.
  14341. </note>
  14342. </para>
  14343. <para>
  14344. This section describes what you need to do to implement Wayland and
  14345. use the Weston compositor when building an image for a supporting
  14346. target.
  14347. </para>
  14348. <section id="enabling-wayland-in-an-image">
  14349. <title>Enabling Wayland in an Image</title>
  14350. <para>
  14351. To enable Wayland, you need to enable it to be built and enable
  14352. it to be included (installed) in the image.
  14353. </para>
  14354. <section id="enable-building">
  14355. <title>Building</title>
  14356. <para>
  14357. To cause Mesa to build the <filename>wayland-egl</filename>
  14358. platform and Weston to build Wayland with Kernel Mode
  14359. Setting
  14360. (<ulink url='https://wiki.archlinux.org/index.php/Kernel_Mode_Setting'>KMS</ulink>)
  14361. support, include the "wayland" flag in the
  14362. <ulink url="&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES"><filename>DISTRO_FEATURES</filename></ulink>
  14363. statement in your <filename>local.conf</filename> file:
  14364. <literallayout class='monospaced'>
  14365. DISTRO_FEATURES_append = " wayland"
  14366. </literallayout>
  14367. <note>
  14368. If X11 has been enabled elsewhere, Weston will build
  14369. Wayland with X11 support
  14370. </note>
  14371. </para>
  14372. </section>
  14373. <section id="enable-installation-in-an-image">
  14374. <title>Installing</title>
  14375. <para>
  14376. To install the Wayland feature into an image, you must
  14377. include the following
  14378. <ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'><filename>CORE_IMAGE_EXTRA_INSTALL</filename></ulink>
  14379. statement in your <filename>local.conf</filename> file:
  14380. <literallayout class='monospaced'>
  14381. CORE_IMAGE_EXTRA_INSTALL += "wayland weston"
  14382. </literallayout>
  14383. </para>
  14384. </section>
  14385. </section>
  14386. <section id="running-weston">
  14387. <title>Running Weston</title>
  14388. <para>
  14389. To run Weston inside X11, enabling it as described earlier and
  14390. building a Sato image is sufficient.
  14391. If you are running your image under Sato, a Weston Launcher
  14392. appears in the "Utility" category.
  14393. </para>
  14394. <para>
  14395. Alternatively, you can run Weston through the command-line
  14396. interpretor (CLI), which is better suited for development work.
  14397. To run Weston under the CLI, you need to do the following after
  14398. your image is built:
  14399. <orderedlist>
  14400. <listitem><para>
  14401. Run these commands to export
  14402. <filename>XDG_RUNTIME_DIR</filename>:
  14403. <literallayout class='monospaced'>
  14404. mkdir -p /tmp/$USER-weston
  14405. chmod 0700 /tmp/$USER-weston
  14406. export XDG_RUNTIME_DIR=/tmp/$USER-weston
  14407. </literallayout>
  14408. </para></listitem>
  14409. <listitem><para>
  14410. Launch Weston in the shell:
  14411. <literallayout class='monospaced'>
  14412. weston
  14413. </literallayout></para></listitem>
  14414. </orderedlist>
  14415. </para>
  14416. </section>
  14417. </section>
  14418. </chapter>
  14419. <!--
  14420. vim: expandtab tw=80 ts=4
  14421. -->