dev-manual-common-tasks.xml 813 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455
  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 how
  182. up-to-date your particular layer is.
  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, use the following
  3014. structure in the post-installation script:
  3015. <literallayout class='monospaced'>
  3016. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  3017. if [ x"$D" = "x" ]; then
  3018. # Actions to carry out on the device go here
  3019. else
  3020. exit 1
  3021. fi
  3022. }
  3023. </literallayout>
  3024. </para>
  3025. <para>
  3026. The previous example delays execution until the image boots
  3027. again because the environment variable <filename>D</filename>
  3028. points to the directory containing the image when
  3029. the root filesystem is created at build time but is unset
  3030. when executed on the first boot.
  3031. </para>
  3032. <para>
  3033. If you have recipes that use <filename>pkg_postinst</filename>
  3034. scripts and they require the use of non-standard native
  3035. tools that have dependencies during rootfs construction, you
  3036. need to use the
  3037. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink>
  3038. variable in your recipe to list these tools.
  3039. If you do not use this variable, the tools might be missing and
  3040. execution of the post-installation script is deferred until
  3041. first boot.
  3042. Deferring the script to first boot is undesirable and for
  3043. read-only rootfs impossible.
  3044. </para>
  3045. <note>
  3046. Equivalent support for pre-install, pre-uninstall, and
  3047. post-uninstall scripts exist by way of
  3048. <filename>pkg_preinst</filename>,
  3049. <filename>pkg_prerm</filename>, and
  3050. <filename>pkg_postrm</filename>, respectively.
  3051. These scrips work in exactly the same way as does
  3052. <filename>pkg_postinst</filename> with the exception that they
  3053. run at different times.
  3054. Also, because of when they run, they are not applicable to
  3055. being run at image creation time like
  3056. <filename>pkg_postinst</filename>.
  3057. </note>
  3058. </section>
  3059. <section id='new-recipe-testing'>
  3060. <title>Testing</title>
  3061. <para>
  3062. The final step for completing your recipe is to be sure that
  3063. the software you built runs correctly.
  3064. To accomplish runtime testing, add the build's output
  3065. packages to your image and test them on the target.
  3066. </para>
  3067. <para>
  3068. For information on how to customize your image by adding
  3069. specific packages, see the
  3070. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  3071. section.
  3072. </para>
  3073. </section>
  3074. <section id='new-recipe-testing-examples'>
  3075. <title>Examples</title>
  3076. <para>
  3077. To help summarize how to write a recipe, this section provides
  3078. some examples given various scenarios:
  3079. <itemizedlist>
  3080. <listitem><para>Recipes that use local files</para></listitem>
  3081. <listitem><para>Using an Autotooled package</para></listitem>
  3082. <listitem><para>Using a Makefile-based package</para></listitem>
  3083. <listitem><para>Splitting an application into multiple packages</para></listitem>
  3084. <listitem><para>Adding binaries to an image</para></listitem>
  3085. </itemizedlist>
  3086. </para>
  3087. <section id='new-recipe-single-c-file-package-hello-world'>
  3088. <title>Single .c File Package (Hello World!)</title>
  3089. <para>
  3090. Building an application from a single file that is stored
  3091. locally (e.g. under <filename>files</filename>) requires
  3092. a recipe that has the file listed in the
  3093. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  3094. variable.
  3095. Additionally, you need to manually write the
  3096. <filename>do_compile</filename> and
  3097. <filename>do_install</filename> tasks.
  3098. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3099. variable defines the directory containing the source code,
  3100. which is set to
  3101. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  3102. in this case - the directory BitBake uses for the build.
  3103. <literallayout class='monospaced'>
  3104. SUMMARY = "Simple helloworld application"
  3105. SECTION = "examples"
  3106. LICENSE = "MIT"
  3107. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  3108. SRC_URI = "file://helloworld.c"
  3109. S = "${WORKDIR}"
  3110. do_compile() {
  3111. ${CC} helloworld.c -o helloworld
  3112. }
  3113. do_install() {
  3114. install -d ${D}${bindir}
  3115. install -m 0755 helloworld ${D}${bindir}
  3116. }
  3117. </literallayout>
  3118. </para>
  3119. <para>
  3120. By default, the <filename>helloworld</filename>,
  3121. <filename>helloworld-dbg</filename>, and
  3122. <filename>helloworld-dev</filename> packages are built.
  3123. For information on how to customize the packaging process,
  3124. see the
  3125. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  3126. section.
  3127. </para>
  3128. </section>
  3129. <section id='new-recipe-autotooled-package'>
  3130. <title>Autotooled Package</title>
  3131. <para>
  3132. Applications that use Autotools such as <filename>autoconf</filename> and
  3133. <filename>automake</filename> require a recipe that has a source archive listed in
  3134. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  3135. also inherit the
  3136. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  3137. class, which contains the definitions of all the steps
  3138. needed to build an Autotool-based application.
  3139. The result of the build is automatically packaged.
  3140. And, if the application uses NLS for localization, packages with local information are
  3141. generated (one package per language).
  3142. Following is one example: (<filename>hello_2.3.bb</filename>)
  3143. <literallayout class='monospaced'>
  3144. SUMMARY = "GNU Helloworld application"
  3145. SECTION = "examples"
  3146. LICENSE = "GPLv2+"
  3147. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  3148. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  3149. inherit autotools gettext
  3150. </literallayout>
  3151. </para>
  3152. <para>
  3153. The variable
  3154. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  3155. is used to track source license changes as described in the
  3156. "<link linkend='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>"
  3157. section in the Yocto Project Overview and Concepts Manual.
  3158. You can quickly create Autotool-based recipes in a manner
  3159. similar to the previous example.
  3160. </para>
  3161. </section>
  3162. <section id='new-recipe-makefile-based-package'>
  3163. <title>Makefile-Based Package</title>
  3164. <para>
  3165. Applications that use GNU <filename>make</filename> also require a recipe that has
  3166. the source archive listed in
  3167. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3168. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  3169. starts the <filename>make</filename> command to compile the application.
  3170. If you need additional <filename>make</filename> options, you should store them in the
  3171. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
  3172. or
  3173. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  3174. variables.
  3175. BitBake passes these options into the GNU <filename>make</filename> invocation.
  3176. Note that a <filename>do_install</filename> task is still required.
  3177. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  3178. </para>
  3179. <para>
  3180. Some applications might require extra parameters to be passed to the compiler.
  3181. For example, the application might need an additional header path.
  3182. You can accomplish this by adding to the
  3183. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  3184. The following example shows this:
  3185. <literallayout class='monospaced'>
  3186. CFLAGS_prepend = "-I ${S}/include "
  3187. </literallayout>
  3188. </para>
  3189. <para>
  3190. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  3191. <literallayout class='monospaced'>
  3192. SUMMARY = "Tools for managing memory technology devices"
  3193. SECTION = "base"
  3194. DEPENDS = "zlib lzo e2fsprogs util-linux"
  3195. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  3196. LICENSE = "GPLv2+"
  3197. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  3198. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  3199. # Use the latest version at 26 Oct, 2013
  3200. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  3201. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  3202. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  3203. "
  3204. PV = "1.5.1+git${SRCPV}"
  3205. S = "${WORKDIR}/git"
  3206. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  3207. do_install () {
  3208. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  3209. }
  3210. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  3211. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  3212. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  3213. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  3214. PARALLEL_MAKE = ""
  3215. BBCLASSEXTEND = "native"
  3216. </literallayout>
  3217. </para>
  3218. </section>
  3219. <section id='splitting-an-application-into-multiple-packages'>
  3220. <title>Splitting an Application into Multiple Packages</title>
  3221. <para>
  3222. You can use the variables
  3223. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  3224. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  3225. to split an application into multiple packages.
  3226. </para>
  3227. <para>
  3228. Following is an example that uses the <filename>libxpm</filename> recipe.
  3229. By default, this recipe generates a single package that contains the library along
  3230. with a few binaries.
  3231. You can modify the recipe to split the binaries into separate packages:
  3232. <literallayout class='monospaced'>
  3233. require xorg-lib-common.inc
  3234. SUMMARY = "Xpm: X Pixmap extension library"
  3235. LICENSE = "BSD"
  3236. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  3237. DEPENDS += "libxext libsm libxt"
  3238. PE = "1"
  3239. XORG_PN = "libXpm"
  3240. PACKAGES =+ "sxpm cxpm"
  3241. FILES_cxpm = "${bindir}/cxpm"
  3242. FILES_sxpm = "${bindir}/sxpm"
  3243. </literallayout>
  3244. </para>
  3245. <para>
  3246. In the previous example, we want to ship the <filename>sxpm</filename>
  3247. and <filename>cxpm</filename> binaries in separate packages.
  3248. Since <filename>bindir</filename> would be packaged into the main
  3249. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  3250. package by default, we prepend the <filename>PACKAGES</filename>
  3251. variable so additional package names are added to the start of list.
  3252. This results in the extra <filename>FILES_*</filename>
  3253. variables then containing information that define which files and
  3254. directories go into which packages.
  3255. Files included by earlier packages are skipped by latter packages.
  3256. Thus, the main <filename>PN</filename> package
  3257. does not include the above listed files.
  3258. </para>
  3259. </section>
  3260. <section id='packaging-externally-produced-binaries'>
  3261. <title>Packaging Externally Produced Binaries</title>
  3262. <para>
  3263. Sometimes, you need to add pre-compiled binaries to an
  3264. image.
  3265. For example, suppose that binaries for proprietary code
  3266. exist, which are created by a particular division of a
  3267. company.
  3268. Your part of the company needs to use those binaries as
  3269. part of an image that you are building using the
  3270. OpenEmbedded build system.
  3271. Since you only have the binaries and not the source code,
  3272. you cannot use a typical recipe that expects to fetch the
  3273. source specified in
  3274. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  3275. and then compile it.
  3276. </para>
  3277. <para>
  3278. One method is to package the binaries and then install them
  3279. as part of the image.
  3280. Generally, it is not a good idea to package binaries
  3281. since, among other things, it can hinder the ability to
  3282. reproduce builds and could lead to compatibility problems
  3283. with ABI in the future.
  3284. However, sometimes you have no choice.
  3285. </para>
  3286. <para>
  3287. The easiest solution is to create a recipe that uses
  3288. the
  3289. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  3290. class and to be sure that you are using default locations
  3291. for build artifacts.
  3292. In most cases, the <filename>bin_package</filename> class
  3293. handles "skipping" the configure and compile steps as well
  3294. as sets things up to grab packages from the appropriate
  3295. area.
  3296. In particular, this class sets <filename>noexec</filename>
  3297. on both the
  3298. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3299. and
  3300. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3301. tasks, sets
  3302. <filename>FILES_${PN}</filename> to "/" so that it picks
  3303. up all files, and sets up a
  3304. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3305. task, which effectively copies all files from
  3306. <filename>${S}</filename> to <filename>${D}</filename>.
  3307. The <filename>bin_package</filename> class works well when
  3308. the files extracted into <filename>${S}</filename> are
  3309. already laid out in the way they should be laid out
  3310. on the target.
  3311. For more information on these variables, see the
  3312. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  3313. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  3314. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  3315. and
  3316. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  3317. variables in the Yocto Project Reference Manual's variable
  3318. glossary.
  3319. <note><title>Notes</title>
  3320. <itemizedlist>
  3321. <listitem><para>
  3322. Using
  3323. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3324. is a good idea even for components distributed
  3325. in binary form, and is often necessary for
  3326. shared libraries.
  3327. For a shared library, listing the library
  3328. dependencies in
  3329. <filename>DEPENDS</filename> makes sure that
  3330. the libraries are available in the staging
  3331. sysroot when other recipes link against the
  3332. library, which might be necessary for
  3333. successful linking.
  3334. </para></listitem>
  3335. <listitem><para>
  3336. Using <filename>DEPENDS</filename> also
  3337. allows runtime dependencies between packages
  3338. to be added automatically.
  3339. See the
  3340. "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  3341. section in the Yocto Project Overview and
  3342. Concepts Manual for more information.
  3343. </para></listitem>
  3344. </itemizedlist>
  3345. </note>
  3346. </para>
  3347. <para>
  3348. If you cannot use the <filename>bin_package</filename>
  3349. class, you need to be sure you are doing the following:
  3350. <itemizedlist>
  3351. <listitem><para>
  3352. Create a recipe where the
  3353. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3354. and
  3355. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3356. tasks do nothing:
  3357. It is usually sufficient to just not define these
  3358. tasks in the recipe, because the default
  3359. implementations do nothing unless a Makefile is
  3360. found in
  3361. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>.
  3362. </para>
  3363. <para>If
  3364. <filename>${S}</filename> might contain a Makefile,
  3365. or if you inherit some class that replaces
  3366. <filename>do_configure</filename> and
  3367. <filename>do_compile</filename> with custom
  3368. versions, then you can use the
  3369. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename>
  3370. flag to turn the tasks into no-ops, as follows:
  3371. <literallayout class='monospaced'>
  3372. do_configure[noexec] = "1"
  3373. do_compile[noexec] = "1"
  3374. </literallayout>
  3375. Unlike
  3376. <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>,
  3377. using the flag preserves the dependency chain from
  3378. the
  3379. <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>,
  3380. and
  3381. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3382. tasks to the
  3383. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3384. task.
  3385. </para></listitem>
  3386. <listitem><para>Make sure your
  3387. <filename>do_install</filename> task installs the
  3388. binaries appropriately.
  3389. </para></listitem>
  3390. <listitem><para>Ensure that you set up
  3391. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3392. (usually
  3393. <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>)
  3394. to point to the files you have installed, which of
  3395. course depends on where you have installed them
  3396. and whether those files are in different locations
  3397. than the defaults.
  3398. </para></listitem>
  3399. </itemizedlist>
  3400. </para>
  3401. </section>
  3402. </section>
  3403. <section id="following-recipe-style-guidelines">
  3404. <title>Following Recipe Style Guidelines</title>
  3405. <para>
  3406. When writing recipes, it is good to conform to existing
  3407. style guidelines.
  3408. The
  3409. <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink>
  3410. wiki page provides rough guidelines for preferred recipe style.
  3411. </para>
  3412. <para>
  3413. It is common for existing recipes to deviate a bit from this
  3414. style.
  3415. However, aiming for at least a consistent style is a good idea.
  3416. Some practices, such as omitting spaces around
  3417. <filename>=</filename> operators in assignments or ordering
  3418. recipe components in an erratic way, are widely seen as poor
  3419. style.
  3420. </para>
  3421. </section>
  3422. <section id='recipe-syntax'>
  3423. <title>Recipe Syntax</title>
  3424. <para>
  3425. Understanding recipe file syntax is important for writing
  3426. recipes.
  3427. The following list overviews the basic items that make up a
  3428. BitBake recipe file.
  3429. For more complete BitBake syntax descriptions, see the
  3430. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  3431. chapter of the BitBake User Manual.
  3432. <itemizedlist>
  3433. <listitem><para>
  3434. <emphasis>Variable Assignments and Manipulations:</emphasis>
  3435. Variable assignments allow a value to be assigned to a
  3436. variable.
  3437. The assignment can be static text or might include
  3438. the contents of other variables.
  3439. In addition to the assignment, appending and prepending
  3440. operations are also supported.</para>
  3441. <para>The following example shows some of the ways
  3442. you can use variables in recipes:
  3443. <literallayout class='monospaced'>
  3444. S = "${WORKDIR}/postfix-${PV}"
  3445. CFLAGS += "-DNO_ASM"
  3446. SRC_URI_append = " file://fixup.patch"
  3447. </literallayout>
  3448. </para></listitem>
  3449. <listitem><para>
  3450. <emphasis>Functions:</emphasis>
  3451. Functions provide a series of actions to be performed.
  3452. You usually use functions to override the default
  3453. implementation of a task function or to complement
  3454. a default function (i.e. append or prepend to an
  3455. existing function).
  3456. Standard functions use <filename>sh</filename> shell
  3457. syntax, although access to OpenEmbedded variables and
  3458. internal methods are also available.</para>
  3459. <para>The following is an example function from the
  3460. <filename>sed</filename> recipe:
  3461. <literallayout class='monospaced'>
  3462. do_install () {
  3463. autotools_do_install
  3464. install -d ${D}${base_bindir}
  3465. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  3466. rmdir ${D}${bindir}/
  3467. }
  3468. </literallayout>
  3469. It is also possible to implement new functions that
  3470. are called between existing tasks as long as the
  3471. new functions are not replacing or complementing the
  3472. default functions.
  3473. You can implement functions in Python
  3474. instead of shell.
  3475. Both of these options are not seen in the majority of
  3476. recipes.
  3477. </para></listitem>
  3478. <listitem><para><emphasis>Keywords:</emphasis>
  3479. BitBake recipes use only a few keywords.
  3480. You use keywords to include common
  3481. functions (<filename>inherit</filename>), load parts
  3482. of a recipe from other files
  3483. (<filename>include</filename> and
  3484. <filename>require</filename>) and export variables
  3485. to the environment (<filename>export</filename>).
  3486. </para>
  3487. <para>The following example shows the use of some of
  3488. these keywords:
  3489. <literallayout class='monospaced'>
  3490. export POSTCONF = "${STAGING_BINDIR}/postconf"
  3491. inherit autoconf
  3492. require otherfile.inc
  3493. </literallayout>
  3494. </para></listitem>
  3495. <listitem><para>
  3496. <emphasis>Comments (#):</emphasis>
  3497. Any lines that begin with the hash character
  3498. (<filename>#</filename>) are treated as comment lines
  3499. and are ignored:
  3500. <literallayout class='monospaced'>
  3501. # This is a comment
  3502. </literallayout>
  3503. </para></listitem>
  3504. </itemizedlist>
  3505. </para>
  3506. <para>
  3507. This next list summarizes the most important and most commonly
  3508. used parts of the recipe syntax.
  3509. For more information on these parts of the syntax, you can
  3510. reference the
  3511. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>
  3512. chapter in the BitBake User Manual.
  3513. <itemizedlist>
  3514. <listitem><para>
  3515. <emphasis>Line Continuation (\):</emphasis>
  3516. Use the backward slash (<filename>\</filename>)
  3517. character to split a statement over multiple lines.
  3518. Place the slash character at the end of the line that
  3519. is to be continued on the next line:
  3520. <literallayout class='monospaced'>
  3521. VAR = "A really long \
  3522. line"
  3523. </literallayout>
  3524. <note>
  3525. You cannot have any characters including spaces
  3526. or tabs after the slash character.
  3527. </note>
  3528. </para></listitem>
  3529. <listitem><para>
  3530. <emphasis>Using Variables (${<replaceable>VARNAME</replaceable>}):</emphasis>
  3531. Use the <filename>${<replaceable>VARNAME</replaceable>}</filename>
  3532. syntax to access the contents of a variable:
  3533. <literallayout class='monospaced'>
  3534. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  3535. </literallayout>
  3536. <note>
  3537. It is important to understand that the value of a
  3538. variable expressed in this form does not get
  3539. substituted automatically.
  3540. The expansion of these expressions happens
  3541. on-demand later (e.g. usually when a function that
  3542. makes reference to the variable executes).
  3543. This behavior ensures that the values are most
  3544. appropriate for the context in which they are
  3545. finally used.
  3546. On the rare occasion that you do need the variable
  3547. expression to be expanded immediately, you can use
  3548. the <filename>:=</filename> operator instead of
  3549. <filename>=</filename> when you make the
  3550. assignment, but this is not generally needed.
  3551. </note>
  3552. </para></listitem>
  3553. <listitem><para>
  3554. <emphasis>Quote All Assignments ("<replaceable>value</replaceable>"):</emphasis>
  3555. Use double quotes around values in all variable
  3556. assignments (e.g.
  3557. <filename>"<replaceable>value</replaceable>"</filename>).
  3558. Following is an example:
  3559. <literallayout class='monospaced'>
  3560. VAR1 = "${OTHERVAR}"
  3561. VAR2 = "The version is ${PV}"
  3562. </literallayout>
  3563. </para></listitem>
  3564. <listitem><para>
  3565. <emphasis>Conditional Assignment (?=):</emphasis>
  3566. Conditional assignment is used to assign a
  3567. value to a variable, but only when the variable is
  3568. currently unset.
  3569. Use the question mark followed by the equal sign
  3570. (<filename>?=</filename>) to make a "soft" assignment
  3571. used for conditional assignment.
  3572. Typically, "soft" assignments are used in the
  3573. <filename>local.conf</filename> file for variables
  3574. that are allowed to come through from the external
  3575. environment.
  3576. </para>
  3577. <para>Here is an example where
  3578. <filename>VAR1</filename> is set to "New value" if
  3579. it is currently empty.
  3580. However, if <filename>VAR1</filename> has already been
  3581. set, it remains unchanged:
  3582. <literallayout class='monospaced'>
  3583. VAR1 ?= "New value"
  3584. </literallayout>
  3585. In this next example, <filename>VAR1</filename>
  3586. is left with the value "Original value":
  3587. <literallayout class='monospaced'>
  3588. VAR1 = "Original value"
  3589. VAR1 ?= "New value"
  3590. </literallayout>
  3591. </para></listitem>
  3592. <listitem><para>
  3593. <emphasis>Appending (+=):</emphasis>
  3594. Use the plus character followed by the equals sign
  3595. (<filename>+=</filename>) to append values to existing
  3596. variables.
  3597. <note>
  3598. This operator adds a space between the existing
  3599. content of the variable and the new content.
  3600. </note></para>
  3601. <para>Here is an example:
  3602. <literallayout class='monospaced'>
  3603. SRC_URI += "file://fix-makefile.patch"
  3604. </literallayout>
  3605. </para></listitem>
  3606. <listitem><para>
  3607. <emphasis>Prepending (=+):</emphasis>
  3608. Use the equals sign followed by the plus character
  3609. (<filename>=+</filename>) to prepend values to existing
  3610. variables.
  3611. <note>
  3612. This operator adds a space between the new content
  3613. and the existing content of the variable.
  3614. </note></para>
  3615. <para>Here is an example:
  3616. <literallayout class='monospaced'>
  3617. VAR =+ "Starts"
  3618. </literallayout>
  3619. </para></listitem>
  3620. <listitem><para>
  3621. <emphasis>Appending (_append):</emphasis>
  3622. Use the <filename>_append</filename> operator to
  3623. append values to existing variables.
  3624. This operator does not add any additional space.
  3625. Also, the operator is applied after all the
  3626. <filename>+=</filename>, and
  3627. <filename>=+</filename> operators have been applied and
  3628. after all <filename>=</filename> assignments have
  3629. occurred.
  3630. </para>
  3631. <para>The following example shows the space being
  3632. explicitly added to the start to ensure the appended
  3633. value is not merged with the existing value:
  3634. <literallayout class='monospaced'>
  3635. SRC_URI_append = " file://fix-makefile.patch"
  3636. </literallayout>
  3637. You can also use the <filename>_append</filename>
  3638. operator with overrides, which results in the actions
  3639. only being performed for the specified target or
  3640. machine:
  3641. <literallayout class='monospaced'>
  3642. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  3643. </literallayout>
  3644. </para></listitem>
  3645. <listitem><para>
  3646. <emphasis>Prepending (_prepend):</emphasis>
  3647. Use the <filename>_prepend</filename> operator to
  3648. prepend values to existing variables.
  3649. This operator does not add any additional space.
  3650. Also, the operator is applied after all the
  3651. <filename>+=</filename>, and
  3652. <filename>=+</filename> operators have been applied and
  3653. after all <filename>=</filename> assignments have
  3654. occurred.
  3655. </para>
  3656. <para>The following example shows the space being
  3657. explicitly added to the end to ensure the prepended
  3658. value is not merged with the existing value:
  3659. <literallayout class='monospaced'>
  3660. CFLAGS_prepend = "-I${S}/myincludes "
  3661. </literallayout>
  3662. You can also use the <filename>_prepend</filename>
  3663. operator with overrides, which results in the actions
  3664. only being performed for the specified target or
  3665. machine:
  3666. <literallayout class='monospaced'>
  3667. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  3668. </literallayout>
  3669. </para></listitem>
  3670. <listitem><para>
  3671. <emphasis>Overrides:</emphasis>
  3672. You can use overrides to set a value conditionally,
  3673. typically based on how the recipe is being built.
  3674. For example, to set the
  3675. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  3676. variable's value to "standard/base" for any target
  3677. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  3678. except for qemuarm where it should be set to
  3679. "standard/arm-versatile-926ejs", you would do the
  3680. following:
  3681. <literallayout class='monospaced'>
  3682. KBRANCH = "standard/base"
  3683. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  3684. </literallayout>
  3685. Overrides are also used to separate alternate values
  3686. of a variable in other situations.
  3687. For example, when setting variables such as
  3688. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3689. and
  3690. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  3691. that are specific to individual packages produced by
  3692. a recipe, you should always use an override that
  3693. specifies the name of the package.
  3694. </para></listitem>
  3695. <listitem><para>
  3696. <emphasis>Indentation:</emphasis>
  3697. Use spaces for indentation rather than than tabs.
  3698. For shell functions, both currently work.
  3699. However, it is a policy decision of the Yocto Project
  3700. to use tabs in shell functions.
  3701. Realize that some layers have a policy to use spaces
  3702. for all indentation.
  3703. </para></listitem>
  3704. <listitem><para>
  3705. <emphasis>Using Python for Complex Operations:</emphasis>
  3706. For more advanced processing, it is possible to use
  3707. Python code during variable assignments (e.g.
  3708. search and replacement on a variable).</para>
  3709. <para>You indicate Python code using the
  3710. <filename>${@<replaceable>python_code</replaceable>}</filename>
  3711. syntax for the variable assignment:
  3712. <literallayout class='monospaced'>
  3713. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  3714. </literallayout>
  3715. </para></listitem>
  3716. <listitem><para>
  3717. <emphasis>Shell Function Syntax:</emphasis>
  3718. Write shell functions as if you were writing a shell
  3719. script when you describe a list of actions to take.
  3720. You should ensure that your script works with a generic
  3721. <filename>sh</filename> and that it does not require
  3722. any <filename>bash</filename> or other shell-specific
  3723. functionality.
  3724. The same considerations apply to various system
  3725. utilities (e.g. <filename>sed</filename>,
  3726. <filename>grep</filename>, <filename>awk</filename>,
  3727. and so forth) that you might wish to use.
  3728. If in doubt, you should check with multiple
  3729. implementations - including those from BusyBox.
  3730. </para></listitem>
  3731. </itemizedlist>
  3732. </para>
  3733. </section>
  3734. </section>
  3735. <section id="platdev-newmachine">
  3736. <title>Adding a New Machine</title>
  3737. <para>
  3738. Adding a new machine to the Yocto Project is a straightforward
  3739. process.
  3740. This section describes how to add machines that are similar
  3741. to those that the Yocto Project already supports.
  3742. <note>
  3743. Although well within the capabilities of the Yocto Project,
  3744. adding a totally new architecture might require
  3745. changes to <filename>gcc/glibc</filename> and to the site
  3746. information, which is beyond the scope of this manual.
  3747. </note>
  3748. </para>
  3749. <para>
  3750. For a complete example that shows how to add a new machine,
  3751. see the
  3752. "<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>"
  3753. section in the Yocto Project Board Support Package (BSP)
  3754. Developer's Guide.
  3755. </para>
  3756. <section id="platdev-newmachine-conffile">
  3757. <title>Adding the Machine Configuration File</title>
  3758. <para>
  3759. To add a new machine, you need to add a new machine
  3760. configuration file to the layer's
  3761. <filename>conf/machine</filename> directory.
  3762. This configuration file provides details about the device
  3763. you are adding.
  3764. </para>
  3765. <para>
  3766. The OpenEmbedded build system uses the root name of the
  3767. machine configuration file to reference the new machine.
  3768. For example, given a machine configuration file named
  3769. <filename>crownbay.conf</filename>, the build system
  3770. recognizes the machine as "crownbay".
  3771. </para>
  3772. <para>
  3773. The most important variables you must set in your machine
  3774. configuration file or include from a lower-level configuration
  3775. file are as follows:
  3776. <itemizedlist>
  3777. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  3778. (e.g. "arm")</para></listitem>
  3779. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  3780. </para></listitem>
  3781. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  3782. (e.g. "apm screen wifi")</para></listitem>
  3783. </itemizedlist>
  3784. </para>
  3785. <para>
  3786. You might also need these variables:
  3787. <itemizedlist>
  3788. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  3789. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  3790. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  3791. (e.g. "zImage")</para></listitem>
  3792. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  3793. (e.g. "tar.gz jffs2")</para></listitem>
  3794. </itemizedlist>
  3795. </para>
  3796. <para>
  3797. You can find full details on these variables in the reference
  3798. section.
  3799. You can leverage existing machine <filename>.conf</filename>
  3800. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  3801. </para>
  3802. </section>
  3803. <section id="platdev-newmachine-kernel">
  3804. <title>Adding a Kernel for the Machine</title>
  3805. <para>
  3806. The OpenEmbedded build system needs to be able to build a kernel
  3807. for the machine.
  3808. You need to either create a new kernel recipe for this machine,
  3809. or extend an existing kernel recipe.
  3810. You can find several kernel recipe examples in the
  3811. Source Directory at
  3812. <filename>meta/recipes-kernel/linux</filename>
  3813. that you can use as references.
  3814. </para>
  3815. <para>
  3816. If you are creating a new kernel recipe, normal recipe-writing
  3817. rules apply for setting up a
  3818. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3819. Thus, you need to specify any necessary patches and set
  3820. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3821. to point at the source code.
  3822. You need to create a <filename>do_configure</filename> task that
  3823. configures the unpacked kernel with a
  3824. <filename>defconfig</filename> file.
  3825. You can do this by using a <filename>make defconfig</filename>
  3826. command or, more commonly, by copying in a suitable
  3827. <filename>defconfig</filename> file and then running
  3828. <filename>make oldconfig</filename>.
  3829. By making use of <filename>inherit kernel</filename> and
  3830. potentially some of the <filename>linux-*.inc</filename> files,
  3831. most other functionality is centralized and the defaults of the
  3832. class normally work well.
  3833. </para>
  3834. <para>
  3835. If you are extending an existing kernel recipe, it is usually
  3836. a matter of adding a suitable <filename>defconfig</filename>
  3837. file.
  3838. The file needs to be added into a location similar to
  3839. <filename>defconfig</filename> files used for other machines
  3840. in a given kernel recipe.
  3841. A possible way to do this is by listing the file in the
  3842. <filename>SRC_URI</filename> and adding the machine to the
  3843. expression in
  3844. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  3845. <literallayout class='monospaced'>
  3846. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  3847. </literallayout>
  3848. For more information on <filename>defconfig</filename> files,
  3849. see the
  3850. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  3851. section in the Yocto Project Linux Kernel Development Manual.
  3852. </para>
  3853. </section>
  3854. <section id="platdev-newmachine-formfactor">
  3855. <title>Adding a Formfactor Configuration File</title>
  3856. <para>
  3857. A formfactor configuration file provides information about the
  3858. target hardware for which the image is being built and information that
  3859. the build system cannot obtain from other sources such as the kernel.
  3860. Some examples of information contained in a formfactor configuration file include
  3861. framebuffer orientation, whether or not the system has a keyboard,
  3862. the positioning of the keyboard in relation to the screen, and
  3863. the screen resolution.
  3864. </para>
  3865. <para>
  3866. The build system uses reasonable defaults in most cases.
  3867. However, if customization is
  3868. necessary, you need to create a <filename>machconfig</filename> file
  3869. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  3870. directory.
  3871. This directory contains directories for specific machines such as
  3872. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  3873. For information about the settings available and the defaults, see the
  3874. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  3875. same area.
  3876. </para>
  3877. <para>
  3878. Following is an example for "qemuarm" machine:
  3879. <literallayout class='monospaced'>
  3880. HAVE_TOUCHSCREEN=1
  3881. HAVE_KEYBOARD=1
  3882. DISPLAY_CAN_ROTATE=0
  3883. DISPLAY_ORIENTATION=0
  3884. #DISPLAY_WIDTH_PIXELS=640
  3885. #DISPLAY_HEIGHT_PIXELS=480
  3886. #DISPLAY_BPP=16
  3887. DISPLAY_DPI=150
  3888. DISPLAY_SUBPIXEL_ORDER=vrgb
  3889. </literallayout>
  3890. </para>
  3891. </section>
  3892. </section>
  3893. <section id='gs-upgrading-recipes'>
  3894. <title>Upgrading Recipes</title>
  3895. <para>
  3896. Over time, upstream developers publish new versions for software
  3897. built by layer recipes.
  3898. It is recommended to keep recipes up-to-date with upstream
  3899. version releases.
  3900. You can use the Automated Upgrade Helper (AUH) to set up
  3901. automatic version upgrades.
  3902. Alternatively, you can use <filename>devtool upgrade</filename>
  3903. to set up semi-automatic version upgrades.
  3904. Finally, you can even manually upgrade a recipe by editing the
  3905. recipe itself.
  3906. </para>
  3907. <section id='gs-using-the-auto-upgrade-helper'>
  3908. <title>Using the Auto Upgrade Helper (AUH)</title>
  3909. <para>
  3910. The AUH utility works in conjunction with the
  3911. OpenEmbedded build system in order to automatically generate
  3912. upgrades for recipes based on new versions being
  3913. published upstream.
  3914. Use AUH when you want to create a service that performs the
  3915. upgrades automatically and optionally sends you an email with
  3916. the results.
  3917. </para>
  3918. <para>
  3919. AUH allows you to update several recipes with a single use.
  3920. You can also optionally perform build and integration tests
  3921. using images with the results saved to your hard drive and
  3922. emails of results optionally sent to recipe maintainers.
  3923. Finally, AUH creates Git commits with appropriate commit
  3924. messages in the layer's tree for the changes made to recipes.
  3925. <note>
  3926. Conditions do exist when you should not use AUH to upgrade
  3927. recipes and you should instead use either
  3928. <filename>devtool upgrade</filename> or upgrade your
  3929. recipes manually:
  3930. <itemizedlist>
  3931. <listitem><para>
  3932. When AUH cannot complete the upgrade sequence.
  3933. This situation usually results because custom
  3934. patches carried by the recipe cannot be
  3935. automatically rebased to the new version.
  3936. In this case, <filename>devtool upgrade</filename>
  3937. allows you to manually resolve conflicts.
  3938. </para></listitem>
  3939. <listitem><para>
  3940. When for any reason you want fuller control over
  3941. the upgrade process.
  3942. For example, when you want special arrangements
  3943. for testing.
  3944. </para></listitem>
  3945. </itemizedlist>
  3946. </note>
  3947. </para>
  3948. <para>
  3949. The following steps describe how to set up the AUH utility:
  3950. <orderedlist>
  3951. <listitem><para>
  3952. <emphasis>Be Sure the Development Host is Set Up:</emphasis>
  3953. You need to be sure that your development host is
  3954. set up to use the Yocto Project.
  3955. For information on how to set up your host, see the
  3956. "<link linkend='dev-preparing-the-build-host'>Preparing the Build Host</link>"
  3957. section.
  3958. </para></listitem>
  3959. <listitem><para>
  3960. <emphasis>Make Sure Git is Configured:</emphasis>
  3961. The AUH utility requires Git to be configured because
  3962. AUH uses Git to save upgrades.
  3963. Thus, you must have Git user and email configured.
  3964. The following command shows your configurations:
  3965. <literallayout class='monospaced'>
  3966. $ git config --list
  3967. </literallayout>
  3968. If you do not have the user and email configured, you
  3969. can use the following commands to do so:
  3970. <literallayout class='monospaced'>
  3971. $ git config --global user.name <replaceable>some_name</replaceable>
  3972. $ git config --global user.email <replaceable>username</replaceable>@<replaceable>domain</replaceable>.com
  3973. </literallayout>
  3974. </para></listitem>
  3975. <listitem><para>
  3976. <emphasis>Clone the AUH Repository:</emphasis>
  3977. To use AUH, you must clone the repository onto your
  3978. development host.
  3979. The following command uses Git to create a local
  3980. copy of the repository on your system:
  3981. <literallayout class='monospaced'>
  3982. $ git clone git://git.yoctoproject.org/auto-upgrade-helper
  3983. Cloning into 'auto-upgrade-helper'...
  3984. remote: Counting objects: 768, done.
  3985. remote: Compressing objects: 100% (300/300), done.
  3986. remote: Total 768 (delta 499), reused 703 (delta 434)
  3987. Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done.
  3988. Resolving deltas: 100% (499/499), done.
  3989. Checking connectivity... done.
  3990. </literallayout>
  3991. AUH is not part of the
  3992. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core (OE-Core)</ulink>
  3993. or
  3994. <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink>
  3995. repositories.
  3996. </para></listitem>
  3997. <listitem><para>
  3998. <emphasis>Create a Dedicated Build Directory:</emphasis>
  3999. Run the
  4000. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
  4001. script to create a fresh build directory that you
  4002. use exclusively for running the AUH utility:
  4003. <literallayout class='monospaced'>
  4004. $ cd ~/poky
  4005. $ source oe-init-build-env <replaceable>your_AUH_build_directory</replaceable>
  4006. </literallayout>
  4007. Re-using an existing build directory and its
  4008. configurations is not recommended as existing settings
  4009. could cause AUH to fail or behave undesirably.
  4010. </para></listitem>
  4011. <listitem><para>
  4012. <emphasis>Make Configurations in Your Local Configuration File:</emphasis>
  4013. Several settings need to exist in the
  4014. <filename>local.conf</filename> file in the build
  4015. directory you just created for AUH.
  4016. Make these following configurations:
  4017. <itemizedlist>
  4018. <listitem><para>
  4019. Enable "distrodata" as follows:
  4020. <literallayout class='monospaced'>
  4021. INHERIT =+ "distrodata"
  4022. </literallayout>
  4023. </para></listitem>
  4024. <listitem><para>
  4025. If you want to enable
  4026. <ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-build-output-quality'>Build History</ulink>,
  4027. which is optional, you need the following
  4028. lines in the
  4029. <filename>conf/local.conf</filename> file:
  4030. <literallayout class='monospaced'>
  4031. INHERIT =+ "buildhistory"
  4032. BUILDHISTORY_COMMIT = "1"
  4033. </literallayout>
  4034. With this configuration and a successful
  4035. upgrade, a build history "diff" file appears in
  4036. the
  4037. <filename>upgrade-helper/work/recipe/buildhistory-diff.txt</filename>
  4038. file found in your build directory.
  4039. </para></listitem>
  4040. <listitem><para>
  4041. If you want to enable testing through the
  4042. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  4043. class, which is optional, you need to have the
  4044. following set in your
  4045. <filename>conf/local.conf</filename> file:
  4046. <literallayout class='monospaced'>
  4047. INHERIT += "testimage"
  4048. </literallayout>
  4049. <note>
  4050. If your distro does not enable by default
  4051. ptest, which Poky does, you need the
  4052. following in your
  4053. <filename>local.conf</filename> file:
  4054. <literallayout class='monospaced'>
  4055. DISTRO_FEATURES_append = " ptest"
  4056. </literallayout>
  4057. </note>
  4058. </para></listitem>
  4059. </itemizedlist>
  4060. </para></listitem>
  4061. <listitem><para>
  4062. <emphasis>Optionally Start a vncserver:</emphasis>
  4063. If you are running in a server without an X11 session,
  4064. you need to start a vncserver:
  4065. <literallayout class='monospaced'>
  4066. $ vncserver :1
  4067. $ export DISPLAY=:1
  4068. </literallayout>
  4069. </para></listitem>
  4070. <listitem><para>
  4071. <emphasis>Create and Edit an AUH Configuration File:</emphasis>
  4072. You need to have the
  4073. <filename>upgrade-helper/upgrade-helper.conf</filename>
  4074. configuration file in your build directory.
  4075. You can find a sample configuration file in the
  4076. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/'>AUH source repository</ulink>.
  4077. </para>
  4078. <para>Read through the sample file and make
  4079. configurations as needed.
  4080. For example, if you enabled build history in your
  4081. <filename>local.conf</filename> as described earlier,
  4082. you must enable it in
  4083. <filename>upgrade-helper.conf</filename>.</para>
  4084. <para>Also, if you are using the default
  4085. <filename>maintainers.inc</filename> file supplied
  4086. with Poky and located in
  4087. <filename>meta-yocto</filename> and you do not set a
  4088. "maintainers_whitelist" or "global_maintainer_override"
  4089. in the <filename>upgrade-helper.conf</filename>
  4090. configuration, and you specify "-e all" on the
  4091. AUH command-line, the utility automatically sends out
  4092. emails to all the default maintainers.
  4093. Please avoid this.
  4094. </para></listitem>
  4095. </orderedlist>
  4096. </para>
  4097. <para>
  4098. This next set of examples describes how to use the AUH:
  4099. <itemizedlist>
  4100. <listitem><para>
  4101. <emphasis>Upgrading a Specific Recipe:</emphasis>
  4102. To upgrade a specific recipe, use the following
  4103. form:
  4104. <literallayout class='monospaced'>
  4105. $ upgrade-helper.py <replaceable>recipe_name</replaceable>
  4106. </literallayout>
  4107. For example, this command upgrades the
  4108. <filename>xmodmap</filename> recipe:
  4109. <literallayout class='monospaced'>
  4110. $ upgrade-helper.py xmodmap
  4111. </literallayout>
  4112. </para></listitem>
  4113. <listitem><para>
  4114. <emphasis>Upgrading a Specific Recipe to a Particular Version:</emphasis>
  4115. To upgrade a specific recipe to a particular version,
  4116. use the following form:
  4117. <literallayout class='monospaced'>
  4118. $ upgrade-helper.py <replaceable>recipe_name</replaceable> -t <replaceable>version</replaceable>
  4119. </literallayout>
  4120. For example, this command upgrades the
  4121. <filename>xmodmap</filename> recipe to version
  4122. 1.2.3:
  4123. <literallayout class='monospaced'>
  4124. $ upgrade-helper.py xmodmap -t 1.2.3
  4125. </literallayout>
  4126. </para></listitem>
  4127. <listitem><para>
  4128. <emphasis>Upgrading all Recipes to the Latest Versions and Suppressing Email Notifications:</emphasis>
  4129. To upgrade all recipes to their most recent versions
  4130. and suppress the email notifications, use the following
  4131. command:
  4132. <literallayout class='monospaced'>
  4133. $ upgrade-helper.py all
  4134. </literallayout>
  4135. </para></listitem>
  4136. <listitem><para>
  4137. <emphasis>Upgrading all Recipes to the Latest Versions and Send Email Notifications:</emphasis>
  4138. To upgrade all recipes to their most recent versions
  4139. and send email messages to maintainers for each
  4140. attempted recipe as well as a status email, use the
  4141. following command:
  4142. <literallayout class='monospaced'>
  4143. $ upgrade-helper.py -e all
  4144. </literallayout>
  4145. </para></listitem>
  4146. </itemizedlist>
  4147. </para>
  4148. <para>
  4149. Once you have run the AUH utility, you can find the results
  4150. in the AUH build directory:
  4151. <literallayout class='monospaced'>
  4152. ${BUILDDIR}/upgrade-helper/<replaceable>timestamp</replaceable>
  4153. </literallayout>
  4154. The AUH utility also creates recipe update commits from
  4155. successful upgrade attempts in the layer tree.
  4156. </para>
  4157. <para>
  4158. You can easily set up to run the AUH utility on a regular
  4159. basis by using a cron job.
  4160. See the
  4161. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/weeklyjob.sh'><filename>weeklyjob.sh</filename></ulink>
  4162. file distributed with the utility for an example.
  4163. </para>
  4164. </section>
  4165. <section id='gs-using-devtool-upgrade'>
  4166. <title>Using <filename>devtool upgrade</filename></title>
  4167. <para>
  4168. As mentioned earlier, an alternative method for upgrading
  4169. recipes to newer versions is to use
  4170. <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool upgrade</filename></ulink>.
  4171. You can read about <filename>devtool upgrade</filename> in
  4172. general in the
  4173. "<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>"
  4174. section in the Yocto Project Application Development and the
  4175. Extensible Software Development Kit (eSDK) Manual.
  4176. </para>
  4177. <para>
  4178. To see all the command-line options available with
  4179. <filename>devtool upgrade</filename>, use the following help
  4180. command:
  4181. <literallayout class='monospaced'>
  4182. $ devtool upgrade -h
  4183. </literallayout>
  4184. </para>
  4185. <para>
  4186. If you want to find out what version a recipe is currently at
  4187. upstream without any attempt to upgrade your local version of
  4188. the recipe, you can use the following command:
  4189. <literallayout class='monospaced'>
  4190. $ devtool latest-version <replaceable>recipe_name</replaceable>
  4191. </literallayout>
  4192. </para>
  4193. <para>
  4194. As mentioned in the previous section describing AUH,
  4195. <filename>devtool upgrade</filename> works in a
  4196. less-automated manner than AUH.
  4197. Specifically, <filename>devtool upgrade</filename> only
  4198. works on a single recipe that you name on the command line,
  4199. cannot perform build and integration testing using images,
  4200. and does not automatically generate commits for changes in
  4201. the source tree.
  4202. Despite all these "limitations",
  4203. <filename>devtool upgrade</filename> updates the recipe file
  4204. to the new upstream version and attempts to rebase custom
  4205. patches contained by the recipe as needed.
  4206. <note>
  4207. AUH uses much of <filename>devtool upgrade</filename>
  4208. behind the scenes making AUH somewhat of a "wrapper"
  4209. application for <filename>devtool upgrade</filename>.
  4210. </note>
  4211. </para>
  4212. <para>
  4213. A typical scenario involves having used Git to clone an
  4214. upstream repository that you use during build operations.
  4215. Because you are (or have) built the recipe in the past, the
  4216. layer is likely added to your configuration already.
  4217. If for some reason, the layer is not added, you could add
  4218. it easily using the
  4219. <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'><filename>bitbake-layers</filename></ulink>
  4220. script.
  4221. For example, suppose you use the <filename>nano.bb</filename>
  4222. recipe from the <filename>meta-oe</filename> layer in the
  4223. <filename>meta-openembedded</filename> repository.
  4224. For this example, assume that the layer has been cloned into
  4225. following area:
  4226. <literallayout class='monospaced'>
  4227. /home/scottrif/meta-openembedded
  4228. </literallayout>
  4229. The following command from your
  4230. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  4231. adds the layer to your build configuration (i.e.
  4232. <filename>${BUILDDIR}/conf/bblayers.conf</filename>):
  4233. <literallayout class='monospaced'>
  4234. $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe
  4235. NOTE: Starting bitbake server...
  4236. Parsing recipes: 100% |##########################################| Time: 0:00:55
  4237. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  4238. Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00
  4239. Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00
  4240. Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00
  4241. Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00
  4242. </literallayout>
  4243. For this example, assume that the <filename>nano.bb</filename>
  4244. recipe that is upstream has a 2.9.3 version number.
  4245. However, the version in the local repository is 2.7.4.
  4246. The following command from your build directory automatically
  4247. upgrades the recipe for you:
  4248. <note>
  4249. Using the <filename>-V</filename> option is not necessary.
  4250. Omitting the version number causes
  4251. <filename>devtool upgrade</filename> to upgrade the recipe
  4252. to the most recent version.
  4253. </note>
  4254. <literallayout class='monospaced'>
  4255. $ devtool upgrade nano -V 2.9.3
  4256. NOTE: Starting bitbake server...
  4257. NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace
  4258. Parsing recipes: 100% |##########################################| Time: 0:00:46
  4259. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  4260. NOTE: Extracting current version source...
  4261. NOTE: Resolving any missing task queue dependencies
  4262. .
  4263. .
  4264. .
  4265. NOTE: Executing SetScene Tasks
  4266. NOTE: Executing RunQueue Tasks
  4267. NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded.
  4268. Adding changed files: 100% |#####################################| Time: 0:00:00
  4269. NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano
  4270. NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb
  4271. </literallayout>
  4272. Continuing with this example, you can use
  4273. <filename>devtool build</filename> to build the newly upgraded
  4274. recipe:
  4275. <literallayout class='monospaced'>
  4276. $ devtool build nano
  4277. NOTE: Starting bitbake server...
  4278. Loading cache: 100% |################################################################################################| Time: 0:00:01
  4279. Loaded 2040 entries from dependency cache.
  4280. Parsing recipes: 100% |##############################################################################################| Time: 0:00:00
  4281. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  4282. NOTE: Resolving any missing task queue dependencies
  4283. .
  4284. .
  4285. .
  4286. NOTE: Executing SetScene Tasks
  4287. NOTE: Executing RunQueue Tasks
  4288. NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano
  4289. NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded.
  4290. </literallayout>
  4291. Within the <filename>devtool upgrade</filename> workflow,
  4292. opportunity exists to deploy and test your rebuilt software.
  4293. For this example, however, running
  4294. <filename>devtool finish</filename> cleans up the workspace
  4295. once the source in your workspace is clean.
  4296. This usually means using Git to stage and submit commits
  4297. for the changes generated by the upgrade process.
  4298. </para>
  4299. <para>
  4300. Once the tree is clean, you can clean things up in this
  4301. example with the following command from the
  4302. <filename>${BUILDDIR}/workspace/sources/nano</filename>
  4303. directory:
  4304. <literallayout class='monospaced'>
  4305. $ devtool finish nano meta-oe
  4306. NOTE: Starting bitbake server...
  4307. Loading cache: 100% |################################################################################################| Time: 0:00:00
  4308. Loaded 2040 entries from dependency cache.
  4309. Parsing recipes: 100% |##############################################################################################| Time: 0:00:01
  4310. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  4311. NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch
  4312. NOTE: Updating recipe nano_2.9.3.bb
  4313. NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb
  4314. NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano
  4315. NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually
  4316. </literallayout>
  4317. Using the <filename>devtool finish</filename> command cleans
  4318. up the workspace and creates a patch file based on your
  4319. commits.
  4320. The tool puts all patch files back into the source directory
  4321. in a sub-directory named <filename>nano</filename> in this
  4322. case.
  4323. </para>
  4324. </section>
  4325. <section id='dev-manually-upgrading-a-recipe'>
  4326. <title>Manually Upgrading a Recipe</title>
  4327. <para>
  4328. If for some reason you choose not to upgrade recipes using the
  4329. <link linkend='gs-using-the-auto-upgrade-helper'>Auto Upgrade Helper (AUH)</link>
  4330. or by using
  4331. <link linkend='gs-using-devtool-upgrade'><filename>devtool upgrade</filename></link>,
  4332. you can manually edit the recipe files to upgrade the versions.
  4333. <note><title>Caution</title>
  4334. Manually updating multiple recipes scales poorly and
  4335. involves many steps.
  4336. The recommendation to upgrade recipe versions is through
  4337. AUH or <filename>devtool upgrade</filename>, both of which
  4338. automate some steps and provide guidance for others needed
  4339. for the manual process.
  4340. </note>
  4341. </para>
  4342. <para>
  4343. To manually upgrade recipe versions, follow these general steps:
  4344. <orderedlist>
  4345. <listitem><para>
  4346. <emphasis>Change the Version:</emphasis>
  4347. Rename the recipe such that the version (i.e. the
  4348. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  4349. part of the recipe name) changes appropriately.
  4350. If the version is not part of the recipe name, change
  4351. the value as it is set for <filename>PV</filename>
  4352. within the recipe itself.
  4353. </para></listitem>
  4354. <listitem><para>
  4355. <emphasis>Update <filename>SRCREV</filename> if Needed:</emphasis>
  4356. If the source code your recipe builds is fetched from
  4357. Git or some other version control system, update
  4358. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  4359. to point to the commit hash that matches the new
  4360. version.
  4361. </para></listitem>
  4362. <listitem><para>
  4363. <emphasis>Build the Software:</emphasis>
  4364. Try to build the recipe using BitBake.
  4365. Typical build failures include the following:
  4366. <itemizedlist>
  4367. <listitem><para>
  4368. License statements were updated for the new
  4369. version.
  4370. For this case, you need to review any changes
  4371. to the license and update the values of
  4372. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  4373. and
  4374. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  4375. as needed.
  4376. <note>
  4377. License changes are often inconsequential.
  4378. For example, the license text's copyright
  4379. year might have changed.
  4380. </note>
  4381. </para></listitem>
  4382. <listitem><para>
  4383. Custom patches carried by the older version of
  4384. the recipe might fail to apply to the new
  4385. version.
  4386. For these cases, you need to review the
  4387. failures.
  4388. Patches might not be necessary for the new
  4389. version of the software if the upgraded version
  4390. has fixed those issues.
  4391. If a patch is necessary and failing, you need
  4392. to rebase it into the new version.
  4393. </para></listitem>
  4394. </itemizedlist>
  4395. </para></listitem>
  4396. <listitem><para>
  4397. <emphasis>Optionally Attempt to Build for Several Architectures:</emphasis>
  4398. Once you successfully build the new software for a
  4399. given architecture, you could test the build for
  4400. other architectures by changing the
  4401. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4402. variable and rebuilding the software.
  4403. This optional step is especially important if the
  4404. recipe is to be released publicly.
  4405. </para></listitem>
  4406. <listitem><para>
  4407. <emphasis>Check the Upstream Change Log or Release Notes:</emphasis>
  4408. Checking both these reveals if new features exist that
  4409. could break backwards-compatibility.
  4410. If so, you need to take steps to mitigate or eliminate
  4411. that situation.
  4412. </para></listitem>
  4413. <listitem><para>
  4414. <emphasis>Optionally Create a Bootable Image and Test:</emphasis>
  4415. If you want, you can test the new software by booting
  4416. it onto actual hardware.
  4417. </para></listitem>
  4418. <listitem><para>
  4419. <emphasis>Create a Commit with the Change in the Layer Repository:</emphasis>
  4420. After all builds work and any testing is successful,
  4421. you can create commits for any changes in the layer
  4422. holding your upgraded recipe.
  4423. </para></listitem>
  4424. </orderedlist>
  4425. </para>
  4426. </section>
  4427. </section>
  4428. <section id='finding-the-temporary-source-code'>
  4429. <title>Finding Temporary Source Code</title>
  4430. <para>
  4431. You might find it helpful during development to modify the
  4432. temporary source code used by recipes to build packages.
  4433. For example, suppose you are developing a patch and you need to
  4434. experiment a bit to figure out your solution.
  4435. After you have initially built the package, you can iteratively
  4436. tweak the source code, which is located in the
  4437. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  4438. and then you can force a re-compile and quickly test your altered
  4439. code.
  4440. Once you settle on a solution, you can then preserve your changes
  4441. in the form of patches.
  4442. </para>
  4443. <para>
  4444. During a build, the unpacked temporary source code used by recipes
  4445. to build packages is available in the Build Directory as
  4446. defined by the
  4447. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  4448. variable.
  4449. Below is the default value for the <filename>S</filename> variable
  4450. as defined in the
  4451. <filename>meta/conf/bitbake.conf</filename> configuration file
  4452. in the
  4453. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  4454. <literallayout class='monospaced'>
  4455. S = "${WORKDIR}/${BP}"
  4456. </literallayout>
  4457. You should be aware that many recipes override the
  4458. <filename>S</filename> variable.
  4459. For example, recipes that fetch their source from Git usually set
  4460. <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
  4461. <note>
  4462. The
  4463. <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  4464. represents the base recipe name, which consists of the name
  4465. and version:
  4466. <literallayout class='monospaced'>
  4467. BP = "${BPN}-${PV}"
  4468. </literallayout>
  4469. </note>
  4470. </para>
  4471. <para>
  4472. The path to the work directory for the recipe
  4473. (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
  4474. is defined as follows:
  4475. <literallayout class='monospaced'>
  4476. ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
  4477. </literallayout>
  4478. The actual directory depends on several things:
  4479. <itemizedlist>
  4480. <listitem><para>
  4481. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  4482. The top-level build output directory.
  4483. </para></listitem>
  4484. <listitem><para>
  4485. <ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
  4486. The target system identifier.
  4487. </para></listitem>
  4488. <listitem><para>
  4489. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  4490. The recipe name.
  4491. </para></listitem>
  4492. <listitem><para>
  4493. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
  4494. The epoch - (if
  4495. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
  4496. is not specified, which is usually the case for most
  4497. recipes, then <filename>EXTENDPE</filename> is blank).
  4498. </para></listitem>
  4499. <listitem><para>
  4500. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  4501. The recipe version.
  4502. </para></listitem>
  4503. <listitem><para>
  4504. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  4505. The recipe revision.
  4506. </para></listitem>
  4507. </itemizedlist>
  4508. </para>
  4509. <para>
  4510. As an example, assume a Source Directory top-level folder
  4511. named <filename>poky</filename>, a default Build Directory at
  4512. <filename>poky/build</filename>, and a
  4513. <filename>qemux86-poky-linux</filename> machine target
  4514. system.
  4515. Furthermore, suppose your recipe is named
  4516. <filename>foo_1.3.0.bb</filename>.
  4517. In this case, the work directory the build system uses to
  4518. build the package would be as follows:
  4519. <literallayout class='monospaced'>
  4520. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  4521. </literallayout>
  4522. </para>
  4523. </section>
  4524. <section id="using-a-quilt-workflow">
  4525. <title>Using Quilt in Your Workflow</title>
  4526. <para>
  4527. <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
  4528. is a powerful tool that allows you to capture source code changes
  4529. without having a clean source tree.
  4530. This section outlines the typical workflow you can use to modify
  4531. source code, test changes, and then preserve the changes in the
  4532. form of a patch all using Quilt.
  4533. <note><title>Tip</title>
  4534. With regard to preserving changes to source files, if you
  4535. clean a recipe or have <filename>rm_work</filename> enabled,
  4536. the
  4537. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink>
  4538. as described in the Yocto Project Application Development
  4539. and the Extensible Software Development Kit (eSDK) manual
  4540. is a safer development flow than the flow that uses Quilt.
  4541. </note>
  4542. </para>
  4543. <para>
  4544. Follow these general steps:
  4545. <orderedlist>
  4546. <listitem><para>
  4547. <emphasis>Find the Source Code:</emphasis>
  4548. Temporary source code used by the OpenEmbedded build system
  4549. is kept in the
  4550. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4551. See the
  4552. "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
  4553. section to learn how to locate the directory that has the
  4554. temporary source code for a particular package.
  4555. </para></listitem>
  4556. <listitem><para>
  4557. <emphasis>Change Your Working Directory:</emphasis>
  4558. You need to be in the directory that has the temporary
  4559. source code.
  4560. That directory is defined by the
  4561. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  4562. variable.</para></listitem>
  4563. <listitem><para>
  4564. <emphasis>Create a New Patch:</emphasis>
  4565. Before modifying source code, you need to create a new
  4566. patch.
  4567. To create a new patch file, use
  4568. <filename>quilt new</filename> as below:
  4569. <literallayout class='monospaced'>
  4570. $ quilt new my_changes.patch
  4571. </literallayout>
  4572. </para></listitem>
  4573. <listitem><para>
  4574. <emphasis>Notify Quilt and Add Files:</emphasis>
  4575. After creating the patch, you need to notify Quilt about
  4576. the files you plan to edit.
  4577. You notify Quilt by adding the files to the patch you
  4578. just created:
  4579. <literallayout class='monospaced'>
  4580. $ quilt add file1.c file2.c file3.c
  4581. </literallayout>
  4582. </para></listitem>
  4583. <listitem><para>
  4584. <emphasis>Edit the Files:</emphasis>
  4585. Make your changes in the source code to the files you added
  4586. to the patch.
  4587. </para></listitem>
  4588. <listitem><para>
  4589. <emphasis>Test Your Changes:</emphasis>
  4590. Once you have modified the source code, the easiest way to
  4591. test your changes is by calling the
  4592. <filename>do_compile</filename> task as shown in the
  4593. following example:
  4594. <literallayout class='monospaced'>
  4595. $ bitbake -c compile -f <replaceable>package</replaceable>
  4596. </literallayout>
  4597. The <filename>-f</filename> or <filename>--force</filename>
  4598. option forces the specified task to execute.
  4599. If you find problems with your code, you can just keep
  4600. editing and re-testing iteratively until things work
  4601. as expected.
  4602. <note>
  4603. All the modifications you make to the temporary
  4604. source code disappear once you run the
  4605. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
  4606. or
  4607. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
  4608. tasks using BitBake (i.e.
  4609. <filename>bitbake -c clean <replaceable>package</replaceable></filename>
  4610. and
  4611. <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
  4612. Modifications will also disappear if you use the
  4613. <filename>rm_work</filename> feature as described
  4614. in the
  4615. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-saving-memory-during-a-build'>Conserving Disk Space During Builds</ulink>"
  4616. section.
  4617. </note>
  4618. </para></listitem>
  4619. <listitem><para>
  4620. <emphasis>Generate the Patch:</emphasis>
  4621. Once your changes work as expected, you need to use Quilt
  4622. to generate the final patch that contains all your
  4623. modifications.
  4624. <literallayout class='monospaced'>
  4625. $ quilt refresh
  4626. </literallayout>
  4627. At this point, the <filename>my_changes.patch</filename>
  4628. file has all your edits made to the
  4629. <filename>file1.c</filename>, <filename>file2.c</filename>,
  4630. and <filename>file3.c</filename> files.</para>
  4631. <para>You can find the resulting patch file in the
  4632. <filename>patches/</filename> subdirectory of the source
  4633. (<filename>S</filename>) directory.
  4634. </para></listitem>
  4635. <listitem><para>
  4636. <emphasis>Copy the Patch File:</emphasis>
  4637. For simplicity, copy the patch file into a directory
  4638. named <filename>files</filename>, which you can create
  4639. in the same directory that holds the recipe
  4640. (<filename>.bb</filename>) file or the append
  4641. (<filename>.bbappend</filename>) file.
  4642. Placing the patch here guarantees that the OpenEmbedded
  4643. build system will find the patch.
  4644. Next, add the patch into the
  4645. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  4646. of the recipe.
  4647. Here is an example:
  4648. <literallayout class='monospaced'>
  4649. SRC_URI += "file://my_changes.patch"
  4650. </literallayout>
  4651. </para></listitem>
  4652. </orderedlist>
  4653. </para>
  4654. </section>
  4655. <section id="platdev-appdev-devshell">
  4656. <title>Using a Development Shell</title>
  4657. <para>
  4658. When debugging certain commands or even when just editing packages,
  4659. <filename>devshell</filename> can be a useful tool.
  4660. When you invoke <filename>devshell</filename>, all tasks up to and
  4661. including
  4662. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  4663. are run for the specified target.
  4664. Then, a new terminal is opened and you are placed in
  4665. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  4666. the source directory.
  4667. In the new terminal, all the OpenEmbedded build-related environment variables are
  4668. still defined so you can use commands such as <filename>configure</filename> and
  4669. <filename>make</filename>.
  4670. The commands execute just as if the OpenEmbedded build system were executing them.
  4671. Consequently, working this way can be helpful when debugging a build or preparing
  4672. software to be used with the OpenEmbedded build system.
  4673. </para>
  4674. <para>
  4675. Following is an example that uses <filename>devshell</filename> on a target named
  4676. <filename>matchbox-desktop</filename>:
  4677. <literallayout class='monospaced'>
  4678. $ bitbake matchbox-desktop -c devshell
  4679. </literallayout>
  4680. </para>
  4681. <para>
  4682. This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
  4683. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  4684. variable controls what type of shell is opened.
  4685. </para>
  4686. <para>
  4687. For spawned terminals, the following occurs:
  4688. <itemizedlist>
  4689. <listitem><para>The <filename>PATH</filename> variable includes the
  4690. cross-toolchain.</para></listitem>
  4691. <listitem><para>The <filename>pkgconfig</filename> variables find the correct
  4692. <filename>.pc</filename> files.</para></listitem>
  4693. <listitem><para>The <filename>configure</filename> command finds the
  4694. Yocto Project site files as well as any other necessary files.</para></listitem>
  4695. </itemizedlist>
  4696. </para>
  4697. <para>
  4698. Within this environment, you can run configure or compile
  4699. commands as if they were being run by
  4700. the OpenEmbedded build system itself.
  4701. As noted earlier, the working directory also automatically changes to the
  4702. Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
  4703. </para>
  4704. <para>
  4705. To manually run a specific task using <filename>devshell</filename>,
  4706. run the corresponding <filename>run.*</filename> script in
  4707. the
  4708. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename>
  4709. directory (e.g.,
  4710. <filename>run.do_configure.</filename><replaceable>pid</replaceable>).
  4711. If a task's script does not exist, which would be the case if the task was
  4712. skipped by way of the sstate cache, you can create the task by first running
  4713. it outside of the <filename>devshell</filename>:
  4714. <literallayout class='monospaced'>
  4715. $ bitbake -c <replaceable>task</replaceable>
  4716. </literallayout>
  4717. <note><title>Notes</title>
  4718. <itemizedlist>
  4719. <listitem><para>Execution of a task's <filename>run.*</filename>
  4720. script and BitBake's execution of a task are identical.
  4721. In other words, running the script re-runs the task
  4722. just as it would be run using the
  4723. <filename>bitbake -c</filename> command.
  4724. </para></listitem>
  4725. <listitem><para>Any <filename>run.*</filename> file that does not
  4726. have a <filename>.pid</filename> extension is a
  4727. symbolic link (symlink) to the most recent version of that
  4728. file.
  4729. </para></listitem>
  4730. </itemizedlist>
  4731. </note>
  4732. </para>
  4733. <para>
  4734. Remember, that the <filename>devshell</filename> is a mechanism that allows
  4735. you to get into the BitBake task execution environment.
  4736. And as such, all commands must be called just as BitBake would call them.
  4737. That means you need to provide the appropriate options for
  4738. cross-compilation and so forth as applicable.
  4739. </para>
  4740. <para>
  4741. When you are finished using <filename>devshell</filename>, exit the shell
  4742. or close the terminal window.
  4743. </para>
  4744. <note><title>Notes</title>
  4745. <itemizedlist>
  4746. <listitem><para>
  4747. It is worth remembering that when using <filename>devshell</filename>
  4748. you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
  4749. instead of just using <filename>gcc</filename>.
  4750. The same applies to other applications such as <filename>binutils</filename>,
  4751. <filename>libtool</filename> and so forth.
  4752. BitBake sets up environment variables such as <filename>CC</filename>
  4753. to assist applications, such as <filename>make</filename> to find the correct tools.
  4754. </para></listitem>
  4755. <listitem><para>
  4756. It is also worth noting that <filename>devshell</filename> still works over
  4757. X11 forwarding and similar situations.
  4758. </para></listitem>
  4759. </itemizedlist>
  4760. </note>
  4761. </section>
  4762. <section id="platdev-appdev-devpyshell">
  4763. <title>Using a Development Python Shell</title>
  4764. <para>
  4765. Similar to working within a development shell as described in
  4766. the previous section, you can also spawn and work within an
  4767. interactive Python development shell.
  4768. When debugging certain commands or even when just editing packages,
  4769. <filename>devpyshell</filename> can be a useful tool.
  4770. When you invoke <filename>devpyshell</filename>, all tasks up to and
  4771. including
  4772. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  4773. are run for the specified target.
  4774. Then a new terminal is opened.
  4775. Additionally, key Python objects and code are available in the same
  4776. way they are to BitBake tasks, in particular, the data store 'd'.
  4777. So, commands such as the following are useful when exploring the data
  4778. store and running functions:
  4779. <literallayout class='monospaced'>
  4780. pydevshell> d.getVar("STAGING_DIR", True)
  4781. '/media/build1/poky/build/tmp/sysroots'
  4782. pydevshell> d.getVar("STAGING_DIR", False)
  4783. '${TMPDIR}/sysroots'
  4784. pydevshell> d.setVar("FOO", "bar")
  4785. pydevshell> d.getVar("FOO", True)
  4786. 'bar'
  4787. pydevshell> d.delVar("FOO")
  4788. pydevshell> d.getVar("FOO", True)
  4789. pydevshell> bb.build.exec_func("do_unpack", d)
  4790. pydevshell>
  4791. </literallayout>
  4792. The commands execute just as if the OpenEmbedded build system were executing them.
  4793. Consequently, working this way can be helpful when debugging a build or preparing
  4794. software to be used with the OpenEmbedded build system.
  4795. </para>
  4796. <para>
  4797. Following is an example that uses <filename>devpyshell</filename> on a target named
  4798. <filename>matchbox-desktop</filename>:
  4799. <literallayout class='monospaced'>
  4800. $ bitbake matchbox-desktop -c devpyshell
  4801. </literallayout>
  4802. </para>
  4803. <para>
  4804. This command spawns a terminal and places you in an interactive
  4805. Python interpreter within the OpenEmbedded build environment.
  4806. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  4807. variable controls what type of shell is opened.
  4808. </para>
  4809. <para>
  4810. When you are finished using <filename>devpyshell</filename>, you
  4811. can exit the shell either by using Ctrl+d or closing the terminal
  4812. window.
  4813. </para>
  4814. </section>
  4815. <section id='dev-building'>
  4816. <title>Building</title>
  4817. <para>
  4818. This section describes various build procedures.
  4819. For example, the steps needed for a simple build, a target that
  4820. uses multiple configurations, building an image for more than
  4821. one machine, and so forth.
  4822. </para>
  4823. <section id='dev-building-a-simple-image'>
  4824. <title>Building a Simple Image</title>
  4825. <para>
  4826. In the development environment, you need to build an image
  4827. whenever you change hardware support, add or change system
  4828. libraries, or add or change services that have dependencies.
  4829. Several methods exist that allow you to build an image within
  4830. the Yocto Project.
  4831. This section presents the basic steps you need to build a
  4832. simple image using BitBake from a build host running Linux.
  4833. <note><title>Notes</title>
  4834. <itemizedlist>
  4835. <listitem><para>
  4836. For information on how to build an image using
  4837. <ulink url='&YOCTO_DOCS_REF_URL;#toaster-term'>Toaster</ulink>,
  4838. see the
  4839. <ulink url='&YOCTO_DOCS_TOAST_URL;'>Toaster User Manual</ulink>.
  4840. </para></listitem>
  4841. <listitem><para>
  4842. For information on how to use
  4843. <filename>devtool</filename> to build images, see
  4844. the
  4845. "<ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'>Using <filename>devtool</filename> in Your SDK Workflow</ulink>"
  4846. section in the Yocto Project Application
  4847. Development and the Extensible Software Development
  4848. Kit (eSDK) manual.
  4849. </para></listitem>
  4850. <listitem><para>
  4851. For a quick example on how to build an image using
  4852. the OpenEmbedded build system, see the
  4853. <ulink url='&YOCTO_DOCS_BRIEF_URL;'>Yocto Project Quick Build</ulink>
  4854. document.
  4855. </para></listitem>
  4856. </itemizedlist>
  4857. </note>
  4858. </para>
  4859. <para>
  4860. The build process creates an entire Linux distribution from
  4861. source and places it in your
  4862. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  4863. under <filename>tmp/deploy/images</filename>.
  4864. For detailed information on the build process using BitBake,
  4865. see the
  4866. "<ulink url='&YOCTO_DOCS_OM_URL;#images-dev-environment'>Images</ulink>"
  4867. section in the Yocto Project Overview and Concepts Manual.
  4868. </para>
  4869. <para>
  4870. The following figure and list overviews the build process:
  4871. <imagedata fileref="figures/bitbake-build-flow.png" width="7in" depth="4in" align="center" scalefit="1" />
  4872. <orderedlist>
  4873. <listitem><para>
  4874. <emphasis>Set up Your Host Development System to Support
  4875. Development Using the Yocto Project</emphasis>:
  4876. See the
  4877. "<link linkend='dev-manual-start'>Setting Up to Use the Yocto Project</link>"
  4878. section for options on how to get a build host ready to
  4879. use the Yocto Project.
  4880. </para></listitem>
  4881. <listitem><para>
  4882. <emphasis>Initialize the Build Environment:</emphasis>
  4883. Initialize the build environment by sourcing the build
  4884. environment script (i.e.
  4885. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>):
  4886. <literallayout class='monospaced'>
  4887. $ source &OE_INIT_FILE; [<replaceable>build_dir</replaceable>]
  4888. </literallayout></para>
  4889. <para>When you use the initialization script, the
  4890. OpenEmbedded build system uses
  4891. <filename>build</filename> as the default Build
  4892. Directory in your current work directory.
  4893. You can use a <replaceable>build_dir</replaceable>
  4894. argument with the script to specify a different build
  4895. directory.
  4896. <note><title>Tip</title>
  4897. A common practice is to use a different Build
  4898. Directory for different targets.
  4899. For example, <filename>~/build/x86</filename> for a
  4900. <filename>qemux86</filename> target, and
  4901. <filename>~/build/arm</filename> for a
  4902. <filename>qemuarm</filename> target.
  4903. </note>
  4904. </para></listitem>
  4905. <listitem><para>
  4906. <emphasis>Make Sure Your <filename>local.conf</filename>
  4907. File is Correct:</emphasis>
  4908. Ensure the <filename>conf/local.conf</filename>
  4909. configuration file, which is found in the Build
  4910. Directory, is set up how you want it.
  4911. This file defines many aspects of the build environment
  4912. including the target machine architecture through the
  4913. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable,
  4914. the packaging format used during the build
  4915. (<ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>),
  4916. and a centralized tarball download directory through the
  4917. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> variable.
  4918. </para></listitem>
  4919. <listitem><para>
  4920. <emphasis>Build the Image:</emphasis>
  4921. Build the image using the <filename>bitbake</filename>
  4922. command:
  4923. <literallayout class='monospaced'>
  4924. $ bitbake <replaceable>target</replaceable>
  4925. </literallayout>
  4926. <note>
  4927. For information on BitBake, see the
  4928. <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
  4929. </note>
  4930. The <replaceable>target</replaceable> is the name of the
  4931. recipe you want to build.
  4932. Common targets are the images in
  4933. <filename>meta/recipes-core/images</filename>,
  4934. <filename>meta/recipes-sato/images</filename>, and so
  4935. forth all found in the
  4936. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  4937. Or, the target can be the name of a recipe for a
  4938. specific piece of software such as BusyBox.
  4939. For more details about the images the OpenEmbedded build
  4940. system supports, see the
  4941. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  4942. chapter in the Yocto Project Reference Manual.</para>
  4943. <para>As an example, the following command builds the
  4944. <filename>core-image-minimal</filename> image:
  4945. <literallayout class='monospaced'>
  4946. $ bitbake core-image-minimal
  4947. </literallayout>
  4948. Once an image has been built, it often needs to be
  4949. installed.
  4950. The images and kernels built by the OpenEmbedded
  4951. build system are placed in the Build Directory in
  4952. <filename class="directory">tmp/deploy/images</filename>.
  4953. For information on how to run pre-built images such as
  4954. <filename>qemux86</filename> and <filename>qemuarm</filename>,
  4955. see the
  4956. <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
  4957. manual.
  4958. For information about how to install these images,
  4959. see the documentation for your particular board or
  4960. machine.
  4961. </para></listitem>
  4962. </orderedlist>
  4963. </para>
  4964. </section>
  4965. <section id='dev-building-images-for-multiple-targets-using-multiple-configurations'>
  4966. <title>Building Images for Multiple Targets Using Multiple Configurations</title>
  4967. <para>
  4968. You can use a single <filename>bitbake</filename> command
  4969. to build multiple images for different targets where each
  4970. image requires a different configuration (multiple
  4971. configuration builds).
  4972. The builds, in this scenario, are sometimes referred to as
  4973. "multiconfigs", and this section uses that term throughout.
  4974. </para>
  4975. <para>
  4976. This section describes how to set up for multiple
  4977. configuration builds and how to account for cross-build
  4978. dependencies between the multiconfigs.
  4979. </para>
  4980. <section id='dev-setting-up-and-running-a-multiple-configuration-build'>
  4981. <title>Setting Up and Running a Multiple Configuration Build</title>
  4982. <para>
  4983. To accomplish a multiple configuration build, you must
  4984. define each target's configuration separately using
  4985. a parallel configuration file in the
  4986. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  4987. and you must follow a required file hierarchy.
  4988. Additionally, you must enable the multiple configuration
  4989. builds in your <filename>local.conf</filename> file.
  4990. </para>
  4991. <para>
  4992. Follow these steps to set up and execute multiple
  4993. configuration builds:
  4994. <itemizedlist>
  4995. <listitem><para>
  4996. <emphasis>Create Separate Configuration Files</emphasis>:
  4997. You need to create a single configuration file for
  4998. each build target (each multiconfig).
  4999. Minimally, each configuration file must define the
  5000. machine and the temporary directory BitBake uses
  5001. for the build.
  5002. You must not overlap the temporary directories
  5003. used during the build.</para>
  5004. <para>Here is an example showing the minimal
  5005. statements needed in a configuration file for
  5006. a "qemux86" target whose temporary build directory
  5007. is <filename>tmpmultix86</filename>:
  5008. <literallayout class='monospaced'>
  5009. MACHINE="qemux86"
  5010. TMPDIR="${TOPDIR}/tmpmultix86"
  5011. </literallayout></para>
  5012. <para>The location for these multiconfig
  5013. configuration files is specific.
  5014. They must reside in the current build directory in
  5015. a sub-directory of <filename>conf</filename> named
  5016. <filename>multiconfig</filename>.
  5017. Following is an example that defines two
  5018. configuration files for the "x86" and "arm"
  5019. multiconfigs:
  5020. <imagedata fileref="figures/multiconfig_files.png" align="center" width="4in" depth="3in" />
  5021. </para>
  5022. <para>The reason for this required file hierarchy
  5023. is because the <filename>BBPATH</filename> variable
  5024. is not constructed until the layers are parsed.
  5025. Consequently, using the configuration file as a
  5026. pre-configuration file is not possible unless it is
  5027. located in the current working directory.
  5028. </para></listitem>
  5029. <listitem><para>
  5030. <emphasis>Add the BitBake Multi-configuration Variable to the Local Configuration File</emphasis>:
  5031. Use the
  5032. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBMULTICONFIG'><filename>BBMULTICONFIG</filename></ulink>
  5033. variable in your
  5034. <filename>conf/local.conf</filename> configuration
  5035. file to specify each multiconfig.
  5036. Continuing with the example from the previous
  5037. figure, the <filename>BBMULTICONFIG</filename>
  5038. variable needs to enable two multiconfigs: "x86"
  5039. and "arm" by specifying each configuration file:
  5040. <literallayout class='monospaced'>
  5041. BBMULTICONFIG = "x86 arm"
  5042. </literallayout>
  5043. </para></listitem>
  5044. <listitem><para>
  5045. <emphasis>Launch BitBake</emphasis>:
  5046. Use the following BitBake command form to launch the
  5047. multiple configuration build:
  5048. <literallayout class='monospaced'>
  5049. $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ]
  5050. </literallayout>
  5051. For the example in this section, the following
  5052. command applies:
  5053. <literallayout class='monospaced'>
  5054. $ bitbake multiconfig:x86:core-image-minimal multiconfig:arm:core-image-sato
  5055. </literallayout>
  5056. The previous BitBake command builds a
  5057. <filename>core-image-minimal</filename> image that
  5058. is configured through the
  5059. <filename>x86.conf</filename> configuration file
  5060. and builds a <filename>core-image-sato</filename>
  5061. image that is configured through the
  5062. <filename>arm.conf</filename> configuration file.
  5063. </para></listitem>
  5064. </itemizedlist>
  5065. <note>
  5066. Support for multiple configuration builds in the
  5067. Yocto Project &DISTRO; (&DISTRO_NAME;) Release does
  5068. not include Shared State (sstate) optimizations.
  5069. Consequently, if a build uses the same object twice
  5070. in, for example, two different
  5071. <filename>TMPDIR</filename> directories, the build
  5072. either loads from an existing sstate cache for that
  5073. build at the start or builds the object fresh.
  5074. </note>
  5075. </para>
  5076. </section>
  5077. <section id='dev-enabling-multiple-configuration-build-dependencies'>
  5078. <title>Enabling Multiple Configuration Build Dependencies</title>
  5079. <para>
  5080. Sometimes dependencies can exist between targets
  5081. (multiconfigs) in a multiple configuration build.
  5082. For example, suppose that in order to build a
  5083. <filename>core-image-sato</filename> image for an "x86"
  5084. multiconfig, the root filesystem of an "arm"
  5085. multiconfig must exist.
  5086. This dependency is essentially that the
  5087. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink>
  5088. task in the <filename>core-image-sato</filename> recipe
  5089. depends on the completion of the
  5090. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>
  5091. task of the <filename>core-image-minimal</filename>
  5092. recipe.
  5093. </para>
  5094. <para>
  5095. To enable dependencies in a multiple configuration
  5096. build, you must declare the dependencies in the recipe
  5097. using the following statement form:
  5098. <literallayout class='monospaced'>
  5099. <replaceable>task_or_package</replaceable>[mcdepends] = "multiconfig:<replaceable>from_multiconfig</replaceable>:<replaceable>to_multiconfig</replaceable>:<replaceable>recipe_name</replaceable>:<replaceable>task_or_package_on_which_to_depend</replaceable>"
  5100. </literallayout>
  5101. <note>
  5102. Dependencies can be on tasks or packages.
  5103. </note>
  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 and <filename>mkefidisk.sh</filename> script.
  6783. The difference between
  6784. Wic and those examples is
  6785. that with Wic the
  6786. functionality of those scripts is implemented
  6787. by a general-purpose partitioning language, which is
  6788. based on Redhat kickstart syntax.</para></listitem>
  6789. </itemizedlist>
  6790. </para>
  6791. </section>
  6792. <section id='wic-requirements'>
  6793. <title>Requirements</title>
  6794. <para>
  6795. In order to use the Wic utility with the OpenEmbedded Build
  6796. system, your system needs to meet the following
  6797. requirements:
  6798. <itemizedlist>
  6799. <listitem><para>
  6800. The Linux distribution on your development host must
  6801. support the Yocto Project.
  6802. See the
  6803. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  6804. section in the Yocto Project Reference Manual for
  6805. the list of distributions that support the
  6806. Yocto Project.
  6807. </para></listitem>
  6808. <listitem><para>
  6809. The standard system utilities, such as
  6810. <filename>cp</filename>, must be installed on your
  6811. development host system.
  6812. </para></listitem>
  6813. <listitem><para>
  6814. You must have sourced the build environment
  6815. setup script (i.e.
  6816. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  6817. found in the
  6818. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6819. </para></listitem>
  6820. <listitem><para>
  6821. You need to have the build artifacts already
  6822. available, which typically means that you must
  6823. have already created an image using the
  6824. Openembedded build system (e.g.
  6825. <filename>core-image-minimal</filename>).
  6826. While it might seem redundant to generate an image
  6827. in order to create an image using
  6828. Wic, the current version of
  6829. Wic requires the artifacts
  6830. in the form generated by the OpenEmbedded build
  6831. system.
  6832. </para></listitem>
  6833. <listitem><para>
  6834. You must build several native tools, which are
  6835. built to run on the build system:
  6836. <literallayout class='monospaced'>
  6837. $ bitbake parted-native dosfstools-native mtools-native
  6838. </literallayout>
  6839. </para></listitem>
  6840. <listitem><para>
  6841. Include "wic" as part of the
  6842. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  6843. variable.
  6844. </para></listitem>
  6845. <listitem><para>
  6846. Include the name of the
  6847. <ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>wic kickstart file</ulink>
  6848. as part of the
  6849. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink>
  6850. variable
  6851. </para></listitem>
  6852. </itemizedlist>
  6853. </para>
  6854. </section>
  6855. <section id='wic-getting-help'>
  6856. <title>Getting Help</title>
  6857. <para>
  6858. You can get general help for the <filename>wic</filename>
  6859. command by entering the <filename>wic</filename> command
  6860. by itself or by entering the command with a help argument
  6861. as follows:
  6862. <literallayout class='monospaced'>
  6863. $ wic -h
  6864. $ wic --help
  6865. $ wic help
  6866. </literallayout>
  6867. </para>
  6868. <para>
  6869. Currently, Wic supports seven commands:
  6870. <filename>cp</filename>, <filename>create</filename>,
  6871. <filename>help</filename>, <filename>list</filename>,
  6872. <filename>ls</filename>, <filename>rm</filename>, and
  6873. <filename>write</filename>.
  6874. You can get help for all these commands except "help" by
  6875. using the following form:
  6876. <literallayout class='monospaced'>
  6877. $ wic help <replaceable>command</replaceable>
  6878. </literallayout>
  6879. For example, the following command returns help for the
  6880. <filename>write</filename> command:
  6881. <literallayout class='monospaced'>
  6882. $ wic help write
  6883. </literallayout>
  6884. </para>
  6885. <para>
  6886. Wic supports help for three topics:
  6887. <filename>overview</filename>,
  6888. <filename>plugins</filename>, and
  6889. <filename>kickstart</filename>.
  6890. You can get help for any topic using the following form:
  6891. <literallayout class='monospaced'>
  6892. $ wic help <replaceable>topic</replaceable>
  6893. </literallayout>
  6894. For example, the following returns overview help for Wic:
  6895. <literallayout class='monospaced'>
  6896. $ wic help overview
  6897. </literallayout>
  6898. </para>
  6899. <para>
  6900. One additional level of help exists for Wic.
  6901. You can get help on individual images through the
  6902. <filename>list</filename> command.
  6903. You can use the <filename>list</filename> command to return the
  6904. available Wic images as follows:
  6905. <literallayout class='monospaced'>
  6906. $ wic list images
  6907. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  6908. genericx86 Create an EFI disk image for genericx86*
  6909. beaglebone-yocto Create SD card image for Beaglebone
  6910. edgerouter Create SD card image for Edgerouter
  6911. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  6912. directdisk-gpt Create a 'pcbios' direct disk image
  6913. mkefidisk Create an EFI disk image
  6914. directdisk Create a 'pcbios' direct disk image
  6915. systemd-bootdisk Create an EFI disk image with systemd-boot
  6916. mkhybridiso Create a hybrid ISO image
  6917. sdimage-bootpart Create SD card image with a boot partition
  6918. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  6919. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  6920. </literallayout>
  6921. Once you know the list of available Wic images, you can use
  6922. <filename>help</filename> with the command to get help on a
  6923. particular image.
  6924. For example, the following command returns help on the
  6925. "beaglebone-yocto" image:
  6926. <literallayout class='monospaced'>
  6927. $ wic list beaglebone-yocto help
  6928. Creates a partitioned SD card image for Beaglebone.
  6929. Boot files are located in the first vfat partition.
  6930. </literallayout>
  6931. </para>
  6932. </section>
  6933. <section id='operational-modes'>
  6934. <title>Operational Modes</title>
  6935. <para>
  6936. You can use Wic in two different
  6937. modes, depending on how much control you need for
  6938. specifying the Openembedded build artifacts that are
  6939. used for creating the image: Raw and Cooked:
  6940. <itemizedlist>
  6941. <listitem><para>
  6942. <emphasis>Raw Mode:</emphasis>
  6943. You explicitly specify build artifacts through
  6944. Wic command-line arguments.
  6945. </para></listitem>
  6946. <listitem><para>
  6947. <emphasis>Cooked Mode:</emphasis>
  6948. The current
  6949. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6950. setting and image name are used to automatically
  6951. locate and provide the build artifacts.
  6952. You just supply a kickstart file and the name
  6953. of the image from which to use artifacts.
  6954. </para></listitem>
  6955. </itemizedlist>
  6956. </para>
  6957. <para>
  6958. Regardless of the mode you use, you need to have the build
  6959. artifacts ready and available.
  6960. </para>
  6961. <section id='raw-mode'>
  6962. <title>Raw Mode</title>
  6963. <para>
  6964. Running Wic in raw mode allows you to specify all the
  6965. partitions through the <filename>wic</filename>
  6966. command line.
  6967. The primary use for raw mode is if you have built
  6968. your kernel outside of the Yocto Project
  6969. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  6970. In other words, you can point to arbitrary kernel,
  6971. root filesystem locations, and so forth.
  6972. Contrast this behavior with cooked mode where Wic
  6973. looks in the Build Directory (e.g.
  6974. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>).
  6975. </para>
  6976. <para>
  6977. The general form of the
  6978. <filename>wic</filename> command in raw mode is:
  6979. <literallayout class='monospaced'>
  6980. $ wic create <replaceable>wks_file</replaceable> <replaceable>options</replaceable> ...
  6981. Where:
  6982. <replaceable>wks_file</replaceable>:
  6983. An OpenEmbedded kickstart file. You can provide
  6984. your own custom file or use a file from a set of
  6985. existing files as described by further options.
  6986. optional arguments:
  6987. -h, --help show this help message and exit
  6988. -o <replaceable>OUTDIR</replaceable>, --outdir <replaceable>OUTDIR</replaceable>
  6989. name of directory to create image in
  6990. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  6991. name of the image to use the artifacts from e.g. core-
  6992. image-sato
  6993. -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir <replaceable>ROOTFS_DIR</replaceable>
  6994. path to the /rootfs dir to use as the .wks rootfs
  6995. source
  6996. -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir <replaceable>BOOTIMG_DIR</replaceable>
  6997. path to the dir containing the boot artifacts (e.g.
  6998. /EFI or /syslinux dirs) to use as the .wks bootimg
  6999. source
  7000. -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir <replaceable>KERNEL_DIR</replaceable>
  7001. path to the dir containing the kernel to use in the
  7002. .wks bootimg
  7003. -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot <replaceable>NATIVE_SYSROOT</replaceable>
  7004. path to the native sysroot containing the tools to use
  7005. to build the image
  7006. -s, --skip-build-check
  7007. skip the build check
  7008. -f, --build-rootfs build rootfs
  7009. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  7010. compress image with specified compressor
  7011. -m, --bmap generate .bmap
  7012. --no-fstab-update Do not change fstab file.
  7013. -v <replaceable>VARS_DIR</replaceable>, --vars <replaceable>VARS_DIR</replaceable>
  7014. directory with &lt;image&gt;.env files that store bitbake
  7015. variables
  7016. -D, --debug output debug information
  7017. </literallayout>
  7018. <note>
  7019. You do not need root privileges to run
  7020. Wic.
  7021. In fact, you should not run as root when using the
  7022. utility.
  7023. </note>
  7024. </para>
  7025. </section>
  7026. <section id='cooked-mode'>
  7027. <title>Cooked Mode</title>
  7028. <para>
  7029. Running Wic in cooked mode leverages off artifacts in
  7030. the Build Directory.
  7031. In other words, you do not have to specify kernel or
  7032. root filesystem locations as part of the command.
  7033. All you need to provide is a kickstart file and the
  7034. name of the image from which to use artifacts by using
  7035. the "-e" option.
  7036. Wic looks in the Build Directory (e.g.
  7037. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>)
  7038. for artifacts.
  7039. </para>
  7040. <para>
  7041. The general form of the <filename>wic</filename>
  7042. command using Cooked Mode is as follows:
  7043. <literallayout class='monospaced'>
  7044. $ wic create <replaceable>wks_file</replaceable> -e <replaceable>IMAGE_NAME</replaceable>
  7045. Where:
  7046. <replaceable>wks_file</replaceable>:
  7047. An OpenEmbedded kickstart file. You can provide
  7048. your own custom file or use a file from a set of
  7049. existing files provided with the Yocto Project
  7050. release.
  7051. required argument:
  7052. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  7053. name of the image to use the artifacts from e.g. core-
  7054. image-sato
  7055. </literallayout>
  7056. </para>
  7057. </section>
  7058. </section>
  7059. <section id='using-a-provided-kickstart-file'>
  7060. <title>Using an Existing Kickstart File</title>
  7061. <para>
  7062. If you do not want to create your own kickstart file, you
  7063. can use an existing file provided by the Wic installation.
  7064. As shipped, kickstart files can be found in the
  7065. Yocto Project
  7066. <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink>
  7067. in the following two locations:
  7068. <literallayout class='monospaced'>
  7069. poky/meta-yocto-bsp/wic
  7070. poky/scripts/lib/wic/canned-wks
  7071. </literallayout>
  7072. Use the following command to list the available kickstart
  7073. files:
  7074. <literallayout class='monospaced'>
  7075. $ wic list images
  7076. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  7077. genericx86 Create an EFI disk image for genericx86*
  7078. beaglebone-yocto Create SD card image for Beaglebone
  7079. edgerouter Create SD card image for Edgerouter
  7080. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  7081. directdisk-gpt Create a 'pcbios' direct disk image
  7082. mkefidisk Create an EFI disk image
  7083. directdisk Create a 'pcbios' direct disk image
  7084. systemd-bootdisk Create an EFI disk image with systemd-boot
  7085. mkhybridiso Create a hybrid ISO image
  7086. sdimage-bootpart Create SD card image with a boot partition
  7087. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  7088. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  7089. </literallayout>
  7090. When you use an existing file, you do not have to use the
  7091. <filename>.wks</filename> extension.
  7092. Here is an example in Raw Mode that uses the
  7093. <filename>directdisk</filename> file:
  7094. <literallayout class='monospaced'>
  7095. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  7096. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  7097. </literallayout>
  7098. </para>
  7099. <para>
  7100. Here are the actual partition language commands
  7101. used in the <filename>genericx86.wks</filename> file to
  7102. generate an image:
  7103. <literallayout class='monospaced'>
  7104. # short-description: Create an EFI disk image for genericx86*
  7105. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  7106. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  7107. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  7108. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  7109. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  7110. </literallayout>
  7111. </para>
  7112. </section>
  7113. <section id='wic-using-the-wic-plug-ins-interface'>
  7114. <title>Using the Wic Plug-Ins Interface</title>
  7115. <para>
  7116. You can extend and specialize Wic functionality by using
  7117. Wic plug-ins.
  7118. This section explains the Wic plug-in interface.
  7119. <note>
  7120. Wic plug-ins consist of "source" and "imager" plug-ins.
  7121. Imager plug-ins are beyond the scope of this section.
  7122. </note>
  7123. </para>
  7124. <para>
  7125. Source plug-ins provide a mechanism to customize partition
  7126. content during the Wic image generation process.
  7127. You can use source plug-ins to map values that you specify
  7128. using <filename>--source</filename> commands in kickstart
  7129. files (i.e. <filename>*.wks</filename>) to a plug-in
  7130. implementation used to populate a given partition.
  7131. <note>
  7132. If you use plug-ins that have build-time dependencies
  7133. (e.g. native tools, bootloaders, and so forth)
  7134. when building a Wic image, you need to specify those
  7135. dependencies using the
  7136. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink>
  7137. variable.
  7138. </note>
  7139. </para>
  7140. <para>
  7141. Source plug-ins are subclasses defined in plug-in files.
  7142. As shipped, the Yocto Project provides several plug-in
  7143. files.
  7144. You can see the source plug-in files that ship with the
  7145. Yocto Project
  7146. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>.
  7147. Each of these plug-in files contains source plug-ins that
  7148. are designed to populate a specific Wic image partition.
  7149. </para>
  7150. <para>
  7151. Source plug-ins are subclasses of the
  7152. <filename>SourcePlugin</filename> class, which is
  7153. defined in the
  7154. <filename>poky/scripts/lib/wic/pluginbase.py</filename>
  7155. file.
  7156. For example, the <filename>BootimgEFIPlugin</filename>
  7157. source plug-in found in the
  7158. <filename>bootimg-efi.py</filename> file is a subclass of
  7159. the <filename>SourcePlugin</filename> class, which is found
  7160. in the <filename>pluginbase.py</filename> file.
  7161. </para>
  7162. <para>
  7163. You can also implement source plug-ins in a layer outside
  7164. of the Source Repositories (external layer).
  7165. To do so, be sure that your plug-in files are located in
  7166. a directory whose path is
  7167. <filename>scripts/lib/wic/plugins/source/</filename>
  7168. within your external layer.
  7169. When the plug-in files are located there, the source
  7170. plug-ins they contain are made available to Wic.
  7171. </para>
  7172. <para>
  7173. When the Wic implementation needs to invoke a
  7174. partition-specific implementation, it looks for the plug-in
  7175. with the same name as the <filename>--source</filename>
  7176. parameter used in the kickstart file given to that
  7177. partition.
  7178. For example, if the partition is set up using the following
  7179. command in a kickstart file:
  7180. <literallayout class='monospaced'>
  7181. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  7182. </literallayout>
  7183. The methods defined as class members of the matching
  7184. source plug-in (i.e. <filename>bootimg-pcbios</filename>)
  7185. in the <filename>bootimg-pcbios.py</filename> plug-in file
  7186. are used.
  7187. </para>
  7188. <para>
  7189. To be more concrete, here is the corresponding plug-in
  7190. definition from the <filename>bootimg-pcbios.py</filename>
  7191. file for the previous command along with an example
  7192. method called by the Wic implementation when it needs to
  7193. prepare a partition using an implementation-specific
  7194. function:
  7195. <literallayout class='monospaced'>
  7196. .
  7197. .
  7198. .
  7199. class BootimgPcbiosPlugin(SourcePlugin):
  7200. """
  7201. Create MBR boot partition and install syslinux on it.
  7202. """
  7203. name = 'bootimg-pcbios'
  7204. .
  7205. .
  7206. .
  7207. @classmethod
  7208. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  7209. oe_builddir, bootimg_dir, kernel_dir,
  7210. rootfs_dir, native_sysroot):
  7211. """
  7212. Called to do the actual content population for a partition i.e. it
  7213. 'prepares' the partition to be incorporated into the image.
  7214. In this case, prepare content for legacy bios boot partition.
  7215. """
  7216. .
  7217. .
  7218. .
  7219. </literallayout>
  7220. If a subclass (plug-in) itself does not implement a
  7221. particular function, Wic locates and uses the default
  7222. version in the superclass.
  7223. It is for this reason that all source plug-ins are derived
  7224. from the <filename>SourcePlugin</filename> class.
  7225. </para>
  7226. <para>
  7227. The <filename>SourcePlugin</filename> class defined in
  7228. the <filename>pluginbase.py</filename> file defines
  7229. a set of methods that source plug-ins can implement or
  7230. override.
  7231. Any plug-ins (subclass of
  7232. <filename>SourcePlugin</filename>) that do not implement
  7233. a particular method inherit the implementation of the
  7234. method from the <filename>SourcePlugin</filename> class.
  7235. For more information, see the
  7236. <filename>SourcePlugin</filename> class in the
  7237. <filename>pluginbase.py</filename> file for details:
  7238. </para>
  7239. <para>
  7240. The following list describes the methods implemented in the
  7241. <filename>SourcePlugin</filename> class:
  7242. <itemizedlist>
  7243. <listitem><para>
  7244. <emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  7245. Called to populate a partition with actual content.
  7246. In other words, the method prepares the final
  7247. partition image that is incorporated into the
  7248. disk image.
  7249. </para></listitem>
  7250. <listitem><para>
  7251. <emphasis><filename>do_configure_partition()</filename>:</emphasis>
  7252. Called before
  7253. <filename>do_prepare_partition()</filename> to
  7254. create custom configuration files for a partition
  7255. (e.g. syslinux or grub configuration files).
  7256. </para></listitem>
  7257. <listitem><para>
  7258. <emphasis><filename>do_install_disk()</filename>:</emphasis>
  7259. Called after all partitions have been prepared and
  7260. assembled into a disk image.
  7261. This method provides a hook to allow finalization
  7262. of a disk image (e.g. writing an MBR).
  7263. </para></listitem>
  7264. <listitem><para>
  7265. <emphasis><filename>do_stage_partition()</filename>:</emphasis>
  7266. Special content-staging hook called before
  7267. <filename>do_prepare_partition()</filename>.
  7268. This method is normally empty.</para>
  7269. <para>Typically, a partition just uses the passed-in
  7270. parameters (e.g. the unmodified value of
  7271. <filename>bootimg_dir</filename>).
  7272. However, in some cases, things might need to be
  7273. more tailored.
  7274. As an example, certain files might additionally
  7275. need to be taken from
  7276. <filename>bootimg_dir + /boot</filename>.
  7277. This hook allows those files to be staged in a
  7278. customized fashion.
  7279. <note>
  7280. <filename>get_bitbake_var()</filename>
  7281. allows you to access non-standard variables
  7282. that you might want to use for this
  7283. behavior.
  7284. </note>
  7285. </para></listitem>
  7286. </itemizedlist>
  7287. </para>
  7288. <para>
  7289. You can extend the source plug-in mechanism.
  7290. To add more hooks, create more source plug-in methods
  7291. within <filename>SourcePlugin</filename> and the
  7292. corresponding derived subclasses.
  7293. The code that calls the plug-in methods uses the
  7294. <filename>plugin.get_source_plugin_methods()</filename>
  7295. function to find the method or methods needed by the call.
  7296. Retrieval of those methods is accomplished by filling up
  7297. a dict with keys that contain the method names of interest.
  7298. On success, these will be filled in with the actual
  7299. methods.
  7300. See the Wic implementation for examples and details.
  7301. </para>
  7302. </section>
  7303. <section id='wic-usage-examples'>
  7304. <title>Examples</title>
  7305. <para>
  7306. This section provides several examples that show how to use
  7307. the Wic utility.
  7308. All the examples assume the list of requirements in the
  7309. "<link linkend='wic-requirements'>Requirements</link>"
  7310. section have been met.
  7311. The examples assume the previously generated image is
  7312. <filename>core-image-minimal</filename>.
  7313. </para>
  7314. <section id='generate-an-image-using-a-provided-kickstart-file'>
  7315. <title>Generate an Image using an Existing Kickstart File</title>
  7316. <para>
  7317. This example runs in Cooked Mode and uses the
  7318. <filename>mkefidisk</filename> kickstart file:
  7319. <literallayout class='monospaced'>
  7320. $ wic create mkefidisk -e core-image-minimal
  7321. INFO: Building wic-tools...
  7322. .
  7323. .
  7324. .
  7325. INFO: The new image(s) can be found here:
  7326. ./mkefidisk-201804191017-sda.direct
  7327. The following build artifacts were used to create the image(s):
  7328. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  7329. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  7330. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  7331. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7332. INFO: The image(s) were created using OE kickstart file:
  7333. /home/stephano/build/master/openembedded-core/scripts/lib/wic/canned-wks/mkefidisk.wks
  7334. </literallayout>
  7335. The previous example shows the easiest way to create
  7336. an image by running in cooked mode and supplying
  7337. a kickstart file and the "-e" option to point to the
  7338. existing build artifacts.
  7339. Your <filename>local.conf</filename> file needs to have
  7340. the
  7341. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7342. variable set to the machine you are using, which is
  7343. "qemux86" in this example.
  7344. </para>
  7345. <para>
  7346. Once the image builds, the output provides image
  7347. location, artifact use, and kickstart file information.
  7348. <note>
  7349. You should always verify the details provided in the
  7350. output to make sure that the image was indeed
  7351. created exactly as expected.
  7352. </note>
  7353. </para>
  7354. <para>
  7355. Continuing with the example, you can now write the
  7356. image from the Build Directory onto a USB stick, or
  7357. whatever media for which you built your image, and boot
  7358. from the media.
  7359. You can write the image by using
  7360. <filename>bmaptool</filename> or
  7361. <filename>dd</filename>:
  7362. <literallayout class='monospaced'>
  7363. $ oe-run-native bmaptool copy mkefidisk-201804191017-sda.direct /dev/sd<replaceable>X</replaceable>
  7364. </literallayout>
  7365. or
  7366. <literallayout class='monospaced'>
  7367. $ sudo dd if=mkefidisk-201804191017-sda.direct of=/dev/sd<replaceable>X</replaceable>
  7368. </literallayout>
  7369. <note>
  7370. For more information on how to use the
  7371. <filename>bmaptool</filename> to flash a device
  7372. with an image, see the
  7373. "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>"
  7374. section.
  7375. </note>
  7376. </para>
  7377. </section>
  7378. <section id='using-a-modified-kickstart-file'>
  7379. <title>Using a Modified Kickstart File</title>
  7380. <para>
  7381. Because partitioned image creation is driven by the
  7382. kickstart file, it is easy to affect image creation by
  7383. changing the parameters in the file.
  7384. This next example demonstrates that through modification
  7385. of the <filename>directdisk-gpt</filename> kickstart
  7386. file.
  7387. </para>
  7388. <para>
  7389. As mentioned earlier, you can use the command
  7390. <filename>wic list images</filename> to show the list
  7391. of existing kickstart files.
  7392. The directory in which the
  7393. <filename>directdisk-gpt.wks</filename> file resides is
  7394. <filename>scripts/lib/image/canned-wks/</filename>,
  7395. which is located in the
  7396. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  7397. (e.g. <filename>poky</filename>).
  7398. Because available files reside in this directory,
  7399. you can create and add your own custom files to the
  7400. directory.
  7401. Subsequent use of the
  7402. <filename>wic list images</filename> command would then
  7403. include your kickstart files.
  7404. </para>
  7405. <para>
  7406. In this example, the existing
  7407. <filename>directdisk-gpt</filename> file already does
  7408. most of what is needed.
  7409. However, for the hardware in this example, the image
  7410. will need to boot from <filename>sdb</filename> instead
  7411. of <filename>sda</filename>, which is what the
  7412. <filename>directdisk-gpt</filename> kickstart file
  7413. uses.
  7414. </para>
  7415. <para>
  7416. The example begins by making a copy of the
  7417. <filename>directdisk-gpt.wks</filename> file in the
  7418. <filename>scripts/lib/image/canned-wks</filename>
  7419. directory and then by changing the lines that specify
  7420. the target disk from which to boot.
  7421. <literallayout class='monospaced'>
  7422. $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  7423. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  7424. </literallayout>
  7425. Next, the example modifies the
  7426. <filename>directdisksdb-gpt.wks</filename> file and
  7427. changes all instances of
  7428. "<filename>--ondisk sda</filename>" to
  7429. "<filename>--ondisk sdb</filename>".
  7430. The example changes the following two lines and leaves
  7431. the remaining lines untouched:
  7432. <literallayout class='monospaced'>
  7433. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  7434. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  7435. </literallayout>
  7436. Once the lines are changed, the example generates the
  7437. <filename>directdisksdb-gpt</filename> image.
  7438. The command points the process at the
  7439. <filename>core-image-minimal</filename> artifacts for
  7440. the Next Unit of Computing (nuc)
  7441. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7442. the <filename>local.conf</filename>.
  7443. <literallayout class='monospaced'>
  7444. $ wic create directdisksdb-gpt -e core-image-minimal
  7445. INFO: Building wic-tools...
  7446. .
  7447. .
  7448. .
  7449. Initialising tasks: 100% |#######################################| Time: 0:00:01
  7450. NOTE: Executing SetScene Tasks
  7451. NOTE: Executing RunQueue Tasks
  7452. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  7453. INFO: Creating image(s)...
  7454. INFO: The new image(s) can be found here:
  7455. ./directdisksdb-gpt-201710090938-sdb.direct
  7456. The following build artifacts were used to create the image(s):
  7457. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  7458. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  7459. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  7460. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7461. INFO: The image(s) were created using OE kickstart file:
  7462. /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  7463. </literallayout>
  7464. Continuing with the example, you can now directly
  7465. <filename>dd</filename> the image to a USB stick, or
  7466. whatever media for which you built your image,
  7467. and boot the resulting media:
  7468. <literallayout class='monospaced'>
  7469. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  7470. 140966+0 records in
  7471. 140966+0 records out
  7472. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  7473. $ sudo eject /dev/sdb
  7474. </literallayout>
  7475. </para>
  7476. </section>
  7477. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  7478. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  7479. <para>
  7480. This next example manually specifies each build artifact
  7481. (runs in Raw Mode) and uses a modified kickstart file.
  7482. The example also uses the <filename>-o</filename> option
  7483. to cause Wic to create the output
  7484. somewhere other than the default output directory,
  7485. which is the current directory:
  7486. <literallayout class='monospaced'>
  7487. $ wic create /home/stephano/my_yocto/test.wks -o /home/stephano/testwic \
  7488. --rootfs-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  7489. --bootimg-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  7490. --kernel-dir /home/stephano/build/master/build/tmp/deploy/images/qemux86 \
  7491. --native-sysroot /home/stephano/build/master/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7492. INFO: Creating image(s)...
  7493. INFO: The new image(s) can be found here:
  7494. /home/stephano/testwic/test-201710091445-sdb.direct
  7495. The following build artifacts were used to create the image(s):
  7496. ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  7497. BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  7498. KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
  7499. NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  7500. INFO: The image(s) were created using OE kickstart file:
  7501. /home/stephano/my_yocto/test.wks
  7502. </literallayout>
  7503. For this example,
  7504. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7505. did not have to be specified in the
  7506. <filename>local.conf</filename> file since the
  7507. artifact is manually specified.
  7508. </para>
  7509. </section>
  7510. <section id='using-wic-to-manipulate-an-image'>
  7511. <title>Using Wic to Manipulate an Image</title>
  7512. <para>
  7513. Wic image manipulation allows you to shorten turnaround
  7514. time during image development.
  7515. For example, you can use Wic to delete the kernel partition
  7516. of a Wic image and then insert a newly built kernel.
  7517. This saves you time from having to rebuild the entire image
  7518. each time you modify the kernel.
  7519. <note>
  7520. In order to use Wic to manipulate a Wic image as in
  7521. this example, your development machine must have the
  7522. <filename>mtools</filename> package installed.
  7523. </note>
  7524. </para>
  7525. <para>
  7526. The following example examines the contents of the Wic
  7527. image, deletes the existing kernel, and then inserts a
  7528. new kernel:
  7529. <orderedlist>
  7530. <listitem><para>
  7531. <emphasis>List the Partitions:</emphasis>
  7532. Use the <filename>wic ls</filename> command to list
  7533. all the partitions in the Wic image:
  7534. <literallayout class='monospaced'>
  7535. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  7536. Num Start End Size Fstype
  7537. 1 1048576 25041919 23993344 fat16
  7538. 2 25165824 72157183 46991360 ext4
  7539. </literallayout>
  7540. The previous output shows two partitions in the
  7541. <filename>core-image-minimal-qemux86.wic</filename>
  7542. image.
  7543. </para></listitem>
  7544. <listitem><para>
  7545. <emphasis>Examine a Particular Partition:</emphasis>
  7546. Use the <filename>wic ls</filename> command again
  7547. but in a different form to examine a particular
  7548. partition.
  7549. <note>
  7550. You can get command usage on any Wic command
  7551. using the following form:
  7552. <literallayout class='monospaced'>
  7553. $ wic help <replaceable>command</replaceable>
  7554. </literallayout>
  7555. For example, the following command shows you
  7556. the various ways to use the
  7557. <filename>wic ls</filename> command:
  7558. <literallayout class='monospaced'>
  7559. $ wic help ls
  7560. </literallayout>
  7561. </note>
  7562. The following command shows what is in Partition
  7563. one:
  7564. <literallayout class='monospaced'>
  7565. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  7566. Volume in drive : is boot
  7567. Volume Serial Number is E894-1809
  7568. Directory for ::/
  7569. libcom32 c32 186500 2017-10-09 16:06
  7570. libutil c32 24148 2017-10-09 16:06
  7571. syslinux cfg 220 2017-10-09 16:06
  7572. vesamenu c32 27104 2017-10-09 16:06
  7573. vmlinuz 6904608 2017-10-09 16:06
  7574. 5 files 7 142 580 bytes
  7575. 16 582 656 bytes free
  7576. </literallayout>
  7577. The previous output shows five files, with the
  7578. <filename>vmlinuz</filename> being the kernel.
  7579. <note>
  7580. If you see the following error, you need to
  7581. update or create a
  7582. <filename>~/.mtoolsrc</filename> file and
  7583. be sure to have the line “mtools_skip_check=1“
  7584. in the file.
  7585. Then, run the Wic command again:
  7586. <literallayout class='monospaced'>
  7587. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  7588. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  7589. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  7590. </literallayout>
  7591. </note>
  7592. </para></listitem>
  7593. <listitem><para>
  7594. <emphasis>Remove the Old Kernel:</emphasis>
  7595. Use the <filename>wic rm</filename> command to
  7596. remove the <filename>vmlinuz</filename> file
  7597. (kernel):
  7598. <literallayout class='monospaced'>
  7599. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  7600. </literallayout>
  7601. </para></listitem>
  7602. <listitem><para>
  7603. <emphasis>Add In the New Kernel:</emphasis>
  7604. Use the <filename>wic cp</filename> command to
  7605. add the updated kernel to the Wic image.
  7606. Depending on how you built your kernel, it could
  7607. be in different places.
  7608. If you used <filename>devtool</filename> and
  7609. an SDK to build your kernel, it resides in the
  7610. <filename>tmp/work</filename> directory of the
  7611. extensible SDK.
  7612. If you used <filename>make</filename> to build the
  7613. kernel, the kernel will be in the
  7614. <filename>workspace/sources</filename> area.
  7615. </para>
  7616. <para>The following example assumes
  7617. <filename>devtool</filename> was used to build
  7618. the kernel:
  7619. <literallayout class='monospaced'>
  7620. 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 \
  7621. ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  7622. </literallayout>
  7623. Once the new kernel is added back into the image,
  7624. you can use the <filename>dd</filename>
  7625. command or
  7626. <link linkend='flashing-images-using-bmaptool'><filename>bmaptool</filename></link>
  7627. to flash your wic image onto an SD card
  7628. or USB stick and test your target.
  7629. <note>
  7630. Using <filename>bmaptool</filename> is
  7631. generally 10 to 20 times faster than using
  7632. <filename>dd</filename>.
  7633. </note>
  7634. </para></listitem>
  7635. </orderedlist>
  7636. </para>
  7637. </section>
  7638. </section>
  7639. </section>
  7640. <section id='flashing-images-using-bmaptool'>
  7641. <title>Flashing Images Using <filename>bmaptool</filename></title>
  7642. <para>
  7643. A fast and easy way to flash an image to a bootable device
  7644. is to use Bmaptool, which is integrated into the OpenEmbedded
  7645. build system.
  7646. Bmaptool is a generic tool that creates a file's block map (bmap)
  7647. and then uses that map to copy the file.
  7648. As compared to traditional tools such as dd or cp, Bmaptool
  7649. can copy (or flash) large files like raw system image files
  7650. much faster.
  7651. <note><title>Notes</title>
  7652. <itemizedlist>
  7653. <listitem><para>
  7654. If you are using Ubuntu or Debian distributions, you
  7655. can install the <filename>bmap-tools</filename> package
  7656. using the following command and then use the tool
  7657. without specifying <filename>PATH</filename> even from
  7658. the root account:
  7659. <literallayout class='monospaced'>
  7660. $ sudo apt-get install bmap-tools
  7661. </literallayout>
  7662. </para></listitem>
  7663. <listitem><para>
  7664. If you are unable to install the
  7665. <filename>bmap-tools</filename> package, you will
  7666. need to build Bmaptool before using it.
  7667. Use the following command:
  7668. <literallayout class='monospaced'>
  7669. $ bitbake bmap-tools-native
  7670. </literallayout>
  7671. </para></listitem>
  7672. </itemizedlist>
  7673. </note>
  7674. </para>
  7675. <para>
  7676. Following, is an example that shows how to flash a Wic image.
  7677. Realize that while this example uses a Wic image, you can use
  7678. Bmaptool to flash any type of image.
  7679. Use these steps to flash an image using Bmaptool:
  7680. <orderedlist>
  7681. <listitem><para>
  7682. <emphasis>Update your <filename>local.conf</filename> File:</emphasis>
  7683. You need to have the following set in your
  7684. <filename>local.conf</filename> file before building
  7685. your image:
  7686. <literallayout class='monospaced'>
  7687. IMAGE_FSTYPES += "wic wic.bmap"
  7688. </literallayout>
  7689. </para></listitem>
  7690. <listitem><para>
  7691. <emphasis>Get Your Image:</emphasis>
  7692. Either have your image ready (pre-built with the
  7693. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  7694. setting previously mentioned) or take the step to build
  7695. the image:
  7696. <literallayout class='monospaced'>
  7697. $ bitbake <replaceable>image</replaceable>
  7698. </literallayout>
  7699. </para></listitem>
  7700. <listitem><para>
  7701. <emphasis>Flash the Device:</emphasis>
  7702. Flash the device with the image by using Bmaptool
  7703. depending on your particular setup.
  7704. The following commands assume the image resides in the
  7705. Build Directory's <filename>deploy/images/</filename>
  7706. area:
  7707. <itemizedlist>
  7708. <listitem><para>
  7709. If you have write access to the media, use this
  7710. command form:
  7711. <literallayout class='monospaced'>
  7712. $ 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>
  7713. </literallayout>
  7714. </para></listitem>
  7715. <listitem><para>
  7716. If you do not have write access to the media, set
  7717. your permissions first and then use the same
  7718. command form:
  7719. <literallayout class='monospaced'>
  7720. $ sudo chmod 666 /dev/sd<replaceable>X</replaceable>
  7721. $ 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>
  7722. </literallayout>
  7723. </para></listitem>
  7724. </itemizedlist>
  7725. </para></listitem>
  7726. </orderedlist>
  7727. </para>
  7728. <para>
  7729. For help on the <filename>bmaptool</filename> command, use the
  7730. following command:
  7731. <literallayout class='monospaced'>
  7732. $ bmaptool --help
  7733. </literallayout>
  7734. </para>
  7735. </section>
  7736. <section id='making-images-more-secure'>
  7737. <title>Making Images More Secure</title>
  7738. <para>
  7739. Security is of increasing concern for embedded devices.
  7740. Consider the issues and problems discussed in just this
  7741. sampling of work found across the Internet:
  7742. <itemizedlist>
  7743. <listitem><para><emphasis>
  7744. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  7745. by Bruce Schneier
  7746. </para></listitem>
  7747. <listitem><para><emphasis>
  7748. "<ulink url='http://census2012.sourceforge.net/paper.html'>Internet Census 2012</ulink>"</emphasis>
  7749. by Carna Botnet</para></listitem>
  7750. <listitem><para><emphasis>
  7751. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  7752. by Jake Edge
  7753. </para></listitem>
  7754. </itemizedlist>
  7755. </para>
  7756. <para>
  7757. When securing your image is of concern, there are steps, tools,
  7758. and variables that you can consider to help you reach the
  7759. security goals you need for your particular device.
  7760. Not all situations are identical when it comes to making an
  7761. image secure.
  7762. Consequently, this section provides some guidance and suggestions
  7763. for consideration when you want to make your image more secure.
  7764. <note>
  7765. Because the security requirements and risks are
  7766. different for every type of device, this section cannot
  7767. provide a complete reference on securing your custom OS.
  7768. It is strongly recommended that you also consult other sources
  7769. of information on embedded Linux system hardening and on
  7770. security.
  7771. </note>
  7772. </para>
  7773. <section id='general-considerations'>
  7774. <title>General Considerations</title>
  7775. <para>
  7776. General considerations exist that help you create more
  7777. secure images.
  7778. You should consider the following suggestions to help
  7779. make your device more secure:
  7780. <itemizedlist>
  7781. <listitem><para>
  7782. Scan additional code you are adding to the system
  7783. (e.g. application code) by using static analysis
  7784. tools.
  7785. Look for buffer overflows and other potential
  7786. security problems.
  7787. </para></listitem>
  7788. <listitem><para>
  7789. Pay particular attention to the security for
  7790. any web-based administration interface.
  7791. </para>
  7792. <para>Web interfaces typically need to perform
  7793. administrative functions and tend to need to run with
  7794. elevated privileges.
  7795. Thus, the consequences resulting from the interface's
  7796. security becoming compromised can be serious.
  7797. Look for common web vulnerabilities such as
  7798. cross-site-scripting (XSS), unvalidated inputs,
  7799. and so forth.</para>
  7800. <para>As with system passwords, the default credentials
  7801. for accessing a web-based interface should not be the
  7802. same across all devices.
  7803. This is particularly true if the interface is enabled
  7804. by default as it can be assumed that many end-users
  7805. will not change the credentials.
  7806. </para></listitem>
  7807. <listitem><para>
  7808. Ensure you can update the software on the device to
  7809. mitigate vulnerabilities discovered in the future.
  7810. This consideration especially applies when your
  7811. device is network-enabled.
  7812. </para></listitem>
  7813. <listitem><para>
  7814. Ensure you remove or disable debugging functionality
  7815. before producing the final image.
  7816. For information on how to do this, see the
  7817. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  7818. section.
  7819. </para></listitem>
  7820. <listitem><para>
  7821. Ensure you have no network services listening that
  7822. are not needed.
  7823. </para></listitem>
  7824. <listitem><para>
  7825. Remove any software from the image that is not needed.
  7826. </para></listitem>
  7827. <listitem><para>
  7828. Enable hardware support for secure boot functionality
  7829. when your device supports this functionality.
  7830. </para></listitem>
  7831. </itemizedlist>
  7832. </para>
  7833. </section>
  7834. <section id='security-flags'>
  7835. <title>Security Flags</title>
  7836. <para>
  7837. The Yocto Project has security flags that you can enable that
  7838. help make your build output more secure.
  7839. The security flags are in the
  7840. <filename>meta/conf/distro/include/security_flags.inc</filename>
  7841. file in your
  7842. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  7843. (e.g. <filename>poky</filename>).
  7844. <note>
  7845. Depending on the recipe, certain security flags are enabled
  7846. and disabled by default.
  7847. </note>
  7848. </para>
  7849. <para>
  7850. <!--
  7851. The GCC/LD flags in <filename>security_flags.inc</filename>
  7852. enable more secure code generation.
  7853. By including the <filename>security_flags.inc</filename>
  7854. file, you enable flags to the compiler and linker that cause
  7855. them to generate more secure code.
  7856. <note>
  7857. The GCC/LD flags are enabled by default in the
  7858. <filename>poky-lsb</filename> distribution.
  7859. </note>
  7860. -->
  7861. Use the following line in your
  7862. <filename>local.conf</filename> file or in your custom
  7863. distribution configuration file to enable the security
  7864. compiler and linker flags for your build:
  7865. <literallayout class='monospaced'>
  7866. require conf/distro/include/security_flags.inc
  7867. </literallayout>
  7868. </para>
  7869. </section>
  7870. <section id='considerations-specific-to-the-openembedded-build-system'>
  7871. <title>Considerations Specific to the OpenEmbedded Build System</title>
  7872. <para>
  7873. You can take some steps that are specific to the
  7874. OpenEmbedded build system to make your images more secure:
  7875. <itemizedlist>
  7876. <listitem><para>
  7877. Ensure "debug-tweaks" is not one of your selected
  7878. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  7879. When creating a new project, the default is to provide you
  7880. with an initial <filename>local.conf</filename> file that
  7881. enables this feature using the
  7882. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  7883. <literallayout class='monospaced'>
  7884. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  7885. </literallayout>
  7886. To disable that feature, simply comment out that line in your
  7887. <filename>local.conf</filename> file, or
  7888. make sure <filename>IMAGE_FEATURES</filename> does not contain
  7889. "debug-tweaks" before producing your final image.
  7890. Among other things, leaving this in place sets the
  7891. root password as blank, which makes logging in for
  7892. debugging or inspection easy during
  7893. development but also means anyone can easily log in
  7894. during production.
  7895. </para></listitem>
  7896. <listitem><para>
  7897. It is possible to set a root password for the image
  7898. and also to set passwords for any extra users you might
  7899. add (e.g. administrative or service type users).
  7900. When you set up passwords for multiple images or
  7901. users, you should not duplicate passwords.
  7902. </para>
  7903. <para>
  7904. To set up passwords, use the
  7905. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  7906. class, which is the preferred method.
  7907. For an example on how to set up both root and user
  7908. passwords, see the
  7909. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  7910. section.
  7911. <note>
  7912. When adding extra user accounts or setting a
  7913. root password, be cautious about setting the
  7914. same password on every device.
  7915. If you do this, and the password you have set
  7916. is exposed, then every device is now potentially
  7917. compromised.
  7918. If you need this access but want to ensure
  7919. security, consider setting a different,
  7920. random password for each device.
  7921. Typically, you do this as a separate step after
  7922. you deploy the image onto the device.
  7923. </note>
  7924. </para></listitem>
  7925. <listitem><para>
  7926. Consider enabling a Mandatory Access Control (MAC)
  7927. framework such as SMACK or SELinux and tuning it
  7928. appropriately for your device's usage.
  7929. You can find more information in the
  7930. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink>
  7931. layer.
  7932. </para></listitem>
  7933. </itemizedlist>
  7934. </para>
  7935. <para>
  7936. </para>
  7937. </section>
  7938. <section id='tools-for-hardening-your-image'>
  7939. <title>Tools for Hardening Your Image</title>
  7940. <para>
  7941. The Yocto Project provides tools for making your image
  7942. more secure.
  7943. You can find these tools in the
  7944. <filename>meta-security</filename> layer of the
  7945. <ulink url='&YOCTO_GIT_URL;'>Yocto Project Source Repositories</ulink>.
  7946. </para>
  7947. </section>
  7948. </section>
  7949. <section id='creating-your-own-distribution'>
  7950. <title>Creating Your Own Distribution</title>
  7951. <para>
  7952. When you build an image using the Yocto Project and
  7953. do not alter any distribution
  7954. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  7955. you are creating a Poky distribution.
  7956. If you wish to gain more control over package alternative
  7957. selections, compile-time options, and other low-level
  7958. configurations, you can create your own distribution.
  7959. </para>
  7960. <para>
  7961. To create your own distribution, the basic steps consist of
  7962. creating your own distribution layer, creating your own
  7963. distribution configuration file, and then adding any needed
  7964. code and Metadata to the layer.
  7965. The following steps provide some more detail:
  7966. <itemizedlist>
  7967. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  7968. Create your distribution layer so that you can keep your
  7969. Metadata and code for the distribution separate.
  7970. It is strongly recommended that you create and use your own
  7971. layer for configuration and code.
  7972. Using your own layer as compared to just placing
  7973. configurations in a <filename>local.conf</filename>
  7974. configuration file makes it easier to reproduce the same
  7975. build configuration when using multiple build machines.
  7976. See the
  7977. "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>"
  7978. section for information on how to quickly set up a layer.
  7979. </para></listitem>
  7980. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  7981. The distribution configuration file needs to be created in
  7982. the <filename>conf/distro</filename> directory of your
  7983. layer.
  7984. You need to name it using your distribution name
  7985. (e.g. <filename>mydistro.conf</filename>).
  7986. <note>
  7987. The
  7988. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  7989. variable in your
  7990. <filename>local.conf</filename> file determines the
  7991. name of your distribution.
  7992. </note></para>
  7993. <para>You can split out parts of your configuration file
  7994. into include files and then "require" them from within
  7995. your distribution configuration file.
  7996. Be sure to place the include files in the
  7997. <filename>conf/distro/include</filename> directory of
  7998. your layer.
  7999. A common example usage of include files would be to
  8000. separate out the selection of desired version and revisions
  8001. for individual recipes.
  8002. </para>
  8003. <para>Your configuration file needs to set the following
  8004. required variables:
  8005. <literallayout class='monospaced'>
  8006. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  8007. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  8008. </literallayout>
  8009. These following variables are optional and you typically
  8010. set them from the distribution configuration file:
  8011. <literallayout class='monospaced'>
  8012. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  8013. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  8014. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  8015. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  8016. </literallayout>
  8017. <tip>
  8018. If you want to base your distribution configuration file
  8019. on the very basic configuration from OE-Core, you
  8020. can use
  8021. <filename>conf/distro/defaultsetup.conf</filename> as
  8022. a reference and just include variables that differ
  8023. as compared to <filename>defaultsetup.conf</filename>.
  8024. Alternatively, you can create a distribution
  8025. configuration file from scratch using the
  8026. <filename>defaultsetup.conf</filename> file
  8027. or configuration files from other distributions
  8028. such as Poky or Angstrom as references.
  8029. </tip></para></listitem>
  8030. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  8031. Be sure to define any other variables for which you want to
  8032. create a default or enforce as part of the distribution
  8033. configuration.
  8034. You can include nearly any variable from the
  8035. <filename>local.conf</filename> file.
  8036. The variables you use are not limited to the list in the
  8037. previous bulleted item.</para></listitem>
  8038. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  8039. In your <filename>local.conf</filename> file in the
  8040. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  8041. set your
  8042. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  8043. variable to point to your distribution's configuration file.
  8044. For example, if your distribution's configuration file is
  8045. named <filename>mydistro.conf</filename>, then you point
  8046. to it as follows:
  8047. <literallayout class='monospaced'>
  8048. DISTRO = "mydistro"
  8049. </literallayout></para></listitem>
  8050. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  8051. Use your layer to hold other information needed for the
  8052. distribution:
  8053. <itemizedlist>
  8054. <listitem><para>Add recipes for installing
  8055. distro-specific configuration files that are not
  8056. already installed by another recipe.
  8057. If you have distro-specific configuration files
  8058. that are included by an existing recipe, you should
  8059. add an append file (<filename>.bbappend</filename>)
  8060. for those.
  8061. For general information and recommendations
  8062. on how to add recipes to your layer, see the
  8063. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  8064. and
  8065. "<link linkend='best-practices-to-follow-when-creating-layers'>Following Best Practices When Creating Layers</link>"
  8066. sections.</para></listitem>
  8067. <listitem><para>Add any image recipes that are specific
  8068. to your distribution.</para></listitem>
  8069. <listitem><para>Add a <filename>psplash</filename>
  8070. append file for a branded splash screen.
  8071. For information on append files, see the
  8072. "<link linkend='using-bbappend-files'>Using .bbappend Files in Your Layer</link>"
  8073. section.</para></listitem>
  8074. <listitem><para>Add any other append files to make
  8075. custom changes that are specific to individual
  8076. recipes.</para></listitem>
  8077. </itemizedlist></para></listitem>
  8078. </itemizedlist>
  8079. </para>
  8080. </section>
  8081. <section id='creating-a-custom-template-configuration-directory'>
  8082. <title>Creating a Custom Template Configuration Directory</title>
  8083. <para>
  8084. If you are producing your own customized version
  8085. of the build system for use by other users, you might
  8086. want to customize the message shown by the setup script or
  8087. you might want to change the template configuration files (i.e.
  8088. <filename>local.conf</filename> and
  8089. <filename>bblayers.conf</filename>) that are created in
  8090. a new build directory.
  8091. </para>
  8092. <para>
  8093. The OpenEmbedded build system uses the environment variable
  8094. <filename>TEMPLATECONF</filename> to locate the directory
  8095. from which it gathers configuration information that ultimately
  8096. ends up in the
  8097. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8098. <filename>conf</filename> directory.
  8099. By default, <filename>TEMPLATECONF</filename> is set as
  8100. follows in the <filename>poky</filename> repository:
  8101. <literallayout class='monospaced'>
  8102. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  8103. </literallayout>
  8104. This is the directory used by the build system to find templates
  8105. from which to build some key configuration files.
  8106. If you look at this directory, you will see the
  8107. <filename>bblayers.conf.sample</filename>,
  8108. <filename>local.conf.sample</filename>, and
  8109. <filename>conf-notes.txt</filename> files.
  8110. The build system uses these files to form the respective
  8111. <filename>bblayers.conf</filename> file,
  8112. <filename>local.conf</filename> file, and display the list of
  8113. BitBake targets when running the setup script.
  8114. </para>
  8115. <para>
  8116. To override these default configuration files with
  8117. configurations you want used within every new
  8118. Build Directory, simply set the
  8119. <filename>TEMPLATECONF</filename> variable to your directory.
  8120. The <filename>TEMPLATECONF</filename> variable is set in the
  8121. <filename>.templateconf</filename> file, which is in the
  8122. top-level
  8123. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  8124. folder (e.g. <filename>poky</filename>).
  8125. Edit the <filename>.templateconf</filename> so that it can locate
  8126. your directory.
  8127. </para>
  8128. <para>
  8129. Best practices dictate that you should keep your
  8130. template configuration directory in your custom distribution layer.
  8131. For example, suppose you have a layer named
  8132. <filename>meta-mylayer</filename> located in your home directory
  8133. and you want your template configuration directory named
  8134. <filename>myconf</filename>.
  8135. Changing the <filename>.templateconf</filename> as follows
  8136. causes the OpenEmbedded build system to look in your directory
  8137. and base its configuration files on the
  8138. <filename>*.sample</filename> configuration files it finds.
  8139. The final configuration files (i.e.
  8140. <filename>local.conf</filename> and
  8141. <filename>bblayers.conf</filename> ultimately still end up in
  8142. your Build Directory, but they are based on your
  8143. <filename>*.sample</filename> files.
  8144. <literallayout class='monospaced'>
  8145. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  8146. </literallayout>
  8147. </para>
  8148. <para>
  8149. Aside from the <filename>*.sample</filename> configuration files,
  8150. the <filename>conf-notes.txt</filename> also resides in the
  8151. default <filename>meta-poky/conf</filename> directory.
  8152. The script that sets up the build environment
  8153. (i.e.
  8154. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>)
  8155. uses this file to display BitBake targets as part of the script
  8156. output.
  8157. Customizing this <filename>conf-notes.txt</filename> file is a
  8158. good way to make sure your list of custom targets appears
  8159. as part of the script's output.
  8160. </para>
  8161. <para>
  8162. Here is the default list of targets displayed as a result of
  8163. running either of the setup scripts:
  8164. <literallayout class='monospaced'>
  8165. You can now run 'bitbake &lt;target&gt;'
  8166. Common targets are:
  8167. core-image-minimal
  8168. core-image-sato
  8169. meta-toolchain
  8170. meta-ide-support
  8171. </literallayout>
  8172. </para>
  8173. <para>
  8174. Changing the listed common targets is as easy as editing your
  8175. version of <filename>conf-notes.txt</filename> in your
  8176. custom template configuration directory and making sure you
  8177. have <filename>TEMPLATECONF</filename> set to your directory.
  8178. </para>
  8179. </section>
  8180. <section id='dev-saving-memory-during-a-build'>
  8181. <title>Conserving Disk Space During Builds</title>
  8182. <para>
  8183. To help conserve disk space during builds, you can add the
  8184. following statement to your project's
  8185. <filename>local.conf</filename> configuration file found in the
  8186. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8187. <literallayout class='monospaced'>
  8188. INHERIT += "rm_work"
  8189. </literallayout>
  8190. Adding this statement deletes the work directory used for building
  8191. a recipe once the recipe is built.
  8192. For more information on "rm_work", see the
  8193. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  8194. class in the Yocto Project Reference Manual.
  8195. </para>
  8196. </section>
  8197. <section id='working-with-packages'>
  8198. <title>Working with Packages</title>
  8199. <para>
  8200. This section describes a few tasks that involve packages:
  8201. <itemizedlist>
  8202. <listitem><para>
  8203. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  8204. </para></listitem>
  8205. <listitem><para>
  8206. <link linkend='incrementing-a-binary-package-version'>Incrementing a binary package version</link>
  8207. </para></listitem>
  8208. <listitem><para>
  8209. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  8210. </para></listitem>
  8211. <listitem><para>
  8212. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  8213. </para></listitem>
  8214. <listitem><para>
  8215. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  8216. </para></listitem>
  8217. </itemizedlist>
  8218. </para>
  8219. <section id='excluding-packages-from-an-image'>
  8220. <title>Excluding Packages from an Image</title>
  8221. <para>
  8222. You might find it necessary to prevent specific packages
  8223. from being installed into an image.
  8224. If so, you can use several variables to direct the build
  8225. system to essentially ignore installing recommended packages
  8226. or to not install a package at all.
  8227. </para>
  8228. <para>
  8229. The following list introduces variables you can use to
  8230. prevent packages from being installed into your image.
  8231. Each of these variables only works with IPK and RPM
  8232. package types.
  8233. Support for Debian packages does not exist.
  8234. Also, you can use these variables from your
  8235. <filename>local.conf</filename> file or attach them to a
  8236. specific image recipe by using a recipe name override.
  8237. For more detail on the variables, see the descriptions in the
  8238. Yocto Project Reference Manual's glossary chapter.
  8239. <itemizedlist>
  8240. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  8241. Use this variable to specify "recommended-only"
  8242. packages that you do not want installed.
  8243. </para></listitem>
  8244. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  8245. Use this variable to prevent all "recommended-only"
  8246. packages from being installed.
  8247. </para></listitem>
  8248. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  8249. Use this variable to prevent specific packages from
  8250. being installed regardless of whether they are
  8251. "recommended-only" or not.
  8252. You need to realize that the build process could
  8253. fail with an error when you
  8254. prevent the installation of a package whose presence
  8255. is required by an installed package.
  8256. </para></listitem>
  8257. </itemizedlist>
  8258. </para>
  8259. </section>
  8260. <section id='incrementing-a-binary-package-version'>
  8261. <title>Incrementing a Package Version</title>
  8262. <para>
  8263. This section provides some background on how binary package
  8264. versioning is accomplished and presents some of the services,
  8265. variables, and terminology involved.
  8266. </para>
  8267. <para>
  8268. In order to understand binary package versioning, you need
  8269. to consider the following:
  8270. <itemizedlist>
  8271. <listitem><para>
  8272. Binary Package: The binary package that is eventually
  8273. built and installed into an image.
  8274. </para></listitem>
  8275. <listitem><para>
  8276. Binary Package Version: The binary package version
  8277. is composed of two components - a version and a
  8278. revision.
  8279. <note>
  8280. Technically, a third component, the "epoch" (i.e.
  8281. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>)
  8282. is involved but this discussion for the most part
  8283. ignores <filename>PE</filename>.
  8284. </note>
  8285. The version and revision are taken from the
  8286. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  8287. and
  8288. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8289. variables, respectively.
  8290. </para></listitem>
  8291. <listitem><para>
  8292. <filename>PV</filename>: The recipe version.
  8293. <filename>PV</filename> represents the version of the
  8294. software being packaged.
  8295. Do not confuse <filename>PV</filename> with the
  8296. binary package version.
  8297. </para></listitem>
  8298. <listitem><para>
  8299. <filename>PR</filename>: The recipe revision.
  8300. </para></listitem>
  8301. <listitem><para>
  8302. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>:
  8303. The OpenEmbedded build system uses this string
  8304. to help define the value of <filename>PV</filename>
  8305. when the source code revision needs to be included
  8306. in it.
  8307. </para></listitem>
  8308. <listitem><para>
  8309. <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>:
  8310. A network-based service that helps automate keeping
  8311. package feeds compatible with existing package
  8312. manager applications such as RPM, APT, and OPKG.
  8313. </para></listitem>
  8314. </itemizedlist>
  8315. </para>
  8316. <para>
  8317. Whenever the binary package content changes, the binary package
  8318. version must change.
  8319. Changing the binary package version is accomplished by changing
  8320. or "bumping" the <filename>PR</filename> and/or
  8321. <filename>PV</filename> values.
  8322. Increasing these values occurs one of two ways:
  8323. <itemizedlist>
  8324. <listitem><para>Automatically using a Package Revision
  8325. Service (PR Service).
  8326. </para></listitem>
  8327. <listitem><para>Manually incrementing the
  8328. <filename>PR</filename> and/or
  8329. <filename>PV</filename> variables.
  8330. </para></listitem>
  8331. </itemizedlist>
  8332. </para>
  8333. <para>
  8334. Given a primary challenge of any build system and its users
  8335. is how to maintain a package feed that is compatible with
  8336. existing package manager applications such as RPM, APT, and
  8337. OPKG, using an automated system is much preferred over a
  8338. manual system.
  8339. In either system, the main requirement is that binary package
  8340. version numbering increases in a linear fashion and that a
  8341. number of version components exist that support that linear
  8342. progression.
  8343. For information on how to ensure package revisioning remains
  8344. linear, see the
  8345. "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>"
  8346. section.
  8347. </para>
  8348. <para>
  8349. The following three sections provide related information on the
  8350. PR Service, the manual method for "bumping"
  8351. <filename>PR</filename> and/or <filename>PV</filename>, and
  8352. on how to ensure binary package revisioning remains linear.
  8353. </para>
  8354. <section id='working-with-a-pr-service'>
  8355. <title>Working With a PR Service</title>
  8356. <para>
  8357. As mentioned, attempting to maintain revision numbers in the
  8358. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  8359. is error prone, inaccurate, and causes problems for people
  8360. submitting recipes.
  8361. Conversely, the PR Service automatically generates
  8362. increasing numbers, particularly the revision field,
  8363. which removes the human element.
  8364. <note>
  8365. For additional information on using a PR Service, you
  8366. can see the
  8367. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  8368. wiki page.
  8369. </note>
  8370. </para>
  8371. <para>
  8372. The Yocto Project uses variables in order of
  8373. decreasing priority to facilitate revision numbering (i.e.
  8374. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  8375. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  8376. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8377. for epoch, version, and revision, respectively).
  8378. The values are highly dependent on the policies and
  8379. procedures of a given distribution and package feed.
  8380. </para>
  8381. <para>
  8382. Because the OpenEmbedded build system uses
  8383. "<ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>signatures</ulink>",
  8384. which are unique to a given build, the build system
  8385. knows when to rebuild packages.
  8386. All the inputs into a given task are represented by a
  8387. signature, which can trigger a rebuild when different.
  8388. Thus, the build system itself does not rely on the
  8389. <filename>PR</filename>, <filename>PV</filename>, and
  8390. <filename>PE</filename> numbers to trigger a rebuild.
  8391. The signatures, however, can be used to generate
  8392. these values.
  8393. </para>
  8394. <para>
  8395. The PR Service works with both
  8396. <filename>OEBasic</filename> and
  8397. <filename>OEBasicHash</filename> generators.
  8398. The value of <filename>PR</filename> bumps when the
  8399. checksum changes and the different generator mechanisms
  8400. change signatures under different circumstances.
  8401. </para>
  8402. <para>
  8403. As implemented, the build system includes values from
  8404. the PR Service into the <filename>PR</filename> field as
  8405. an addition using the form "<filename>.x</filename>" so
  8406. <filename>r0</filename> becomes <filename>r0.1</filename>,
  8407. <filename>r0.2</filename> and so forth.
  8408. This scheme allows existing <filename>PR</filename> values
  8409. to be used for whatever reasons, which include manual
  8410. <filename>PR</filename> bumps, should it be necessary.
  8411. </para>
  8412. <para>
  8413. By default, the PR Service is not enabled or running.
  8414. Thus, the packages generated are just "self consistent".
  8415. The build system adds and removes packages and
  8416. there are no guarantees about upgrade paths but images
  8417. will be consistent and correct with the latest changes.
  8418. </para>
  8419. <para>
  8420. The simplest form for a PR Service is for it to exist
  8421. for a single host development system that builds the
  8422. package feed (building system).
  8423. For this scenario, you can enable a local PR Service by
  8424. setting
  8425. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  8426. in your <filename>local.conf</filename> file in the
  8427. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8428. <literallayout class='monospaced'>
  8429. PRSERV_HOST = "localhost:0"
  8430. </literallayout>
  8431. Once the service is started, packages will automatically
  8432. get increasing <filename>PR</filename> values and
  8433. BitBake takes care of starting and stopping the server.
  8434. </para>
  8435. <para>
  8436. If you have a more complex setup where multiple host
  8437. development systems work against a common, shared package
  8438. feed, you have a single PR Service running and it is
  8439. connected to each building system.
  8440. For this scenario, you need to start the PR Service using
  8441. the <filename>bitbake-prserv</filename> command:
  8442. <literallayout class='monospaced'>
  8443. bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start
  8444. </literallayout>
  8445. In addition to hand-starting the service, you need to
  8446. update the <filename>local.conf</filename> file of each
  8447. building system as described earlier so each system
  8448. points to the server and port.
  8449. </para>
  8450. <para>
  8451. It is also recommended you use build history, which adds
  8452. some sanity checks to binary package versions, in
  8453. conjunction with the server that is running the PR Service.
  8454. To enable build history, add the following to each building
  8455. system's <filename>local.conf</filename> file:
  8456. <literallayout class='monospaced'>
  8457. # It is recommended to activate "buildhistory" for testing the PR service
  8458. INHERIT += "buildhistory"
  8459. BUILDHISTORY_COMMIT = "1"
  8460. </literallayout>
  8461. For information on build history, see the
  8462. "<link linkend='maintaining-build-output-quality'>Maintaining Build Output Quality</link>"
  8463. section.
  8464. </para>
  8465. <note>
  8466. <para>
  8467. The OpenEmbedded build system does not maintain
  8468. <filename>PR</filename> information as part of the
  8469. shared state (sstate) packages.
  8470. If you maintain an sstate feed, its expected that either
  8471. all your building systems that contribute to the sstate
  8472. feed use a shared PR Service, or you do not run a PR
  8473. Service on any of your building systems.
  8474. Having some systems use a PR Service while others do
  8475. not leads to obvious problems.
  8476. </para>
  8477. <para>
  8478. For more information on shared state, see the
  8479. "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>Shared State Cache</ulink>"
  8480. section in the Yocto Project Overview and Concepts
  8481. Manual.
  8482. </para>
  8483. </note>
  8484. </section>
  8485. <section id='manually-bumping-pr'>
  8486. <title>Manually Bumping PR</title>
  8487. <para>
  8488. The alternative to setting up a PR Service is to manually
  8489. "bump" the
  8490. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8491. variable.
  8492. </para>
  8493. <para>
  8494. If a committed change results in changing the package
  8495. output, then the value of the PR variable needs to be
  8496. increased (or "bumped") as part of that commit.
  8497. For new recipes you should add the <filename>PR</filename>
  8498. variable and set its initial value equal to "r0", which is
  8499. the default.
  8500. Even though the default value is "r0", the practice of
  8501. adding it to a new recipe makes it harder to forget to bump
  8502. the variable when you make changes to the recipe in future.
  8503. </para>
  8504. <para>
  8505. If you are sharing a common <filename>.inc</filename> file
  8506. with multiple recipes, you can also use the
  8507. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  8508. variable to ensure that the recipes sharing the
  8509. <filename>.inc</filename> file are rebuilt when the
  8510. <filename>.inc</filename> file itself is changed.
  8511. The <filename>.inc</filename> file must set
  8512. <filename>INC_PR</filename> (initially to "r0"), and all
  8513. recipes referring to it should set <filename>PR</filename>
  8514. to "${INC_PR}.0" initially, incrementing the last number
  8515. when the recipe is changed.
  8516. If the <filename>.inc</filename> file is changed then its
  8517. <filename>INC_PR</filename> should be incremented.
  8518. </para>
  8519. <para>
  8520. When upgrading the version of a binary package, assuming the
  8521. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  8522. changes, the <filename>PR</filename> variable should be
  8523. reset to "r0" (or "${INC_PR}.0" if you are using
  8524. <filename>INC_PR</filename>).
  8525. </para>
  8526. <para>
  8527. Usually, version increases occur only to binary packages.
  8528. However, if for some reason <filename>PV</filename> changes
  8529. but does not increase, you can increase the
  8530. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  8531. variable (Package Epoch).
  8532. The <filename>PE</filename> variable defaults to "0".
  8533. </para>
  8534. <para>
  8535. Binary package version numbering strives to follow the
  8536. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  8537. Debian Version Field Policy Guidelines</ulink>.
  8538. These guidelines define how versions are compared and what
  8539. "increasing" a version means.
  8540. </para>
  8541. </section>
  8542. <section id='automatically-incrementing-a-binary-package-revision-number'>
  8543. <title>Automatically Incrementing a Package Version Number</title>
  8544. <para>
  8545. When fetching a repository, BitBake uses the
  8546. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  8547. variable to determine the specific source code revision
  8548. from which to build.
  8549. You set the <filename>SRCREV</filename> variable to
  8550. <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>
  8551. to cause the OpenEmbedded build system to automatically use the
  8552. latest revision of the software:
  8553. <literallayout class='monospaced'>
  8554. SRCREV = "${AUTOREV}"
  8555. </literallayout>
  8556. </para>
  8557. <para>
  8558. Furthermore, you need to reference <filename>SRCPV</filename>
  8559. in <filename>PV</filename> in order to automatically update
  8560. the version whenever the revision of the source code
  8561. changes.
  8562. Here is an example:
  8563. <literallayout class='monospaced'>
  8564. PV = "1.0+git${SRCPV}"
  8565. </literallayout>
  8566. The OpenEmbedded build system substitutes
  8567. <filename>SRCPV</filename> with the following:
  8568. <literallayout class='monospaced'>
  8569. AUTOINC+<replaceable>source_code_revision</replaceable>
  8570. </literallayout>
  8571. The build system replaces the <filename>AUTOINC</filename> with
  8572. a number.
  8573. The number used depends on the state of the PR Service:
  8574. <itemizedlist>
  8575. <listitem><para>
  8576. If PR Service is enabled, the build system increments
  8577. the number, which is similar to the behavior of
  8578. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>.
  8579. This behavior results in linearly increasing package
  8580. versions, which is desirable.
  8581. Here is an example:
  8582. <literallayout class='monospaced'>
  8583. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  8584. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  8585. </literallayout>
  8586. </para></listitem>
  8587. <listitem><para>
  8588. If PR Service is not enabled, the build system
  8589. replaces the <filename>AUTOINC</filename>
  8590. placeholder with zero (i.e. "0").
  8591. This results in changing the package version since
  8592. the source revision is included.
  8593. However, package versions are not increased linearly.
  8594. Here is an example:
  8595. <literallayout class='monospaced'>
  8596. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  8597. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  8598. </literallayout>
  8599. </para></listitem>
  8600. </itemizedlist>
  8601. </para>
  8602. <para>
  8603. In summary, the OpenEmbedded build system does not track the
  8604. history of binary package versions for this purpose.
  8605. <filename>AUTOINC</filename>, in this case, is comparable to
  8606. <filename>PR</filename>.
  8607. If PR server is not enabled, <filename>AUTOINC</filename>
  8608. in the package version is simply replaced by "0".
  8609. If PR server is enabled, the build system keeps track of the
  8610. package versions and bumps the number when the package
  8611. revision changes.
  8612. </para>
  8613. </section>
  8614. </section>
  8615. <section id='handling-optional-module-packaging'>
  8616. <title>Handling Optional Module Packaging</title>
  8617. <para>
  8618. Many pieces of software split functionality into optional
  8619. modules (or plug-ins) and the plug-ins that are built
  8620. might depend on configuration options.
  8621. To avoid having to duplicate the logic that determines what
  8622. modules are available in your recipe or to avoid having
  8623. to package each module by hand, the OpenEmbedded build system
  8624. provides functionality to handle module packaging dynamically.
  8625. </para>
  8626. <para>
  8627. To handle optional module packaging, you need to do two things:
  8628. <itemizedlist>
  8629. <listitem><para>Ensure the module packaging is actually
  8630. done.</para></listitem>
  8631. <listitem><para>Ensure that any dependencies on optional
  8632. modules from other recipes are satisfied by your recipe.
  8633. </para></listitem>
  8634. </itemizedlist>
  8635. </para>
  8636. <section id='making-sure-the-packaging-is-done'>
  8637. <title>Making Sure the Packaging is Done</title>
  8638. <para>
  8639. To ensure the module packaging actually gets done, you use
  8640. the <filename>do_split_packages</filename> function within
  8641. the <filename>populate_packages</filename> Python function
  8642. in your recipe.
  8643. The <filename>do_split_packages</filename> function
  8644. searches for a pattern of files or directories under a
  8645. specified path and creates a package for each one it finds
  8646. by appending to the
  8647. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  8648. variable and setting the appropriate values for
  8649. <filename>FILES_packagename</filename>,
  8650. <filename>RDEPENDS_packagename</filename>,
  8651. <filename>DESCRIPTION_packagename</filename>, and so forth.
  8652. Here is an example from the <filename>lighttpd</filename>
  8653. recipe:
  8654. <literallayout class='monospaced'>
  8655. python populate_packages_prepend () {
  8656. lighttpd_libdir = d.expand('${libdir}')
  8657. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  8658. 'lighttpd-module-%s', 'Lighttpd module for %s',
  8659. extra_depends='')
  8660. }
  8661. </literallayout>
  8662. The previous example specifies a number of things in the
  8663. call to <filename>do_split_packages</filename>.
  8664. <itemizedlist>
  8665. <listitem><para>A directory within the files installed
  8666. by your recipe through <filename>do_install</filename>
  8667. in which to search.</para></listitem>
  8668. <listitem><para>A regular expression used to match module
  8669. files in that directory.
  8670. In the example, note the parentheses () that mark
  8671. the part of the expression from which the module
  8672. name should be derived.</para></listitem>
  8673. <listitem><para>A pattern to use for the package names.
  8674. </para></listitem>
  8675. <listitem><para>A description for each package.
  8676. </para></listitem>
  8677. <listitem><para>An empty string for
  8678. <filename>extra_depends</filename>, which disables
  8679. the default dependency on the main
  8680. <filename>lighttpd</filename> package.
  8681. Thus, if a file in <filename>${libdir}</filename>
  8682. called <filename>mod_alias.so</filename> is found,
  8683. a package called <filename>lighttpd-module-alias</filename>
  8684. is created for it and the
  8685. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  8686. is set to "Lighttpd module for alias".</para></listitem>
  8687. </itemizedlist>
  8688. </para>
  8689. <para>
  8690. Often, packaging modules is as simple as the previous
  8691. example.
  8692. However, more advanced options exist that you can use
  8693. within <filename>do_split_packages</filename> to modify its
  8694. behavior.
  8695. And, if you need to, you can add more logic by specifying
  8696. a hook function that is called for each package.
  8697. It is also perfectly acceptable to call
  8698. <filename>do_split_packages</filename> multiple times if
  8699. you have more than one set of modules to package.
  8700. </para>
  8701. <para>
  8702. For more examples that show how to use
  8703. <filename>do_split_packages</filename>, see the
  8704. <filename>connman.inc</filename> file in the
  8705. <filename>meta/recipes-connectivity/connman/</filename>
  8706. directory of the <filename>poky</filename>
  8707. <ulink url='&YOCTO_DOCS_OM_URL;#yocto-project-repositories'>source repository</ulink>.
  8708. You can also find examples in
  8709. <filename>meta/classes/kernel.bbclass</filename>.
  8710. </para>
  8711. <para>
  8712. Following is a reference that shows
  8713. <filename>do_split_packages</filename> mandatory and
  8714. optional arguments:
  8715. <literallayout class='monospaced'>
  8716. Mandatory arguments
  8717. root
  8718. The path in which to search
  8719. file_regex
  8720. Regular expression to match searched files.
  8721. Use parentheses () to mark the part of this
  8722. expression that should be used to derive the
  8723. module name (to be substituted where %s is
  8724. used in other function arguments as noted below)
  8725. output_pattern
  8726. Pattern to use for the package names. Must
  8727. include %s.
  8728. description
  8729. Description to set for each package. Must
  8730. include %s.
  8731. Optional arguments
  8732. postinst
  8733. Postinstall script to use for all packages
  8734. (as a string)
  8735. recursive
  8736. True to perform a recursive search - default
  8737. False
  8738. hook
  8739. A hook function to be called for every match.
  8740. The function will be called with the following
  8741. arguments (in the order listed):
  8742. f
  8743. Full path to the file/directory match
  8744. pkg
  8745. The package name
  8746. file_regex
  8747. As above
  8748. output_pattern
  8749. As above
  8750. modulename
  8751. The module name derived using file_regex
  8752. extra_depends
  8753. Extra runtime dependencies (RDEPENDS) to be
  8754. set for all packages. The default value of None
  8755. causes a dependency on the main package
  8756. (${PN}) - if you do not want this, pass empty
  8757. string '' for this parameter.
  8758. aux_files_pattern
  8759. Extra item(s) to be added to FILES for each
  8760. package. Can be a single string item or a list
  8761. of strings for multiple items. Must include %s.
  8762. postrm
  8763. postrm script to use for all packages (as a
  8764. string)
  8765. allow_dirs
  8766. True to allow directories to be matched -
  8767. default False
  8768. prepend
  8769. If True, prepend created packages to PACKAGES
  8770. instead of the default False which appends them
  8771. match_path
  8772. match file_regex on the whole relative path to
  8773. the root rather than just the file name
  8774. aux_files_pattern_verbatim
  8775. Extra item(s) to be added to FILES for each
  8776. package, using the actual derived module name
  8777. rather than converting it to something legal
  8778. for a package name. Can be a single string item
  8779. or a list of strings for multiple items. Must
  8780. include %s.
  8781. allow_links
  8782. True to allow symlinks to be matched - default
  8783. False
  8784. summary
  8785. Summary to set for each package. Must include %s;
  8786. defaults to description if not set.
  8787. </literallayout>
  8788. </para>
  8789. </section>
  8790. <section id='satisfying-dependencies'>
  8791. <title>Satisfying Dependencies</title>
  8792. <para>
  8793. The second part for handling optional module packaging
  8794. is to ensure that any dependencies on optional modules
  8795. from other recipes are satisfied by your recipe.
  8796. You can be sure these dependencies are satisfied by
  8797. using the
  8798. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  8799. Here is an example that continues with the
  8800. <filename>lighttpd</filename> recipe shown earlier:
  8801. <literallayout class='monospaced'>
  8802. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  8803. </literallayout>
  8804. The name specified in the regular expression can of
  8805. course be anything.
  8806. In this example, it is <filename>lighttpd-module-</filename>
  8807. and is specified as the prefix to ensure that any
  8808. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  8809. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  8810. on a package name starting with the prefix are satisfied
  8811. during build time.
  8812. If you are using <filename>do_split_packages</filename>
  8813. as described in the previous section, the value you put in
  8814. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  8815. the name pattern specified in the call to
  8816. <filename>do_split_packages</filename>.
  8817. </para>
  8818. </section>
  8819. </section>
  8820. <section id='using-runtime-package-management'>
  8821. <title>Using Runtime Package Management</title>
  8822. <para>
  8823. During a build, BitBake always transforms a recipe into one or
  8824. more packages.
  8825. For example, BitBake takes the <filename>bash</filename> recipe
  8826. and produces a number of packages (e.g.
  8827. <filename>bash</filename>, <filename>bash-bashbug</filename>,
  8828. <filename>bash-completion</filename>,
  8829. <filename>bash-completion-dbg</filename>,
  8830. <filename>bash-completion-dev</filename>,
  8831. <filename>bash-completion-extra</filename>,
  8832. <filename>bash-dbg</filename>, and so forth).
  8833. Not all generated packages are included in an image.
  8834. </para>
  8835. <para>
  8836. In several situations, you might need to update, add, remove,
  8837. or query the packages on a target device at runtime
  8838. (i.e. without having to generate a new image).
  8839. Examples of such situations include:
  8840. <itemizedlist>
  8841. <listitem><para>
  8842. You want to provide in-the-field updates to deployed
  8843. devices (e.g. security updates).
  8844. </para></listitem>
  8845. <listitem><para>
  8846. You want to have a fast turn-around development cycle
  8847. for one or more applications that run on your device.
  8848. </para></listitem>
  8849. <listitem><para>
  8850. You want to temporarily install the "debug" packages
  8851. of various applications on your device so that
  8852. debugging can be greatly improved by allowing
  8853. access to symbols and source debugging.
  8854. </para></listitem>
  8855. <listitem><para>
  8856. You want to deploy a more minimal package selection of
  8857. your device but allow in-the-field updates to add a
  8858. larger selection for customization.
  8859. </para></listitem>
  8860. </itemizedlist>
  8861. </para>
  8862. <para>
  8863. In all these situations, you have something similar to a more
  8864. traditional Linux distribution in that in-field devices
  8865. are able to receive pre-compiled packages from a server for
  8866. installation or update.
  8867. Being able to install these packages on a running,
  8868. in-field device is what is termed "runtime package
  8869. management".
  8870. </para>
  8871. <para>
  8872. In order to use runtime package management, you
  8873. need a host or server machine that serves up the pre-compiled
  8874. packages plus the required metadata.
  8875. You also need package manipulation tools on the target.
  8876. The build machine is a likely candidate to act as the server.
  8877. However, that machine does not necessarily have to be the
  8878. package server.
  8879. The build machine could push its artifacts to another machine
  8880. that acts as the server (e.g. Internet-facing).
  8881. In fact, doing so is advantageous for a production
  8882. environment as getting the packages away from the
  8883. development system's build directory prevents accidental
  8884. overwrites.
  8885. </para>
  8886. <para>
  8887. A simple build that targets just one device produces
  8888. more than one package database.
  8889. In other words, the packages produced by a build are separated
  8890. out into a couple of different package groupings based on
  8891. criteria such as the target's CPU architecture, the target
  8892. board, or the C library used on the target.
  8893. For example, a build targeting the <filename>qemux86</filename>
  8894. device produces the following three package databases:
  8895. <filename>noarch</filename>, <filename>i586</filename>, and
  8896. <filename>qemux86</filename>.
  8897. If you wanted your <filename>qemux86</filename> device to be
  8898. aware of all the packages that were available to it,
  8899. you would need to point it to each of these databases
  8900. individually.
  8901. In a similar way, a traditional Linux distribution usually is
  8902. configured to be aware of a number of software repositories
  8903. from which it retrieves packages.
  8904. </para>
  8905. <para>
  8906. Using runtime package management is completely optional and
  8907. not required for a successful build or deployment in any
  8908. way.
  8909. But if you want to make use of runtime package management,
  8910. you need to do a couple things above and beyond the basics.
  8911. The remainder of this section describes what you need to do.
  8912. </para>
  8913. <section id='runtime-package-management-build'>
  8914. <title>Build Considerations</title>
  8915. <para>
  8916. This section describes build considerations of which you
  8917. need to be aware in order to provide support for runtime
  8918. package management.
  8919. </para>
  8920. <para>
  8921. When BitBake generates packages, it needs to know
  8922. what format or formats to use.
  8923. In your configuration, you use the
  8924. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  8925. variable to specify the format:
  8926. <orderedlist>
  8927. <listitem><para>
  8928. Open the <filename>local.conf</filename> file
  8929. inside your
  8930. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8931. (e.g. <filename>~/poky/build/conf/local.conf</filename>).
  8932. </para></listitem>
  8933. <listitem><para>
  8934. Select the desired package format as follows:
  8935. <literallayout class='monospaced'>
  8936. PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>”
  8937. </literallayout>
  8938. where <replaceable>packageformat</replaceable>
  8939. can be "ipk", "rpm", "deb", or "tar" which are the
  8940. supported package formats.
  8941. <note>
  8942. Because the Yocto Project supports four
  8943. different package formats, you can set the
  8944. variable with more than one argument.
  8945. However, the OpenEmbedded build system only
  8946. uses the first argument when creating an image
  8947. or Software Development Kit (SDK).
  8948. </note>
  8949. </para></listitem>
  8950. </orderedlist>
  8951. </para>
  8952. <para>
  8953. If you would like your image to start off with a basic
  8954. package database containing the packages in your current
  8955. build as well as to have the relevant tools available on the
  8956. target for runtime package management, you can include
  8957. "package-management" in the
  8958. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  8959. variable.
  8960. Including "package-management" in this configuration
  8961. variable ensures that when the image is assembled for your
  8962. target, the image includes the currently-known package
  8963. databases as well as the target-specific tools required
  8964. for runtime package management to be performed on the
  8965. target.
  8966. However, this is not strictly necessary.
  8967. You could start your image off without any databases
  8968. but only include the required on-target package
  8969. tool(s).
  8970. As an example, you could include "opkg" in your
  8971. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  8972. variable if you are using the IPK package format.
  8973. You can then initialize your target's package database(s)
  8974. later once your image is up and running.
  8975. </para>
  8976. <para>
  8977. Whenever you perform any sort of build step that can
  8978. potentially generate a package or modify existing
  8979. package, it is always a good idea to re-generate the
  8980. package index after the build by using the following
  8981. command:
  8982. <literallayout class='monospaced'>
  8983. $ bitbake package-index
  8984. </literallayout>
  8985. It might be tempting to build the package and the
  8986. package index at the same time with a command such as
  8987. the following:
  8988. <literallayout class='monospaced'>
  8989. $ bitbake <replaceable>some-package</replaceable> package-index
  8990. </literallayout>
  8991. Do not do this as BitBake does not schedule the package
  8992. index for after the completion of the package you are
  8993. building.
  8994. Consequently, you cannot be sure of the package index
  8995. including information for the package you just built.
  8996. Thus, be sure to run the package update step separately
  8997. after building any packages.
  8998. </para>
  8999. <para>
  9000. You can use the
  9001. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9002. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  9003. and
  9004. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9005. variables to pre-configure target images to use a package
  9006. feed.
  9007. If you do not define these variables, then manual steps
  9008. as described in the subsequent sections are necessary to
  9009. configure the target.
  9010. You should set these variables before building the image
  9011. in order to produce a correctly configured image.
  9012. </para>
  9013. <para>
  9014. When your build is complete, your packages reside in the
  9015. <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename>
  9016. directory.
  9017. For example, if
  9018. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename>
  9019. is <filename>tmp</filename> and your selected package type
  9020. is RPM, then your RPM packages are available in
  9021. <filename>tmp/deploy/rpm</filename>.
  9022. </para>
  9023. </section>
  9024. <section id='runtime-package-management-server'>
  9025. <title>Host or Server Machine Setup</title>
  9026. <para>
  9027. Although other protocols are possible, a server using HTTP
  9028. typically serves packages.
  9029. If you want to use HTTP, then set up and configure a
  9030. web server such as Apache 2, lighttpd, or
  9031. SimpleHTTPServer on the machine serving the packages.
  9032. </para>
  9033. <para>
  9034. To keep things simple, this section describes how to set
  9035. up a SimpleHTTPServer web server to share package feeds
  9036. from the developer's machine.
  9037. Although this server might not be the best for a production
  9038. environment, the setup is simple and straight forward.
  9039. Should you want to use a different server more suited for
  9040. production (e.g. Apache 2, Lighttpd, or Nginx), take the
  9041. appropriate steps to do so.
  9042. </para>
  9043. <para>
  9044. From within the build directory where you have built an
  9045. image based on your packaging choice (i.e. the
  9046. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  9047. setting), simply start the server.
  9048. The following example assumes a build directory of
  9049. <filename>~/poky/build/tmp/deploy/rpm</filename> and a
  9050. <filename>PACKAGE_CLASSES</filename> setting of
  9051. "package_rpm":
  9052. <literallayout class='monospaced'>
  9053. $ cd ~/poky/build/tmp/deploy/rpm
  9054. $ python -m SimpleHTTPServer
  9055. </literallayout>
  9056. </para>
  9057. </section>
  9058. <section id='runtime-package-management-target'>
  9059. <title>Target Setup</title>
  9060. <para>
  9061. Setting up the target differs depending on the
  9062. package management system.
  9063. This section provides information for RPM, IPK, and DEB.
  9064. </para>
  9065. <section id='runtime-package-management-target-rpm'>
  9066. <title>Using RPM</title>
  9067. <para>
  9068. The
  9069. <ulink url='https://en.wikipedia.org/wiki/DNF_(software)'>Dandified Packaging Tool</ulink>
  9070. (DNF) performs runtime package management of RPM
  9071. packages.
  9072. In order to use DNF for runtime package management,
  9073. you must perform an initial setup on the target
  9074. machine for cases where the
  9075. <filename>PACKAGE_FEED_*</filename> variables were not
  9076. set as part of the image that is running on the
  9077. target.
  9078. This means if you built your image and did not not use
  9079. these variables as part of the build and your image is
  9080. now running on the target, you need to perform the
  9081. steps in this section if you want to use runtime
  9082. package management.
  9083. <note>
  9084. For information on the
  9085. <filename>PACKAGE_FEED_*</filename> variables, see
  9086. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9087. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  9088. and
  9089. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9090. in the Yocto Project Reference Manual variables
  9091. glossary.
  9092. </note>
  9093. </para>
  9094. <para>
  9095. On the target, you must inform DNF that package
  9096. databases are available.
  9097. You do this by creating a file named
  9098. <filename>/etc/yum.repos.d/oe-packages.repo</filename>
  9099. and defining the <filename>oe-packages</filename>.
  9100. </para>
  9101. <para>
  9102. As an example, assume the target is able to use the
  9103. following package databases:
  9104. <filename>all</filename>, <filename>i586</filename>,
  9105. and <filename>qemux86</filename> from a server named
  9106. <filename>my.server</filename>.
  9107. The specifics for setting up the web server are up to
  9108. you.
  9109. The critical requirement is that the URIs in the
  9110. target repository configuration point to the
  9111. correct remote location for the feeds.
  9112. <note><title>Tip</title>
  9113. For development purposes, you can point the web
  9114. server to the build system's
  9115. <filename>deploy</filename> directory.
  9116. However, for production use, it is better to copy
  9117. the package directories to a location outside of
  9118. the build area and use that location.
  9119. Doing so avoids situations where the build system
  9120. overwrites or changes the
  9121. <filename>deploy</filename> directory.
  9122. </note>
  9123. </para>
  9124. <para>
  9125. When telling DNF where to look for the package
  9126. databases, you must declare individual locations
  9127. per architecture or a single location used for all
  9128. architectures.
  9129. You cannot do both:
  9130. <itemizedlist>
  9131. <listitem><para>
  9132. <emphasis>Create an Explicit List of Architectures:</emphasis>
  9133. Define individual base URLs to identify where
  9134. each package database is located:
  9135. <literallayout class='monospaced'>
  9136. [oe-packages]
  9137. baseurl=http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all
  9138. </literallayout>
  9139. This example informs DNF about individual
  9140. package databases for all three architectures.
  9141. </para></listitem>
  9142. <listitem><para>
  9143. <emphasis>Create a Single (Full) Package Index:</emphasis>
  9144. Define a single base URL that identifies where
  9145. a full package database is located:
  9146. <literallayout class='monospaced'>
  9147. [oe-packages]
  9148. baseurl=http://my.server/rpm
  9149. </literallayout>
  9150. This example informs DNF about a single package
  9151. database that contains all the package index
  9152. information for all supported architectures.
  9153. </para></listitem>
  9154. </itemizedlist>
  9155. </para>
  9156. <para>
  9157. Once you have informed DNF where to find the package
  9158. databases, you need to fetch them:
  9159. <literallayout class='monospaced'>
  9160. # dnf makecache
  9161. </literallayout>
  9162. DNF is now able to find, install, and upgrade packages
  9163. from the specified repository or repositories.
  9164. <note>
  9165. See the
  9166. <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink>
  9167. for additional information.
  9168. </note>
  9169. </para>
  9170. </section>
  9171. <section id='runtime-package-management-target-ipk'>
  9172. <title>Using IPK</title>
  9173. <para>
  9174. The <filename>opkg</filename> application performs
  9175. runtime package management of IPK packages.
  9176. You must perform an initial setup for
  9177. <filename>opkg</filename> on the target machine
  9178. if the
  9179. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9180. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  9181. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9182. variables have not been set or the target image was
  9183. built before the variables were set.
  9184. </para>
  9185. <para>
  9186. The <filename>opkg</filename> application uses
  9187. configuration files to find available package
  9188. databases.
  9189. Thus, you need to create a configuration file inside
  9190. the <filename>/etc/opkg/</filename> direction, which
  9191. informs <filename>opkg</filename> of any repository
  9192. you want to use.
  9193. </para>
  9194. <para>
  9195. As an example, suppose you are serving packages from a
  9196. <filename>ipk/</filename> directory containing the
  9197. <filename>i586</filename>,
  9198. <filename>all</filename>, and
  9199. <filename>qemux86</filename> databases through an
  9200. HTTP server named <filename>my.server</filename>.
  9201. On the target, create a configuration file
  9202. (e.g. <filename>my_repo.conf</filename>) inside the
  9203. <filename>/etc/opkg/</filename> directory containing
  9204. the following:
  9205. <literallayout class='monospaced'>
  9206. src/gz all http://my.server/ipk/all
  9207. src/gz i586 http://my.server/ipk/i586
  9208. src/gz qemux86 http://my.server/ipk/qemux86
  9209. </literallayout>
  9210. Next, instruct <filename>opkg</filename> to fetch
  9211. the repository information:
  9212. <literallayout class='monospaced'>
  9213. # opkg update
  9214. </literallayout>
  9215. The <filename>opkg</filename> application is now able
  9216. to find, install, and upgrade packages from the
  9217. specified repository.
  9218. </para>
  9219. </section>
  9220. <section id='runtime-package-management-target-deb'>
  9221. <title>Using DEB</title>
  9222. <para>
  9223. The <filename>apt</filename> application performs
  9224. runtime package management of DEB packages.
  9225. This application uses a source list file to find
  9226. available package databases.
  9227. You must perform an initial setup for
  9228. <filename>apt</filename> on the target machine
  9229. if the
  9230. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  9231. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  9232. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  9233. variables have not been set or the target image was
  9234. built before the variables were set.
  9235. </para>
  9236. <para>
  9237. To inform <filename>apt</filename> of the repository
  9238. you want to use, you might create a list file (e.g.
  9239. <filename>my_repo.list</filename>) inside the
  9240. <filename>/etc/apt/sources.list.d/</filename>
  9241. directory.
  9242. As an example, suppose you are serving packages from a
  9243. <filename>deb/</filename> directory containing the
  9244. <filename>i586</filename>,
  9245. <filename>all</filename>, and
  9246. <filename>qemux86</filename> databases through an
  9247. HTTP server named <filename>my.server</filename>.
  9248. The list file should contain:
  9249. <literallayout class='monospaced'>
  9250. deb http://my.server/deb/all ./
  9251. deb http://my.server/deb/i586 ./
  9252. deb http://my.server/deb/qemux86 ./
  9253. </literallayout>
  9254. Next, instruct the <filename>apt</filename>
  9255. application to fetch the repository information:
  9256. <literallayout class='monospaced'>
  9257. # apt-get update
  9258. </literallayout>
  9259. After this step, <filename>apt</filename> is able
  9260. to find, install, and upgrade packages from the
  9261. specified repository.
  9262. </para>
  9263. </section>
  9264. </section>
  9265. </section>
  9266. <section id='generating-and-using-signed-packages'>
  9267. <title>Generating and Using Signed Packages</title>
  9268. <para>
  9269. In order to add security to RPM packages used during a build,
  9270. you can take steps to securely sign them.
  9271. Once a signature is verified, the OpenEmbedded build system
  9272. can use the package in the build.
  9273. If security fails for a signed package, the build system
  9274. aborts the build.
  9275. </para>
  9276. <para>
  9277. This section describes how to sign RPM packages during a build
  9278. and how to use signed package feeds (repositories) when
  9279. doing a build.
  9280. </para>
  9281. <section id='signing-rpm-packages'>
  9282. <title>Signing RPM Packages</title>
  9283. <para>
  9284. To enable signing RPM packages, you must set up the
  9285. following configurations in either your
  9286. <filename>local.config</filename> or
  9287. <filename>distro.config</filename> file:
  9288. <literallayout class='monospaced'>
  9289. # Inherit sign_rpm.bbclass to enable signing functionality
  9290. INHERIT += " sign_rpm"
  9291. # Define the GPG key that will be used for signing.
  9292. RPM_GPG_NAME = "<replaceable>key_name</replaceable>"
  9293. # Provide passphrase for the key
  9294. RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>"
  9295. </literallayout>
  9296. <note>
  9297. Be sure to supply appropriate values for both
  9298. <replaceable>key_name</replaceable> and
  9299. <replaceable>passphrase</replaceable>
  9300. </note>
  9301. Aside from the
  9302. <filename>RPM_GPG_NAME</filename> and
  9303. <filename>RPM_GPG_PASSPHRASE</filename> variables in the
  9304. previous example, two optional variables related to signing
  9305. exist:
  9306. <itemizedlist>
  9307. <listitem><para>
  9308. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  9309. Specifies a <filename>gpg</filename> binary/wrapper
  9310. that is executed when the package is signed.
  9311. </para></listitem>
  9312. <listitem><para>
  9313. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  9314. Specifies the <filename>gpg</filename> home
  9315. directory used when the package is signed.
  9316. </para></listitem>
  9317. </itemizedlist>
  9318. </para>
  9319. </section>
  9320. <section id='processing-package-feeds'>
  9321. <title>Processing Package Feeds</title>
  9322. <para>
  9323. In addition to being able to sign RPM packages, you can
  9324. also enable signed package feeds for IPK and RPM packages.
  9325. </para>
  9326. <para>
  9327. The steps you need to take to enable signed package feed
  9328. use are similar to the steps used to sign RPM packages.
  9329. You must define the following in your
  9330. <filename>local.config</filename> or
  9331. <filename>distro.config</filename> file:
  9332. <literallayout class='monospaced'>
  9333. INHERIT += "sign_package_feed"
  9334. PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>"
  9335. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>"
  9336. </literallayout>
  9337. For signed package feeds, the passphrase must exist in a
  9338. separate file, which is pointed to by the
  9339. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  9340. variable.
  9341. Regarding security, keeping a plain text passphrase out of
  9342. the configuration is more secure.
  9343. </para>
  9344. <para>
  9345. Aside from the
  9346. <filename>PACKAGE_FEED_GPG_NAME</filename> and
  9347. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  9348. variables, three optional variables related to signed
  9349. package feeds exist:
  9350. <itemizedlist>
  9351. <listitem><para>
  9352. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  9353. Specifies a <filename>gpg</filename> binary/wrapper
  9354. that is executed when the package is signed.
  9355. </para></listitem>
  9356. <listitem><para>
  9357. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  9358. Specifies the <filename>gpg</filename> home
  9359. directory used when the package is signed.
  9360. </para></listitem>
  9361. <listitem><para>
  9362. <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis>
  9363. Specifies the type of <filename>gpg</filename>
  9364. signature.
  9365. This variable applies only to RPM and IPK package
  9366. feeds.
  9367. Allowable values for the
  9368. <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>
  9369. are "ASC", which is the default and specifies ascii
  9370. armored, and "BIN", which specifies binary.
  9371. </para></listitem>
  9372. </itemizedlist>
  9373. </para>
  9374. </section>
  9375. </section>
  9376. <section id='testing-packages-with-ptest'>
  9377. <title>Testing Packages With ptest</title>
  9378. <para>
  9379. A Package Test (ptest) runs tests against packages built
  9380. by the OpenEmbedded build system on the target machine.
  9381. A ptest contains at least two items: the actual test, and
  9382. a shell script (<filename>run-ptest</filename>) that starts
  9383. the test.
  9384. The shell script that starts the test must not contain
  9385. the actual test - the script only starts the test.
  9386. On the other hand, the test can be anything from a simple
  9387. shell script that runs a binary and checks the output to
  9388. an elaborate system of test binaries and data files.
  9389. </para>
  9390. <para>
  9391. The test generates output in the format used by
  9392. Automake:
  9393. <literallayout class='monospaced'>
  9394. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  9395. </literallayout>
  9396. where the result can be <filename>PASS</filename>,
  9397. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  9398. and the testname can be any identifying string.
  9399. </para>
  9400. <para>
  9401. For a list of Yocto Project recipes that are already
  9402. enabled with ptest, see the
  9403. <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink>
  9404. wiki page.
  9405. <note>
  9406. A recipe is "ptest-enabled" if it inherits the
  9407. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  9408. class.
  9409. </note>
  9410. </para>
  9411. <section id='adding-ptest-to-your-build'>
  9412. <title>Adding ptest to Your Build</title>
  9413. <para>
  9414. To add package testing to your build, add the
  9415. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  9416. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  9417. variables to your <filename>local.conf</filename> file,
  9418. which is found in the
  9419. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  9420. <literallayout class='monospaced'>
  9421. DISTRO_FEATURES_append = " ptest"
  9422. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  9423. </literallayout>
  9424. Once your build is complete, the ptest files are installed
  9425. into the
  9426. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  9427. directory within the image, where
  9428. <filename><replaceable>package</replaceable></filename>
  9429. is the name of the package.
  9430. </para>
  9431. </section>
  9432. <section id='running-ptest'>
  9433. <title>Running ptest</title>
  9434. <para>
  9435. The <filename>ptest-runner</filename> package installs a
  9436. shell script that loops through all installed ptest test
  9437. suites and runs them in sequence.
  9438. Consequently, you might want to add this package to
  9439. your image.
  9440. </para>
  9441. </section>
  9442. <section id='getting-your-package-ready'>
  9443. <title>Getting Your Package Ready</title>
  9444. <para>
  9445. In order to enable a recipe to run installed ptests
  9446. on target hardware,
  9447. you need to prepare the recipes that build the packages
  9448. you want to test.
  9449. Here is what you have to do for each recipe:
  9450. <itemizedlist>
  9451. <listitem><para><emphasis>Be sure the recipe
  9452. inherits the
  9453. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  9454. class:</emphasis>
  9455. Include the following line in each recipe:
  9456. <literallayout class='monospaced'>
  9457. inherit ptest
  9458. </literallayout>
  9459. </para></listitem>
  9460. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  9461. This script starts your test.
  9462. Locate the script where you will refer to it
  9463. using
  9464. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  9465. Here is an example that starts a test for
  9466. <filename>dbus</filename>:
  9467. <literallayout class='monospaced'>
  9468. #!/bin/sh
  9469. cd test
  9470. make -k runtest-TESTS
  9471. </literallayout>
  9472. </para></listitem>
  9473. <listitem><para><emphasis>Ensure dependencies are
  9474. met:</emphasis>
  9475. If the test adds build or runtime dependencies
  9476. that normally do not exist for the package
  9477. (such as requiring "make" to run the test suite),
  9478. use the
  9479. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  9480. and
  9481. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  9482. variables in your recipe in order for the package
  9483. to meet the dependencies.
  9484. Here is an example where the package has a runtime
  9485. dependency on "make":
  9486. <literallayout class='monospaced'>
  9487. RDEPENDS_${PN}-ptest += "make"
  9488. </literallayout>
  9489. </para></listitem>
  9490. <listitem><para><emphasis>Add a function to build the
  9491. test suite:</emphasis>
  9492. Not many packages support cross-compilation of
  9493. their test suites.
  9494. Consequently, you usually need to add a
  9495. cross-compilation function to the package.
  9496. </para>
  9497. <para>Many packages based on Automake compile and
  9498. run the test suite by using a single command
  9499. such as <filename>make check</filename>.
  9500. However, the host <filename>make check</filename>
  9501. builds and runs on the same computer, while
  9502. cross-compiling requires that the package is built
  9503. on the host but executed for the target
  9504. architecture (though often, as in the case for
  9505. ptest, the execution occurs on the host).
  9506. The built version of Automake that ships with the
  9507. Yocto Project includes a patch that separates
  9508. building and execution.
  9509. Consequently, packages that use the unaltered,
  9510. patched version of <filename>make check</filename>
  9511. automatically cross-compiles.</para>
  9512. <para>Regardless, you still must add a
  9513. <filename>do_compile_ptest</filename> function to
  9514. build the test suite.
  9515. Add a function similar to the following to your
  9516. recipe:
  9517. <literallayout class='monospaced'>
  9518. do_compile_ptest() {
  9519. oe_runmake buildtest-TESTS
  9520. }
  9521. </literallayout>
  9522. </para></listitem>
  9523. <listitem><para><emphasis>Ensure special configurations
  9524. are set:</emphasis>
  9525. If the package requires special configurations
  9526. prior to compiling the test code, you must
  9527. insert a <filename>do_configure_ptest</filename>
  9528. function into the recipe.
  9529. </para></listitem>
  9530. <listitem><para><emphasis>Install the test
  9531. suite:</emphasis>
  9532. The <filename>ptest</filename> class
  9533. automatically copies the file
  9534. <filename>run-ptest</filename> to the target and
  9535. then runs make <filename>install-ptest</filename>
  9536. to run the tests.
  9537. If this is not enough, you need to create a
  9538. <filename>do_install_ptest</filename> function and
  9539. make sure it gets called after the
  9540. "make install-ptest" completes.
  9541. </para></listitem>
  9542. </itemizedlist>
  9543. </para>
  9544. </section>
  9545. </section>
  9546. </section>
  9547. <section id='efficiently-fetching-source-files-during-a-build'>
  9548. <title>Efficiently Fetching Source Files During a Build</title>
  9549. <para>
  9550. The OpenEmbedded build system works with source files located
  9551. through the
  9552. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  9553. variable.
  9554. When you build something using BitBake, a big part of the operation
  9555. is locating and downloading all the source tarballs.
  9556. For images, downloading all the source for various packages can
  9557. take a significant amount of time.
  9558. </para>
  9559. <para>
  9560. This section shows you how you can use mirrors to speed up
  9561. fetching source files and how you can pre-fetch files all of which
  9562. leads to more efficient use of resources and time.
  9563. </para>
  9564. <section id='setting-up-effective-mirrors'>
  9565. <title>Setting up Effective Mirrors</title>
  9566. <para>
  9567. A good deal that goes into a Yocto Project
  9568. build is simply downloading all of the source tarballs.
  9569. Maybe you have been working with another build system
  9570. (OpenEmbedded or Angstrom) for which you have built up a
  9571. sizable directory of source tarballs.
  9572. Or, perhaps someone else has such a directory for which you
  9573. have read access.
  9574. If so, you can save time by adding statements to your
  9575. configuration file so that the build process checks local
  9576. directories first for existing tarballs before checking the
  9577. Internet.
  9578. </para>
  9579. <para>
  9580. Here is an efficient way to set it up in your
  9581. <filename>local.conf</filename> file:
  9582. <literallayout class='monospaced'>
  9583. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  9584. INHERIT += "own-mirrors"
  9585. BB_GENERATE_MIRROR_TARBALLS = "1"
  9586. # BB_NO_NETWORK = "1"
  9587. </literallayout>
  9588. </para>
  9589. <para>
  9590. In the previous example, the
  9591. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  9592. variable causes the OpenEmbedded build system to generate
  9593. tarballs of the Git repositories and store them in the
  9594. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  9595. directory.
  9596. Due to performance reasons, generating and storing these
  9597. tarballs is not the build system's default behavior.
  9598. </para>
  9599. <para>
  9600. You can also use the
  9601. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  9602. variable.
  9603. For an example, see the variable's glossary entry in the
  9604. Yocto Project Reference Manual.
  9605. </para>
  9606. </section>
  9607. <section id='getting-source-files-and-suppressing-the-build'>
  9608. <title>Getting Source Files and Suppressing the Build</title>
  9609. <para>
  9610. Another technique you can use to ready yourself for a
  9611. successive string of build operations, is to pre-fetch
  9612. all the source files without actually starting a build.
  9613. This technique lets you work through any download issues
  9614. and ultimately gathers all the source files into your
  9615. download directory
  9616. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  9617. which is located with
  9618. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  9619. </para>
  9620. <para>
  9621. Use the following BitBake command form to fetch all the
  9622. necessary sources without starting the build:
  9623. <literallayout class='monospaced'>
  9624. $ bitbake -c <replaceable>target</replaceable> runall="fetch"
  9625. </literallayout>
  9626. This variation of the BitBake command guarantees that you
  9627. have all the sources for that BitBake target should you
  9628. disconnect from the Internet and want to do the build
  9629. later offline.
  9630. </para>
  9631. </section>
  9632. </section>
  9633. <section id="selecting-an-initialization-manager">
  9634. <title>Selecting an Initialization Manager</title>
  9635. <para>
  9636. By default, the Yocto Project uses SysVinit as the initialization
  9637. manager.
  9638. However, support also exists for systemd,
  9639. which is a full replacement for init with
  9640. parallel starting of services, reduced shell overhead and other
  9641. features that are used by many distributions.
  9642. </para>
  9643. <para>
  9644. If you want to use SysVinit, you do
  9645. not have to do anything.
  9646. But, if you want to use systemd, you must
  9647. take some steps as described in the following sections.
  9648. </para>
  9649. <section id='using-systemd-exclusively'>
  9650. <title>Using systemd Exclusively</title>
  9651. <para>
  9652. Set the these variables in your distribution configuration
  9653. file as follows:
  9654. <literallayout class='monospaced'>
  9655. DISTRO_FEATURES_append = " systemd"
  9656. VIRTUAL-RUNTIME_init_manager = "systemd"
  9657. </literallayout>
  9658. You can also prevent the SysVinit
  9659. distribution feature from
  9660. being automatically enabled as follows:
  9661. <literallayout class='monospaced'>
  9662. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  9663. </literallayout>
  9664. Doing so removes any redundant SysVinit scripts.
  9665. </para>
  9666. <para>
  9667. To remove initscripts from your image altogether,
  9668. set this variable also:
  9669. <literallayout class='monospaced'>
  9670. VIRTUAL-RUNTIME_initscripts = ""
  9671. </literallayout>
  9672. </para>
  9673. <para>
  9674. For information on the backfill variable, see
  9675. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  9676. </para>
  9677. </section>
  9678. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  9679. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  9680. <para>
  9681. Set these variables in your distribution configuration
  9682. file as follows:
  9683. <literallayout class='monospaced'>
  9684. DISTRO_FEATURES_append = " systemd"
  9685. VIRTUAL-RUNTIME_init_manager = "systemd"
  9686. </literallayout>
  9687. Doing so causes your main image to use the
  9688. <filename>packagegroup-core-boot.bb</filename> recipe and
  9689. systemd.
  9690. The rescue/minimal image cannot use this package group.
  9691. However, it can install SysVinit
  9692. and the appropriate packages will have support for both
  9693. systemd and SysVinit.
  9694. </para>
  9695. </section>
  9696. </section>
  9697. <section id="selecting-dev-manager">
  9698. <title>Selecting a Device Manager</title>
  9699. <para>
  9700. The Yocto Project provides multiple ways to manage the device
  9701. manager (<filename>/dev</filename>):
  9702. <itemizedlist>
  9703. <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis>
  9704. For this case, the <filename>/dev</filename> directory
  9705. is persistent and the required device nodes are created
  9706. during the build.
  9707. </para></listitem>
  9708. <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis>
  9709. For this case, the <filename>/dev</filename> directory
  9710. is provided by the kernel as an in-memory file system and
  9711. is automatically populated by the kernel at runtime.
  9712. Additional configuration of device nodes is done in user
  9713. space by a device manager like
  9714. <filename>udev</filename> or
  9715. <filename>busybox-mdev</filename>.
  9716. </para></listitem>
  9717. </itemizedlist>
  9718. </para>
  9719. <section id="static-dev-management">
  9720. <title>Using Persistent and Pre-Populated<filename>/dev</filename></title>
  9721. <para>
  9722. To use the static method for device population, you need to
  9723. set the
  9724. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  9725. variable to "0" as follows:
  9726. <literallayout class='monospaced'>
  9727. USE_DEVFS = "0"
  9728. </literallayout>
  9729. </para>
  9730. <para>
  9731. The content of the resulting <filename>/dev</filename>
  9732. directory is defined in a Device Table file.
  9733. The
  9734. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink>
  9735. variable defines the Device Table to use and should be set
  9736. in the machine or distro configuration file.
  9737. Alternatively, you can set this variable in your
  9738. <filename>local.conf</filename> configuration file.
  9739. </para>
  9740. <para>
  9741. If you do not define the
  9742. <filename>IMAGE_DEVICE_TABLES</filename> variable, the default
  9743. <filename>device_table-minimal.txt</filename> is used:
  9744. <literallayout class='monospaced'>
  9745. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  9746. </literallayout>
  9747. </para>
  9748. <para>
  9749. The population is handled by the <filename>makedevs</filename>
  9750. utility during image creation:
  9751. </para>
  9752. </section>
  9753. <section id="devtmpfs-dev-management">
  9754. <title>Using <filename>devtmpfs</filename> and a Device Manager</title>
  9755. <para>
  9756. To use the dynamic method for device population, you need to
  9757. use (or be sure to set) the
  9758. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  9759. variable to "1", which is the default:
  9760. <literallayout class='monospaced'>
  9761. USE_DEVFS = "1"
  9762. </literallayout>
  9763. With this setting, the resulting <filename>/dev</filename>
  9764. directory is populated by the kernel using
  9765. <filename>devtmpfs</filename>.
  9766. Make sure the corresponding kernel configuration variable
  9767. <filename>CONFIG_DEVTMPFS</filename> is set when building
  9768. you build a Linux kernel.
  9769. </para>
  9770. <para>
  9771. All devices created by <filename>devtmpfs</filename> will be
  9772. owned by <filename>root</filename> and have permissions
  9773. <filename>0600</filename>.
  9774. </para>
  9775. <para>
  9776. To have more control over the device nodes, you can use a
  9777. device manager like <filename>udev</filename> or
  9778. <filename>busybox-mdev</filename>.
  9779. You choose the device manager by defining the
  9780. <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable
  9781. in your machine or distro configuration file.
  9782. Alternatively, you can set this variable in your
  9783. <filename>local.conf</filename> configuration file:
  9784. <literallayout class='monospaced'>
  9785. VIRTUAL-RUNTIME_dev_manager = "udev"
  9786. # Some alternative values
  9787. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  9788. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  9789. </literallayout>
  9790. </para>
  9791. </section>
  9792. </section>
  9793. <section id="platdev-appdev-srcrev">
  9794. <title>Using an External SCM</title>
  9795. <para>
  9796. If you're working on a recipe that pulls from an external Source
  9797. Code Manager (SCM), it is possible to have the OpenEmbedded build
  9798. system notice new recipe changes added to the SCM and then build
  9799. the resulting packages that depend on the new recipes by using
  9800. the latest versions.
  9801. This only works for SCMs from which it is possible to get a
  9802. sensible revision number for changes.
  9803. Currently, you can do this with Apache Subversion (SVN), Git, and
  9804. Bazaar (BZR) repositories.
  9805. </para>
  9806. <para>
  9807. To enable this behavior, the
  9808. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  9809. of the recipe needs to reference
  9810. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  9811. Here is an example:
  9812. <literallayout class='monospaced'>
  9813. PV = "1.2.3+git${SRCPV}"
  9814. </literallayout>
  9815. Then, you can add the following to your
  9816. <filename>local.conf</filename>:
  9817. <literallayout class='monospaced'>
  9818. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  9819. </literallayout>
  9820. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  9821. is the name of the recipe for which you want to enable automatic source
  9822. revision updating.
  9823. </para>
  9824. <para>
  9825. If you do not want to update your local configuration file, you can
  9826. add the following directly to the recipe to finish enabling
  9827. the feature:
  9828. <literallayout class='monospaced'>
  9829. SRCREV = "${AUTOREV}"
  9830. </literallayout>
  9831. </para>
  9832. <para>
  9833. The Yocto Project provides a distribution named
  9834. <filename>poky-bleeding</filename>, whose configuration
  9835. file contains the line:
  9836. <literallayout class='monospaced'>
  9837. require conf/distro/include/poky-floating-revisions.inc
  9838. </literallayout>
  9839. This line pulls in the listed include file that contains
  9840. numerous lines of exactly that form:
  9841. <literallayout class='monospaced'>
  9842. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  9843. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  9844. #SRCREV_pn-opkg ?= "${AUTOREV}"
  9845. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  9846. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  9847. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  9848. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  9849. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  9850. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  9851. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  9852. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  9853. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  9854. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  9855. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  9856. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  9857. SRCREV_pn-screenshot ?= "${AUTOREV}"
  9858. .
  9859. .
  9860. .
  9861. </literallayout>
  9862. These lines allow you to experiment with building a
  9863. distribution that tracks the latest development source
  9864. for numerous packages.
  9865. <note><title>Caution</title>
  9866. The <filename>poky-bleeding</filename> distribution
  9867. is not tested on a regular basis.
  9868. Keep this in mind if you use it.
  9869. </note>
  9870. </para>
  9871. </section>
  9872. <section id='creating-a-read-only-root-filesystem'>
  9873. <title>Creating a Read-Only Root Filesystem</title>
  9874. <para>
  9875. Suppose, for security reasons, you need to disable
  9876. your target device's root filesystem's write permissions
  9877. (i.e. you need a read-only root filesystem).
  9878. Or, perhaps you are running the device's operating system
  9879. from a read-only storage device.
  9880. For either case, you can customize your image for
  9881. that behavior.
  9882. </para>
  9883. <note>
  9884. Supporting a read-only root filesystem requires that the system and
  9885. applications do not try to write to the root filesystem.
  9886. You must configure all parts of the target system to write
  9887. elsewhere, or to gracefully fail in the event of attempting to
  9888. write to the root filesystem.
  9889. </note>
  9890. <section id='creating-the-root-filesystem'>
  9891. <title>Creating the Root Filesystem</title>
  9892. <para>
  9893. To create the read-only root filesystem, simply add the
  9894. "read-only-rootfs" feature to your image.
  9895. Using either of the following statements in your
  9896. image recipe or from within the
  9897. <filename>local.conf</filename> file found in the
  9898. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9899. causes the build system to create a read-only root filesystem:
  9900. <literallayout class='monospaced'>
  9901. IMAGE_FEATURES = "read-only-rootfs"
  9902. </literallayout>
  9903. or
  9904. <literallayout class='monospaced'>
  9905. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  9906. </literallayout>
  9907. </para>
  9908. <para>
  9909. For more information on how to use these variables, see the
  9910. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  9911. section.
  9912. For information on the variables, see
  9913. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  9914. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  9915. </para>
  9916. </section>
  9917. <section id='post-installation-scripts'>
  9918. <title>Post-Installation Scripts</title>
  9919. <para>
  9920. It is very important that you make sure all
  9921. post-Installation (<filename>pkg_postinst</filename>) scripts
  9922. for packages that are installed into the image can be run
  9923. at the time when the root filesystem is created during the
  9924. build on the host system.
  9925. These scripts cannot attempt to run during first-boot on the
  9926. target device.
  9927. With the "read-only-rootfs" feature enabled,
  9928. the build system checks during root filesystem creation to make
  9929. sure all post-installation scripts succeed.
  9930. If any of these scripts still need to be run after the root
  9931. filesystem is created, the build immediately fails.
  9932. These build-time checks ensure that the build fails
  9933. rather than the target device fails later during its
  9934. initial boot operation.
  9935. </para>
  9936. <para>
  9937. Most of the common post-installation scripts generated by the
  9938. build system for the out-of-the-box Yocto Project are engineered
  9939. so that they can run during root filesystem creation
  9940. (e.g. post-installation scripts for caching fonts).
  9941. However, if you create and add custom scripts, you need
  9942. to be sure they can be run during this file system creation.
  9943. </para>
  9944. <para>
  9945. Here are some common problems that prevent
  9946. post-installation scripts from running during root filesystem
  9947. creation:
  9948. <itemizedlist>
  9949. <listitem><para>
  9950. <emphasis>Not using $D in front of absolute
  9951. paths:</emphasis>
  9952. The build system defines
  9953. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  9954. when the root filesystem is created.
  9955. Furthermore, <filename>$D</filename> is blank when the
  9956. script is run on the target device.
  9957. This implies two purposes for <filename>$D</filename>:
  9958. ensuring paths are valid in both the host and target
  9959. environments, and checking to determine which
  9960. environment is being used as a method for taking
  9961. appropriate actions.
  9962. </para></listitem>
  9963. <listitem><para>
  9964. <emphasis>Attempting to run processes that are
  9965. specific to or dependent on the target
  9966. architecture:</emphasis>
  9967. You can work around these attempts by using native
  9968. tools, which run on the host system,
  9969. to accomplish the same tasks, or
  9970. by alternatively running the processes under QEMU,
  9971. which has the <filename>qemu_run_binary</filename>
  9972. function.
  9973. For more information, see the
  9974. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  9975. class.</para></listitem>
  9976. </itemizedlist>
  9977. </para>
  9978. </section>
  9979. <section id='areas-with-write-access'>
  9980. <title>Areas With Write Access</title>
  9981. <para>
  9982. With the "read-only-rootfs" feature enabled,
  9983. any attempt by the target to write to the root filesystem at
  9984. runtime fails.
  9985. Consequently, you must make sure that you configure processes
  9986. and applications that attempt these types of writes do so
  9987. to directories with write access (e.g.
  9988. <filename>/tmp</filename> or <filename>/var/run</filename>).
  9989. </para>
  9990. </section>
  9991. </section>
  9992. <section id='maintaining-build-output-quality'>
  9993. <title>Maintaining Build Output Quality</title>
  9994. <para>
  9995. Many factors can influence the quality of a build.
  9996. For example, if you upgrade a recipe to use a new version of an
  9997. upstream software package or you experiment with some new
  9998. configuration options, subtle changes can occur that you might
  9999. not detect until later.
  10000. Consider the case where your recipe is using a newer version of
  10001. an upstream package.
  10002. In this case, a new version of a piece of software might
  10003. introduce an optional dependency on another library, which is
  10004. auto-detected.
  10005. If that library has already been built when the software is
  10006. building, the software will link to the built library and that
  10007. library will be pulled into your image along with the new
  10008. software even if you did not want the library.
  10009. </para>
  10010. <para>
  10011. The
  10012. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-buildhistory'><filename>buildhistory</filename></ulink>
  10013. class exists to help you maintain the quality of your build
  10014. output.
  10015. You can use the class to highlight unexpected and possibly
  10016. unwanted changes in the build output.
  10017. When you enable build history, it records information about the
  10018. contents of each package and image and then commits that
  10019. information to a local Git repository where you can examine
  10020. the information.
  10021. </para>
  10022. <para>
  10023. The remainder of this section describes the following:
  10024. <itemizedlist>
  10025. <listitem><para>
  10026. How you can enable and disable build history
  10027. </para></listitem>
  10028. <listitem><para>
  10029. How to understand what the build history contains
  10030. </para></listitem>
  10031. <listitem><para>
  10032. How to limit the information used for build history
  10033. </para></listitem>
  10034. <listitem><para>
  10035. How to examine the build history from both a
  10036. command-line and web interface
  10037. </para></listitem>
  10038. </itemizedlist>
  10039. </para>
  10040. <section id='enabling-and-disabling-build-history'>
  10041. <title>Enabling and Disabling Build History</title>
  10042. <para>
  10043. Build history is disabled by default.
  10044. To enable it, add the following <filename>INHERIT</filename>
  10045. statement and set the
  10046. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink>
  10047. variable to "1" at the end of your
  10048. <filename>conf/local.conf</filename> file found in the
  10049. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  10050. <literallayout class='monospaced'>
  10051. INHERIT += "buildhistory"
  10052. BUILDHISTORY_COMMIT = "1"
  10053. </literallayout>
  10054. Enabling build history as previously described causes the
  10055. OpenEmbedded build system to collect build output information
  10056. and commit it as a single commit to a local
  10057. <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>
  10058. repository.
  10059. <note>
  10060. Enabling build history increases your build times slightly,
  10061. particularly for images, and increases the amount of disk
  10062. space used during the build.
  10063. </note>
  10064. </para>
  10065. <para>
  10066. You can disable build history by removing the previous
  10067. statements from your <filename>conf/local.conf</filename>
  10068. file.
  10069. </para>
  10070. </section>
  10071. <section id='understanding-what-the-build-history-contains'>
  10072. <title>Understanding What the Build History Contains</title>
  10073. <para>
  10074. Build history information is kept in
  10075. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink><filename>}/buildhistory</filename>
  10076. in the Build Directory as defined by the
  10077. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></ulink>
  10078. variable.
  10079. The following is an example abbreviated listing:
  10080. <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" />
  10081. </para>
  10082. <para>
  10083. At the top level, a <filename>metadata-revs</filename>
  10084. file exists that lists the revisions of the repositories for
  10085. the enabled layers when the build was produced.
  10086. The rest of the data splits into separate
  10087. <filename>packages</filename>, <filename>images</filename>
  10088. and <filename>sdk</filename> directories, the contents of
  10089. which are described as follows.
  10090. </para>
  10091. <section id='build-history-package-information'>
  10092. <title>Build History Package Information</title>
  10093. <para>
  10094. The history for each package contains a text file that has
  10095. name-value pairs with information about the package.
  10096. For example,
  10097. <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename>
  10098. contains the following:
  10099. <literallayout class='monospaced'>
  10100. PV = 1.22.1
  10101. PR = r32
  10102. RPROVIDES =
  10103. RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
  10104. RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
  10105. PKGSIZE = 540168
  10106. FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
  10107. /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
  10108. /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
  10109. /usr/share/pixmaps /usr/share/applications /usr/share/idl \
  10110. /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
  10111. FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
  10112. /etc/busybox.links.nosuid /etc/busybox.links.suid
  10113. </literallayout>
  10114. Most of these name-value pairs correspond to variables
  10115. used to produce the package.
  10116. The exceptions are <filename>FILELIST</filename>, which
  10117. is the actual list of files in the package, and
  10118. <filename>PKGSIZE</filename>, which is the total size of
  10119. files in the package in bytes.
  10120. </para>
  10121. <para>
  10122. A file also exists that corresponds to the recipe from
  10123. which the package came (e.g.
  10124. <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>):
  10125. <literallayout class='monospaced'>
  10126. PV = 1.22.1
  10127. PR = r32
  10128. DEPENDS = initscripts kern-tools-native update-rc.d-native \
  10129. virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
  10130. virtual/libc virtual/update-alternatives
  10131. PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
  10132. busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
  10133. busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
  10134. </literallayout>
  10135. </para>
  10136. <para>
  10137. Finally, for those recipes fetched from a version control
  10138. system (e.g., Git), a file exists that lists source
  10139. revisions that are specified in the recipe and lists
  10140. the actual revisions used during the build.
  10141. Listed and actual revisions might differ when
  10142. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  10143. is set to
  10144. ${<ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>}.
  10145. Here is an example assuming
  10146. <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>):
  10147. <literallayout class='monospaced'>
  10148. # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  10149. SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  10150. # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  10151. SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  10152. </literallayout>
  10153. You can use the
  10154. <filename>buildhistory-collect-srcrevs</filename>
  10155. command with the <filename>-a</filename> option to
  10156. collect the stored <filename>SRCREV</filename> values
  10157. from build history and report them in a format suitable for
  10158. use in global configuration (e.g.,
  10159. <filename>local.conf</filename> or a distro include file)
  10160. to override floating <filename>AUTOREV</filename> values
  10161. to a fixed set of revisions.
  10162. Here is some example output from this command:
  10163. <literallayout class='monospaced'>
  10164. $ buildhistory-collect-srcrevs -a
  10165. # i586-poky-linux
  10166. SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
  10167. SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
  10168. SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
  10169. SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  10170. # x86_64-linux
  10171. SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
  10172. SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
  10173. SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
  10174. SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
  10175. SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
  10176. SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
  10177. SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
  10178. SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
  10179. SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  10180. # qemux86-poky-linux
  10181. SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  10182. SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
  10183. # all-poky-linux
  10184. SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
  10185. </literallayout>
  10186. <note>
  10187. Here are some notes on using the
  10188. <filename>buildhistory-collect-srcrevs</filename>
  10189. command:
  10190. <itemizedlist>
  10191. <listitem><para>
  10192. By default, only values where the
  10193. <filename>SRCREV</filename> was not hardcoded
  10194. (usually when <filename>AUTOREV</filename>
  10195. is used) are reported.
  10196. Use the <filename>-a</filename> option to
  10197. see all <filename>SRCREV</filename> values.
  10198. </para></listitem>
  10199. <listitem><para>
  10200. The output statements might not have any effect
  10201. if overrides are applied elsewhere in the
  10202. build system configuration.
  10203. Use the <filename>-f</filename> option to add
  10204. the <filename>forcevariable</filename> override
  10205. to each output line if you need to work around
  10206. this restriction.
  10207. </para></listitem>
  10208. <listitem><para>
  10209. The script does apply special handling when
  10210. building for multiple machines.
  10211. However, the script does place a comment before
  10212. each set of values that specifies which
  10213. triplet to which they belong as previously
  10214. shown (e.g.,
  10215. <filename>i586-poky-linux</filename>).
  10216. </para></listitem>
  10217. </itemizedlist>
  10218. </note>
  10219. </para>
  10220. </section>
  10221. <section id='build-history-image-information'>
  10222. <title>Build History Image Information</title>
  10223. <para>
  10224. The files produced for each image are as follows:
  10225. <itemizedlist>
  10226. <listitem><para>
  10227. <filename>image-files:</filename>
  10228. A directory containing selected files from the root
  10229. filesystem.
  10230. The files are defined by
  10231. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></ulink>.
  10232. </para></listitem>
  10233. <listitem><para>
  10234. <filename>build-id.txt:</filename>
  10235. Human-readable information about the build
  10236. configuration and metadata source revisions.
  10237. This file contains the full build header as printed
  10238. by BitBake.
  10239. </para></listitem>
  10240. <listitem><para>
  10241. <filename>*.dot:</filename>
  10242. Dependency graphs for the image that are
  10243. compatible with <filename>graphviz</filename>.
  10244. </para></listitem>
  10245. <listitem><para>
  10246. <filename>files-in-image.txt:</filename>
  10247. A list of files in the image with permissions,
  10248. owner, group, size, and symlink information.
  10249. </para></listitem>
  10250. <listitem><para>
  10251. <filename>image-info.txt:</filename>
  10252. A text file containing name-value pairs with
  10253. information about the image.
  10254. See the following listing example for more
  10255. information.
  10256. </para></listitem>
  10257. <listitem><para>
  10258. <filename>installed-package-names.txt:</filename>
  10259. A list of installed packages by name only.
  10260. </para></listitem>
  10261. <listitem><para>
  10262. <filename>installed-package-sizes.txt:</filename>
  10263. A list of installed packages ordered by size.
  10264. </para></listitem>
  10265. <listitem><para>
  10266. <filename>installed-packages.txt:</filename>
  10267. A list of installed packages with full package
  10268. filenames.
  10269. </para></listitem>
  10270. </itemizedlist>
  10271. <note>
  10272. Installed package information is able to be gathered
  10273. and produced even if package management is disabled
  10274. for the final image.
  10275. </note>
  10276. </para>
  10277. <para>
  10278. Here is an example of <filename>image-info.txt</filename>:
  10279. <literallayout class='monospaced'>
  10280. DISTRO = poky
  10281. DISTRO_VERSION = 1.7
  10282. USER_CLASSES = buildstats image-mklibs image-prelink
  10283. IMAGE_CLASSES = image_types
  10284. IMAGE_FEATURES = debug-tweaks
  10285. IMAGE_LINGUAS =
  10286. IMAGE_INSTALL = packagegroup-core-boot run-postinsts
  10287. BAD_RECOMMENDATIONS =
  10288. NO_RECOMMENDATIONS =
  10289. PACKAGE_EXCLUDE =
  10290. ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
  10291. write_image_manifest ; buildhistory_list_installed_image ; \
  10292. buildhistory_get_image_installed ; ssh_allow_empty_password; \
  10293. postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
  10294. IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
  10295. IMAGESIZE = 6900
  10296. </literallayout>
  10297. Other than <filename>IMAGESIZE</filename>, which is the
  10298. total size of the files in the image in Kbytes, the
  10299. name-value pairs are variables that may have influenced the
  10300. content of the image.
  10301. This information is often useful when you are trying to
  10302. determine why a change in the package or file
  10303. listings has occurred.
  10304. </para>
  10305. </section>
  10306. <section id='using-build-history-to-gather-image-information-only'>
  10307. <title>Using Build History to Gather Image Information Only</title>
  10308. <para>
  10309. As you can see, build history produces image information,
  10310. including dependency graphs, so you can see why something
  10311. was pulled into the image.
  10312. If you are just interested in this information and not
  10313. interested in collecting specific package or SDK
  10314. information, you can enable writing only image information
  10315. without any history by adding the following to your
  10316. <filename>conf/local.conf</filename> file found in the
  10317. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  10318. <literallayout class='monospaced'>
  10319. INHERIT += "buildhistory"
  10320. BUILDHISTORY_COMMIT = "0"
  10321. BUILDHISTORY_FEATURES = "image"
  10322. </literallayout>
  10323. Here, you set the
  10324. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></ulink>
  10325. variable to use the image feature only.
  10326. </para>
  10327. </section>
  10328. <section id='build-history-sdk-information'>
  10329. <title>Build History SDK Information</title>
  10330. <para>
  10331. Build history collects similar information on the contents
  10332. of SDKs
  10333. (e.g. <filename>bitbake -c populate_sdk imagename</filename>)
  10334. as compared to information it collects for images.
  10335. Furthermore, this information differs depending on whether
  10336. an extensible or standard SDK is being produced.
  10337. </para>
  10338. <para>
  10339. The following list shows the files produced for SDKs:
  10340. <itemizedlist>
  10341. <listitem><para>
  10342. <filename>files-in-sdk.txt:</filename>
  10343. A list of files in the SDK with permissions,
  10344. owner, group, size, and symlink information.
  10345. This list includes both the host and target parts
  10346. of the SDK.
  10347. </para></listitem>
  10348. <listitem><para>
  10349. <filename>sdk-info.txt:</filename>
  10350. A text file containing name-value pairs with
  10351. information about the SDK.
  10352. See the following listing example for more
  10353. information.
  10354. </para></listitem>
  10355. <listitem><para>
  10356. <filename>sstate-task-sizes.txt:</filename>
  10357. A text file containing name-value pairs with
  10358. information about task group sizes
  10359. (e.g. <filename>do_populate_sysroot</filename>
  10360. tasks have a total size).
  10361. The <filename>sstate-task-sizes.txt</filename> file
  10362. exists only when an extensible SDK is created.
  10363. </para></listitem>
  10364. <listitem><para>
  10365. <filename>sstate-package-sizes.txt:</filename>
  10366. A text file containing name-value pairs with
  10367. information for the shared-state packages and
  10368. sizes in the SDK.
  10369. The <filename>sstate-package-sizes.txt</filename>
  10370. file exists only when an extensible SDK is created.
  10371. </para></listitem>
  10372. <listitem><para>
  10373. <filename>sdk-files:</filename>
  10374. A folder that contains copies of the files
  10375. mentioned in
  10376. <filename>BUILDHISTORY_SDK_FILES</filename> if the
  10377. files are present in the output.
  10378. Additionally, the default value of
  10379. <filename>BUILDHISTORY_SDK_FILES</filename> is
  10380. specific to the extensible SDK although you can
  10381. set it differently if you would like to pull in
  10382. specific files from the standard SDK.</para>
  10383. <para>The default files are
  10384. <filename>conf/local.conf</filename>,
  10385. <filename>conf/bblayers.conf</filename>,
  10386. <filename>conf/auto.conf</filename>,
  10387. <filename>conf/locked-sigs.inc</filename>, and
  10388. <filename>conf/devtool.conf</filename>.
  10389. Thus, for an extensible SDK, these files get
  10390. copied into the <filename>sdk-files</filename>
  10391. directory.
  10392. </para></listitem>
  10393. <listitem><para>
  10394. The following information appears under
  10395. each of the <filename>host</filename>
  10396. and <filename>target</filename> directories
  10397. for the portions of the SDK that run on the host
  10398. and on the target, respectively:
  10399. <note>
  10400. The following files for the most part are empty
  10401. when producing an extensible SDK because this
  10402. type of SDK is not constructed from packages
  10403. as is the standard SDK.
  10404. </note>
  10405. <itemizedlist>
  10406. <listitem><para>
  10407. <filename>depends.dot:</filename>
  10408. Dependency graph for the SDK that is
  10409. compatible with
  10410. <filename>graphviz</filename>.
  10411. </para></listitem>
  10412. <listitem><para>
  10413. <filename>installed-package-names.txt:</filename>
  10414. A list of installed packages by name only.
  10415. </para></listitem>
  10416. <listitem><para>
  10417. <filename>installed-package-sizes.txt:</filename>
  10418. A list of installed packages ordered by size.
  10419. </para></listitem>
  10420. <listitem><para>
  10421. <filename>installed-packages.txt:</filename>
  10422. A list of installed packages with full
  10423. package filenames.
  10424. </para></listitem>
  10425. </itemizedlist>
  10426. </para></listitem>
  10427. </itemizedlist>
  10428. </para>
  10429. <para>
  10430. Here is an example of <filename>sdk-info.txt</filename>:
  10431. <literallayout class='monospaced'>
  10432. DISTRO = poky
  10433. DISTRO_VERSION = 1.3+snapshot-20130327
  10434. SDK_NAME = poky-glibc-i686-arm
  10435. SDK_VERSION = 1.3+snapshot
  10436. SDKMACHINE =
  10437. SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
  10438. BAD_RECOMMENDATIONS =
  10439. SDKSIZE = 352712
  10440. </literallayout>
  10441. Other than <filename>SDKSIZE</filename>, which is the
  10442. total size of the files in the SDK in Kbytes, the
  10443. name-value pairs are variables that might have influenced
  10444. the content of the SDK.
  10445. This information is often useful when you are trying to
  10446. determine why a change in the package or file listings
  10447. has occurred.
  10448. </para>
  10449. </section>
  10450. <section id='examining-build-history-information'>
  10451. <title>Examining Build History Information</title>
  10452. <para>
  10453. You can examine build history output from the command
  10454. line or from a web interface.
  10455. </para>
  10456. <para>
  10457. To see any changes that have occurred (assuming you have
  10458. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink><filename>&nbsp;= "1"</filename>),
  10459. you can simply use any Git command that allows you to
  10460. view the history of a repository.
  10461. Here is one method:
  10462. <literallayout class='monospaced'>
  10463. $ git log -p
  10464. </literallayout>
  10465. You need to realize, however, that this method does show
  10466. changes that are not significant (e.g. a package's size
  10467. changing by a few bytes).
  10468. </para>
  10469. <para>
  10470. A command-line tool called
  10471. <filename>buildhistory-diff</filename> does exist, though,
  10472. that queries the Git repository and prints just the
  10473. differences that might be significant in human-readable
  10474. form.
  10475. Here is an example:
  10476. <literallayout class='monospaced'>
  10477. $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
  10478. Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
  10479. /etc/anotherpkg.conf was added
  10480. /sbin/anotherpkg was added
  10481. * (installed-package-names.txt):
  10482. * anotherpkg was added
  10483. Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
  10484. anotherpkg was added
  10485. packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
  10486. * PR changed from "r0" to "r1"
  10487. * PV changed from "0.1.10" to "0.1.12"
  10488. packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
  10489. * PR changed from "r0" to "r1"
  10490. * PV changed from "0.1.10" to "0.1.12"
  10491. </literallayout>
  10492. <note>
  10493. The <filename>buildhistory-diff</filename> tool
  10494. requires the <filename>GitPython</filename> package.
  10495. Be sure to install it using Pip3 as follows:
  10496. <literallayout class='monospaced'>
  10497. $ pip3 install GitPython --user
  10498. </literallayout>
  10499. Alternatively, you can install
  10500. <filename>python3-git</filename> using the appropriate
  10501. distribution package manager (e.g.
  10502. <filename>apt-get</filename>, <filename>dnf</filename>,
  10503. or <filename>zipper</filename>).
  10504. </note>
  10505. </para>
  10506. <para>
  10507. To see changes to the build history using a web interface,
  10508. follow the instruction in the <filename>README</filename>
  10509. file here.
  10510. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>.
  10511. </para>
  10512. <para>
  10513. Here is a sample screenshot of the interface:
  10514. <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" />
  10515. </para>
  10516. </section>
  10517. </section>
  10518. </section>
  10519. <section id="performing-automated-runtime-testing">
  10520. <title>Performing Automated Runtime Testing</title>
  10521. <para>
  10522. The OpenEmbedded build system makes available a series of automated
  10523. tests for images to verify runtime functionality.
  10524. You can run these tests on either QEMU or actual target hardware.
  10525. Tests are written in Python making use of the
  10526. <filename>unittest</filename> module, and the majority of them
  10527. run commands on the target system over SSH.
  10528. This section describes how you set up the environment to use these
  10529. tests, run available tests, and write and add your own tests.
  10530. </para>
  10531. <para>
  10532. For information on the test and QA infrastructure available
  10533. within the Yocto Project, see the
  10534. "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>"
  10535. section in the Yocto Project Reference Manual.
  10536. </para>
  10537. <section id='enabling-tests'>
  10538. <title>Enabling Tests</title>
  10539. <para>
  10540. Depending on whether you are planning to run tests using
  10541. QEMU or on the hardware, you have to take
  10542. different steps to enable the tests.
  10543. See the following subsections for information on how to
  10544. enable both types of tests.
  10545. </para>
  10546. <section id='qemu-image-enabling-tests'>
  10547. <title>Enabling Runtime Tests on QEMU</title>
  10548. <para>
  10549. In order to run tests, you need to do the following:
  10550. <itemizedlist>
  10551. <listitem><para><emphasis>Set up to avoid interaction
  10552. with <filename>sudo</filename> for networking:</emphasis>
  10553. To accomplish this, you must do one of the
  10554. following:
  10555. <itemizedlist>
  10556. <listitem><para>Add
  10557. <filename>NOPASSWD</filename> for your user
  10558. in <filename>/etc/sudoers</filename> either for
  10559. all commands or just for
  10560. <filename>runqemu-ifup</filename>.
  10561. You must provide the full path as that can
  10562. change if you are using multiple clones of the
  10563. source repository.
  10564. <note>
  10565. On some distributions, you also need to
  10566. comment out "Defaults requiretty" in
  10567. <filename>/etc/sudoers</filename>.
  10568. </note></para></listitem>
  10569. <listitem><para>Manually configure a tap interface
  10570. for your system.</para></listitem>
  10571. <listitem><para>Run as root the script in
  10572. <filename>scripts/runqemu-gen-tapdevs</filename>,
  10573. which should generate a list of tap devices.
  10574. This is the option typically chosen for
  10575. Autobuilder-type environments.
  10576. <note><title>Notes</title>
  10577. <itemizedlist>
  10578. <listitem><para>
  10579. Be sure to use an absolute path
  10580. when calling this script
  10581. with sudo.
  10582. </para></listitem>
  10583. <listitem><para>
  10584. The package recipe
  10585. <filename>qemu-helper-native</filename>
  10586. is required to run this script.
  10587. Build the package using the
  10588. following command:
  10589. <literallayout class='monospaced'>
  10590. $ bitbake qemu-helper-native
  10591. </literallayout>
  10592. </para></listitem>
  10593. </itemizedlist>
  10594. </note>
  10595. </para></listitem>
  10596. </itemizedlist></para></listitem>
  10597. <listitem><para><emphasis>Set the
  10598. <filename>DISPLAY</filename> variable:</emphasis>
  10599. You need to set this variable so that you have an X
  10600. server available (e.g. start
  10601. <filename>vncserver</filename> for a headless machine).
  10602. </para></listitem>
  10603. <listitem><para><emphasis>Be sure your host's firewall
  10604. accepts incoming connections from
  10605. 192.168.7.0/24:</emphasis>
  10606. Some of the tests (in particular DNF tests) start
  10607. an HTTP server on a random high number port,
  10608. which is used to serve files to the target.
  10609. The DNF module serves
  10610. <filename>${WORKDIR}/oe-rootfs-repo</filename>
  10611. so it can run DNF channel commands.
  10612. That means your host's firewall
  10613. must accept incoming connections from 192.168.7.0/24,
  10614. which is the default IP range used for tap devices
  10615. by <filename>runqemu</filename>.</para></listitem>
  10616. <listitem><para><emphasis>Be sure your host has the
  10617. correct packages installed:</emphasis>
  10618. Depending your host's distribution, you need
  10619. to have the following packages installed:
  10620. <itemizedlist>
  10621. <listitem><para>Ubuntu and Debian:
  10622. <filename>sysstat</filename> and
  10623. <filename>iproute2</filename>
  10624. </para></listitem>
  10625. <listitem><para>OpenSUSE:
  10626. <filename>sysstat</filename> and
  10627. <filename>iproute2</filename>
  10628. </para></listitem>
  10629. <listitem><para>Fedora:
  10630. <filename>sysstat</filename> and
  10631. <filename>iproute</filename>
  10632. </para></listitem>
  10633. <listitem><para>CentOS:
  10634. <filename>sysstat</filename> and
  10635. <filename>iproute</filename>
  10636. </para></listitem>
  10637. </itemizedlist>
  10638. </para></listitem>
  10639. </itemizedlist>
  10640. </para>
  10641. <para>
  10642. Once you start running the tests, the following happens:
  10643. <orderedlist>
  10644. <listitem><para>A copy of the root filesystem is written
  10645. to <filename>${WORKDIR}/testimage</filename>.
  10646. </para></listitem>
  10647. <listitem><para>The image is booted under QEMU using the
  10648. standard <filename>runqemu</filename> script.
  10649. </para></listitem>
  10650. <listitem><para>A default timeout of 500 seconds occurs
  10651. to allow for the boot process to reach the login prompt.
  10652. You can change the timeout period by setting
  10653. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  10654. in the <filename>local.conf</filename> file.
  10655. </para></listitem>
  10656. <listitem><para>Once the boot process is reached and the
  10657. login prompt appears, the tests run.
  10658. The full boot log is written to
  10659. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  10660. </para></listitem>
  10661. <listitem><para>Each test module loads in the order found
  10662. in <filename>TEST_SUITES</filename>.
  10663. You can find the full output of the commands run over
  10664. SSH in
  10665. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  10666. </para></listitem>
  10667. <listitem><para>If no failures occur, the task running the
  10668. tests ends successfully.
  10669. You can find the output from the
  10670. <filename>unittest</filename> in the task log at
  10671. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  10672. </para></listitem>
  10673. </orderedlist>
  10674. </para>
  10675. </section>
  10676. <section id='hardware-image-enabling-tests'>
  10677. <title>Enabling Runtime Tests on Hardware</title>
  10678. <para>
  10679. The OpenEmbedded build system can run tests on real
  10680. hardware, and for certain devices it can also deploy
  10681. the image to be tested onto the device beforehand.
  10682. </para>
  10683. <para>
  10684. For automated deployment, a "master image" is installed
  10685. onto the hardware once as part of setup.
  10686. Then, each time tests are to be run, the following
  10687. occurs:
  10688. <orderedlist>
  10689. <listitem><para>The master image is booted into and
  10690. used to write the image to be tested to
  10691. a second partition.
  10692. </para></listitem>
  10693. <listitem><para>The device is then rebooted using an
  10694. external script that you need to provide.
  10695. </para></listitem>
  10696. <listitem><para>The device boots into the image to be
  10697. tested.
  10698. </para></listitem>
  10699. </orderedlist>
  10700. </para>
  10701. <para>
  10702. When running tests (independent of whether the image
  10703. has been deployed automatically or not), the device is
  10704. expected to be connected to a network on a
  10705. pre-determined IP address.
  10706. You can either use static IP addresses written into
  10707. the image, or set the image to use DHCP and have your
  10708. DHCP server on the test network assign a known IP address
  10709. based on the MAC address of the device.
  10710. </para>
  10711. <para>
  10712. In order to run tests on hardware, you need to set
  10713. <filename>TEST_TARGET</filename> to an appropriate value.
  10714. For QEMU, you do not have to change anything, the default
  10715. value is "QemuTarget".
  10716. For running tests on hardware, the following options exist:
  10717. <itemizedlist>
  10718. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  10719. Choose "SimpleRemoteTarget" if you are going to
  10720. run tests on a target system that is already
  10721. running the image to be tested and is available
  10722. on the network.
  10723. You can use "SimpleRemoteTarget" in conjunction
  10724. with either real hardware or an image running
  10725. within a separately started QEMU or any
  10726. other virtual machine manager.
  10727. </para></listitem>
  10728. <listitem><para><emphasis>"SystemdbootTarget":</emphasis>
  10729. Choose "SystemdbootTarget" if your hardware is
  10730. an EFI-based machine with
  10731. <filename>systemd-boot</filename> as bootloader and
  10732. <filename>core-image-testmaster</filename>
  10733. (or something similar) is installed.
  10734. Also, your hardware under test must be in a
  10735. DHCP-enabled network that gives it the same IP
  10736. address for each reboot.</para>
  10737. <para>If you choose "SystemdbootTarget", there are
  10738. additional requirements and considerations.
  10739. See the
  10740. "<link linkend='selecting-systemdboottarget'>Selecting SystemdbootTarget</link>"
  10741. section, which follows, for more information.
  10742. </para></listitem>
  10743. <listitem><para><emphasis>"BeagleBoneTarget":</emphasis>
  10744. Choose "BeagleBoneTarget" if you are deploying
  10745. images and running tests on the BeagleBone
  10746. "Black" or original "White" hardware.
  10747. For information on how to use these tests, see the
  10748. comments at the top of the BeagleBoneTarget
  10749. <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename>
  10750. file.
  10751. </para></listitem>
  10752. <listitem><para><emphasis>"EdgeRouterTarget":</emphasis>
  10753. Choose "EdgeRouterTarget" is you are deploying
  10754. images and running tests on the Ubiquiti Networks
  10755. EdgeRouter Lite.
  10756. For information on how to use these tests, see the
  10757. comments at the top of the EdgeRouterTarget
  10758. <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename>
  10759. file.
  10760. </para></listitem>
  10761. <listitem><para><emphasis>"GrubTarget":</emphasis>
  10762. Choose the "supports deploying images and running
  10763. tests on any generic PC that boots using GRUB.
  10764. For information on how to use these tests, see the
  10765. comments at the top of the GrubTarget
  10766. <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename>
  10767. file.
  10768. </para></listitem>
  10769. <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis>
  10770. Create your own custom target if you want to run
  10771. tests when you are deploying images and running
  10772. tests on a custom machine within your BSP layer.
  10773. To do this, you need to add a Python unit that
  10774. defines the target class under
  10775. <filename>lib/oeqa/controllers/</filename> within
  10776. your layer.
  10777. You must also provide an empty
  10778. <filename>__init__.py</filename>.
  10779. For examples, see files in
  10780. <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>.
  10781. </para></listitem>
  10782. </itemizedlist>
  10783. </para>
  10784. </section>
  10785. <section id='selecting-systemdboottarget'>
  10786. <title>Selecting SystemdbootTarget</title>
  10787. <para>
  10788. If you did not set <filename>TEST_TARGET</filename> to
  10789. "SystemdbootTarget", then you do not need any information
  10790. in this section.
  10791. You can skip down to the
  10792. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  10793. section.
  10794. </para>
  10795. <para>
  10796. If you did set <filename>TEST_TARGET</filename> to
  10797. "SystemdbootTarget", you also need to perform a one-time
  10798. setup of your master image by doing the following:
  10799. <orderedlist>
  10800. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  10801. Be sure that <filename>EFI_PROVIDER</filename>
  10802. is as follows:
  10803. <literallayout class='monospaced'>
  10804. EFI_PROVIDER = "systemd-boot"
  10805. </literallayout>
  10806. </para></listitem>
  10807. <listitem><para><emphasis>Build the master image:</emphasis>
  10808. Build the <filename>core-image-testmaster</filename>
  10809. image.
  10810. The <filename>core-image-testmaster</filename>
  10811. recipe is provided as an example for a
  10812. "master" image and you can customize the image
  10813. recipe as you would any other recipe.
  10814. </para>
  10815. <para>Here are the image recipe requirements:
  10816. <itemizedlist>
  10817. <listitem><para>Inherits
  10818. <filename>core-image</filename>
  10819. so that kernel modules are installed.
  10820. </para></listitem>
  10821. <listitem><para>Installs normal linux utilities
  10822. not busybox ones (e.g.
  10823. <filename>bash</filename>,
  10824. <filename>coreutils</filename>,
  10825. <filename>tar</filename>,
  10826. <filename>gzip</filename>, and
  10827. <filename>kmod</filename>).
  10828. </para></listitem>
  10829. <listitem><para>Uses a custom
  10830. Initial RAM Disk (initramfs) image with a
  10831. custom installer.
  10832. A normal image that you can install usually
  10833. creates a single rootfs partition.
  10834. This image uses another installer that
  10835. creates a specific partition layout.
  10836. Not all Board Support Packages (BSPs)
  10837. can use an installer.
  10838. For such cases, you need to manually create
  10839. the following partition layout on the
  10840. target:
  10841. <itemizedlist>
  10842. <listitem><para>First partition mounted
  10843. under <filename>/boot</filename>,
  10844. labeled "boot".
  10845. </para></listitem>
  10846. <listitem><para>The main rootfs
  10847. partition where this image gets
  10848. installed, which is mounted under
  10849. <filename>/</filename>.
  10850. </para></listitem>
  10851. <listitem><para>Another partition
  10852. labeled "testrootfs" where test
  10853. images get deployed.
  10854. </para></listitem>
  10855. </itemizedlist>
  10856. </para></listitem>
  10857. </itemizedlist>
  10858. </para></listitem>
  10859. <listitem><para><emphasis>Install image:</emphasis>
  10860. Install the image that you just built on the target
  10861. system.
  10862. </para></listitem>
  10863. </orderedlist>
  10864. </para>
  10865. <para>
  10866. The final thing you need to do when setting
  10867. <filename>TEST_TARGET</filename> to "SystemdbootTarget" is
  10868. to set up the test image:
  10869. <orderedlist>
  10870. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  10871. Make sure you have the following statements in
  10872. your <filename>local.conf</filename> file:
  10873. <literallayout class='monospaced'>
  10874. IMAGE_FSTYPES += "tar.gz"
  10875. INHERIT += "testimage"
  10876. TEST_TARGET = "SystemdbootTarget"
  10877. TEST_TARGET_IP = "192.168.2.3"
  10878. </literallayout>
  10879. </para></listitem>
  10880. <listitem><para><emphasis>Build your test image:</emphasis>
  10881. Use BitBake to build the image:
  10882. <literallayout class='monospaced'>
  10883. $ bitbake core-image-sato
  10884. </literallayout>
  10885. </para></listitem>
  10886. </orderedlist>
  10887. </para>
  10888. </section>
  10889. <section id='power-control'>
  10890. <title>Power Control</title>
  10891. <para>
  10892. For most hardware targets other than SimpleRemoteTarget,
  10893. you can control power:
  10894. <itemizedlist>
  10895. <listitem><para>
  10896. You can use
  10897. <filename>TEST_POWERCONTROL_CMD</filename>
  10898. together with
  10899. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  10900. as a command that runs on the host and does power
  10901. cycling.
  10902. The test code passes one argument to that command:
  10903. off, on or cycle (off then on).
  10904. Here is an example that could appear in your
  10905. <filename>local.conf</filename> file:
  10906. <literallayout class='monospaced'>
  10907. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  10908. </literallayout>
  10909. In this example, the expect script does the
  10910. following:
  10911. <literallayout class='monospaced'>
  10912. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  10913. </literallayout>
  10914. It then runs a Python script that controls power
  10915. for a label called <filename>nuc1</filename>.
  10916. <note>
  10917. You need to customize
  10918. <filename>TEST_POWERCONTROL_CMD</filename>
  10919. and
  10920. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  10921. for your own setup.
  10922. The one requirement is that it accepts
  10923. "on", "off", and "cycle" as the last argument.
  10924. </note>
  10925. </para></listitem>
  10926. <listitem><para>
  10927. When no command is defined, it connects to the
  10928. device over SSH and uses the classic reboot command
  10929. to reboot the device.
  10930. Classic reboot is fine as long as the machine
  10931. actually reboots (i.e. the SSH test has not
  10932. failed).
  10933. It is useful for scenarios where you have a simple
  10934. setup, typically with a single board, and where
  10935. some manual interaction is okay from time to time.
  10936. </para></listitem>
  10937. </itemizedlist>
  10938. If you have no hardware to automatically perform power
  10939. control but still wish to experiment with automated
  10940. hardware testing, you can use the dialog-power-control
  10941. script that shows a dialog prompting you to perform the
  10942. required power action.
  10943. This script requires either KDialog or Zenity to be
  10944. installed.
  10945. To use this script, set the
  10946. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink>
  10947. variable as follows:
  10948. <literallayout class='monospaced'>
  10949. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  10950. </literallayout>
  10951. </para>
  10952. </section>
  10953. <section id='serial-console-connection'>
  10954. <title>Serial Console Connection</title>
  10955. <para>
  10956. For test target classes requiring a serial console
  10957. to interact with the bootloader (e.g. BeagleBoneTarget,
  10958. EdgeRouterTarget, and GrubTarget), you need to
  10959. specify a command to use to connect to the serial console
  10960. of the target machine by using the
  10961. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink>
  10962. variable and optionally the
  10963. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink>
  10964. variable.
  10965. </para>
  10966. <para>
  10967. These cases could be a serial terminal program if the
  10968. machine is connected to a local serial port, or a
  10969. <filename>telnet</filename> or
  10970. <filename>ssh</filename> command connecting to a remote
  10971. console server.
  10972. Regardless of the case, the command simply needs to
  10973. connect to the serial console and forward that connection
  10974. to standard input and output as any normal terminal
  10975. program does.
  10976. For example, to use the picocom terminal program on
  10977. serial device <filename>/dev/ttyUSB0</filename>
  10978. at 115200bps, you would set the variable as follows:
  10979. <literallayout class='monospaced'>
  10980. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  10981. </literallayout>
  10982. For local devices where the serial port device disappears
  10983. when the device reboots, an additional "serdevtry" wrapper
  10984. script is provided.
  10985. To use this wrapper, simply prefix the terminal command
  10986. with
  10987. <filename>${COREBASE}/scripts/contrib/serdevtry</filename>:
  10988. <literallayout class='monospaced'>
  10989. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b
  10990. 115200 /dev/ttyUSB0"
  10991. </literallayout>
  10992. </para>
  10993. </section>
  10994. </section>
  10995. <section id="qemu-image-running-tests">
  10996. <title>Running Tests</title>
  10997. <para>
  10998. You can start the tests automatically or manually:
  10999. <itemizedlist>
  11000. <listitem><para><emphasis>Automatically running tests:</emphasis>
  11001. To run the tests automatically after the
  11002. OpenEmbedded build system successfully creates an image,
  11003. first set the
  11004. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink>
  11005. variable to "1" in your <filename>local.conf</filename>
  11006. file in the
  11007. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  11008. <literallayout class='monospaced'>
  11009. TEST_IMAGE = "1"
  11010. </literallayout>
  11011. Next, build your image.
  11012. If the image successfully builds, the tests will be
  11013. run:
  11014. <literallayout class='monospaced'>
  11015. bitbake core-image-sato
  11016. </literallayout></para></listitem>
  11017. <listitem><para><emphasis>Manually running tests:</emphasis>
  11018. To manually run the tests, first globally inherit the
  11019. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  11020. class by editing your <filename>local.conf</filename>
  11021. file:
  11022. <literallayout class='monospaced'>
  11023. INHERIT += "testimage"
  11024. </literallayout>
  11025. Next, use BitBake to run the tests:
  11026. <literallayout class='monospaced'>
  11027. bitbake -c testimage <replaceable>image</replaceable>
  11028. </literallayout></para></listitem>
  11029. </itemizedlist>
  11030. </para>
  11031. <para>
  11032. All test files reside in
  11033. <filename>meta/lib/oeqa/runtime</filename> in the
  11034. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  11035. A test name maps directly to a Python module.
  11036. Each test module may contain a number of individual tests.
  11037. Tests are usually grouped together by the area
  11038. tested (e.g tests for systemd reside in
  11039. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  11040. </para>
  11041. <para>
  11042. You can add tests to any layer provided you place them in the
  11043. proper area and you extend
  11044. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  11045. in the <filename>local.conf</filename> file as normal.
  11046. Be sure that tests reside in
  11047. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  11048. <note>
  11049. Be sure that module names do not collide with module names
  11050. used in the default set of test modules in
  11051. <filename>meta/lib/oeqa/runtime</filename>.
  11052. </note>
  11053. </para>
  11054. <para>
  11055. You can change the set of tests run by appending or overriding
  11056. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  11057. variable in <filename>local.conf</filename>.
  11058. Each name in <filename>TEST_SUITES</filename> represents a
  11059. required test for the image.
  11060. Test modules named within <filename>TEST_SUITES</filename>
  11061. cannot be skipped even if a test is not suitable for an image
  11062. (e.g. running the RPM tests on an image without
  11063. <filename>rpm</filename>).
  11064. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  11065. build system to try to run all tests that are suitable for the
  11066. image (i.e. each test module may elect to skip itself).
  11067. </para>
  11068. <para>
  11069. The order you list tests in <filename>TEST_SUITES</filename>
  11070. is important and influences test dependencies.
  11071. Consequently, tests that depend on other tests should be added
  11072. after the test on which they depend.
  11073. For example, since the <filename>ssh</filename> test
  11074. depends on the
  11075. <filename>ping</filename> test, "ssh" needs to come after
  11076. "ping" in the list.
  11077. The test class provides no re-ordering or dependency handling.
  11078. <note>
  11079. Each module can have multiple classes with multiple test
  11080. methods.
  11081. And, Python <filename>unittest</filename> rules apply.
  11082. </note>
  11083. </para>
  11084. <para>
  11085. Here are some things to keep in mind when running tests:
  11086. <itemizedlist>
  11087. <listitem><para>The default tests for the image are defined
  11088. as:
  11089. <literallayout class='monospaced'>
  11090. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  11091. </literallayout></para></listitem>
  11092. <listitem><para>Add your own test to the list of the
  11093. by using the following:
  11094. <literallayout class='monospaced'>
  11095. TEST_SUITES_append = " mytest"
  11096. </literallayout></para></listitem>
  11097. <listitem><para>Run a specific list of tests as follows:
  11098. <literallayout class='monospaced'>
  11099. TEST_SUITES = "test1 test2 test3"
  11100. </literallayout>
  11101. Remember, order is important.
  11102. Be sure to place a test that is dependent on another test
  11103. later in the order.</para></listitem>
  11104. </itemizedlist>
  11105. </para>
  11106. </section>
  11107. <section id="exporting-tests">
  11108. <title>Exporting Tests</title>
  11109. <para>
  11110. You can export tests so that they can run independently of
  11111. the build system.
  11112. Exporting tests is required if you want to be able to hand
  11113. the test execution off to a scheduler.
  11114. You can only export tests that are defined in
  11115. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  11116. </para>
  11117. <para>
  11118. If your image is already built, make sure the following are set
  11119. in your <filename>local.conf</filename> file:
  11120. <literallayout class='monospaced'>
  11121. INHERIT +="testexport"
  11122. TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>"
  11123. TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>"
  11124. </literallayout>
  11125. You can then export the tests with the following BitBake
  11126. command form:
  11127. <literallayout class='monospaced'>
  11128. $ bitbake <replaceable>image</replaceable> -c testexport
  11129. </literallayout>
  11130. Exporting the tests places them in the
  11131. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  11132. in
  11133. <filename>tmp/testexport/</filename><replaceable>image</replaceable>,
  11134. which is controlled by the
  11135. <filename>TEST_EXPORT_DIR</filename> variable.
  11136. </para>
  11137. <para>
  11138. You can now run the tests outside of the build environment:
  11139. <literallayout class='monospaced'>
  11140. $ cd tmp/testexport/<replaceable>image</replaceable>
  11141. $ ./runexported.py testdata.json
  11142. </literallayout>
  11143. </para>
  11144. <para>
  11145. Here is a complete example that shows IP addresses and uses
  11146. the <filename>core-image-sato</filename> image:
  11147. <literallayout class='monospaced'>
  11148. INHERIT +="testexport"
  11149. TEST_TARGET_IP = "192.168.7.2"
  11150. TEST_SERVER_IP = "192.168.7.1"
  11151. </literallayout>
  11152. Use BitBake to export the tests:
  11153. <literallayout class='monospaced'>
  11154. $ bitbake core-image-sato -c testexport
  11155. </literallayout>
  11156. Run the tests outside of the build environment using the
  11157. following:
  11158. <literallayout class='monospaced'>
  11159. $ cd tmp/testexport/core-image-sato
  11160. $ ./runexported.py testdata.json
  11161. </literallayout>
  11162. </para>
  11163. </section>
  11164. <section id="qemu-image-writing-new-tests">
  11165. <title>Writing New Tests</title>
  11166. <para>
  11167. As mentioned previously, all new test files need to be in the
  11168. proper place for the build system to find them.
  11169. New tests for additional functionality outside of the core
  11170. should be added to the layer that adds the functionality, in
  11171. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  11172. (as long as
  11173. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  11174. is extended in the layer's
  11175. <filename>layer.conf</filename> file as normal).
  11176. Just remember the following:
  11177. <itemizedlist>
  11178. <listitem><para>Filenames need to map directly to test
  11179. (module) names.
  11180. </para></listitem>
  11181. <listitem><para>Do not use module names that
  11182. collide with existing core tests.
  11183. </para></listitem>
  11184. <listitem><para>Minimally, an empty
  11185. <filename>__init__.py</filename> file must exist
  11186. in the runtime directory.
  11187. </para></listitem>
  11188. </itemizedlist>
  11189. </para>
  11190. <para>
  11191. To create a new test, start by copying an existing module
  11192. (e.g. <filename>syslog.py</filename> or
  11193. <filename>gcc.py</filename> are good ones to use).
  11194. Test modules can use code from
  11195. <filename>meta/lib/oeqa/utils</filename>, which are helper
  11196. classes.
  11197. </para>
  11198. <note>
  11199. Structure shell commands such that you rely on them and they
  11200. return a single code for success.
  11201. Be aware that sometimes you will need to parse the output.
  11202. See the <filename>df.py</filename> and
  11203. <filename>date.py</filename> modules for examples.
  11204. </note>
  11205. <para>
  11206. You will notice that all test classes inherit
  11207. <filename>oeRuntimeTest</filename>, which is found in
  11208. <filename>meta/lib/oetest.py</filename>.
  11209. This base class offers some helper attributes, which are
  11210. described in the following sections:
  11211. </para>
  11212. <section id='qemu-image-writing-tests-class-methods'>
  11213. <title>Class Methods</title>
  11214. <para>
  11215. Class methods are as follows:
  11216. <itemizedlist>
  11217. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  11218. Returns "True" if <filename>pkg</filename> is in the
  11219. installed package list of the image, which is based
  11220. on the manifest file that is generated during the
  11221. <filename>do_rootfs</filename> task.
  11222. </para></listitem>
  11223. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  11224. Returns "True" if the feature is in
  11225. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  11226. or
  11227. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  11228. </para></listitem>
  11229. </itemizedlist>
  11230. </para>
  11231. </section>
  11232. <section id='qemu-image-writing-tests-class-attributes'>
  11233. <title>Class Attributes</title>
  11234. <para>
  11235. Class attributes are as follows:
  11236. <itemizedlist>
  11237. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  11238. Equals "ps -ef" if <filename>procps</filename> is
  11239. installed in the image.
  11240. Otherwise, <filename>pscmd</filename> equals
  11241. "ps" (busybox).
  11242. </para></listitem>
  11243. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  11244. The called test context, which gives access to the
  11245. following attributes:
  11246. <itemizedlist>
  11247. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  11248. The BitBake datastore, which allows you to
  11249. use stuff such as
  11250. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  11251. </para></listitem>
  11252. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  11253. Used internally.
  11254. The tests do not need these.
  11255. </para></listitem>
  11256. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  11257. The absolute path to
  11258. <filename>meta/lib/oeqa/runtime/files</filename>,
  11259. which contains helper files for tests meant
  11260. for copying on the target such as small
  11261. files written in C for compilation.
  11262. </para></listitem>
  11263. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  11264. The target controller object used to deploy
  11265. and start an image on a particular target
  11266. (e.g. QemuTarget, SimpleRemote, and
  11267. SystemdbootTarget).
  11268. Tests usually use the following:
  11269. <itemizedlist>
  11270. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  11271. The target's IP address.
  11272. </para></listitem>
  11273. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  11274. The host's IP address, which is
  11275. usually used by the DNF test
  11276. suite.
  11277. </para></listitem>
  11278. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  11279. The single, most used method.
  11280. This command is a wrapper for:
  11281. <filename>ssh root@host "cmd"</filename>.
  11282. The command returns a tuple:
  11283. (status, output), which are what
  11284. their names imply - the return code
  11285. of "cmd" and whatever output
  11286. it produces.
  11287. The optional timeout argument
  11288. represents the number of seconds the
  11289. test should wait for "cmd" to
  11290. return.
  11291. If the argument is "None", the
  11292. test uses the default instance's
  11293. timeout period, which is 300
  11294. seconds.
  11295. If the argument is "0", the test
  11296. runs until the command returns.
  11297. </para></listitem>
  11298. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  11299. <filename>scp localpath root@ip:remotepath</filename>.
  11300. </para></listitem>
  11301. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  11302. <filename>scp root@host:remotepath localpath</filename>.
  11303. </para></listitem>
  11304. </itemizedlist></para></listitem>
  11305. </itemizedlist></para></listitem>
  11306. </itemizedlist>
  11307. </para>
  11308. </section>
  11309. <section id='qemu-image-writing-tests-instance-attributes'>
  11310. <title>Instance Attributes</title>
  11311. <para>
  11312. A single instance attribute exists, which is
  11313. <filename>target</filename>.
  11314. The <filename>target</filename> instance attribute is
  11315. identical to the class attribute of the same name, which
  11316. is described in the previous section.
  11317. This attribute exists as both an instance and class
  11318. attribute so tests can use
  11319. <filename>self.target.run(cmd)</filename> in instance
  11320. methods instead of
  11321. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  11322. </para>
  11323. </section>
  11324. </section>
  11325. <section id='installing-packages-in-the-dut-without-the-package-manager'>
  11326. <title>Installing Packages in the DUT Without the Package Manager</title>
  11327. <para>
  11328. When a test requires a package built by BitBake, it is possible
  11329. to install that package.
  11330. Installing the package does not require a package manager be
  11331. installed in the device under test (DUT).
  11332. It does, however, require an SSH connection and the target must
  11333. be using the <filename>sshcontrol</filename> class.
  11334. <note>
  11335. This method uses <filename>scp</filename> to copy files
  11336. from the host to the target, which causes permissions and
  11337. special attributes to be lost.
  11338. </note>
  11339. </para>
  11340. <para>
  11341. A JSON file is used to define the packages needed by a test.
  11342. This file must be in the same path as the file used to define
  11343. the tests.
  11344. Furthermore, the filename must map directly to the test
  11345. module name with a <filename>.json</filename> extension.
  11346. </para>
  11347. <para>
  11348. The JSON file must include an object with the test name as
  11349. keys of an object or an array.
  11350. This object (or array of objects) uses the following data:
  11351. <itemizedlist>
  11352. <listitem><para>"pkg" - A mandatory string that is the
  11353. name of the package to be installed.
  11354. </para></listitem>
  11355. <listitem><para>"rm" - An optional boolean, which defaults
  11356. to "false", that specifies to remove the package after
  11357. the test.
  11358. </para></listitem>
  11359. <listitem><para>"extract" - An optional boolean, which
  11360. defaults to "false", that specifies if the package must
  11361. be extracted from the package format.
  11362. When set to "true", the package is not automatically
  11363. installed into the DUT.
  11364. </para></listitem>
  11365. </itemizedlist>
  11366. </para>
  11367. <para>
  11368. Following is an example JSON file that handles test "foo"
  11369. installing package "bar" and test "foobar" installing
  11370. packages "foo" and "bar".
  11371. Once the test is complete, the packages are removed from the
  11372. DUT.
  11373. <literallayout class='monospaced'>
  11374. {
  11375. "foo": {
  11376. "pkg": "bar"
  11377. },
  11378. "foobar": [
  11379. {
  11380. "pkg": "foo",
  11381. "rm": true
  11382. },
  11383. {
  11384. "pkg": "bar",
  11385. "rm": true
  11386. }
  11387. ]
  11388. }
  11389. </literallayout>
  11390. </para>
  11391. </section>
  11392. </section>
  11393. <section id='usingpoky-debugging-tools-and-techniques'>
  11394. <title>Debugging Tools and Techniques</title>
  11395. <para>
  11396. The exact method for debugging build failures depends on the nature
  11397. of the problem and on the system's area from which the bug
  11398. originates.
  11399. Standard debugging practices such as comparison against the last
  11400. known working version with examination of the changes and the
  11401. re-application of steps to identify the one causing the problem are
  11402. valid for the Yocto Project just as they are for any other system.
  11403. Even though it is impossible to detail every possible potential
  11404. failure, this section provides some general tips to aid in
  11405. debugging given a variety of situations.
  11406. <note><title>Tip</title>
  11407. A useful feature for debugging is the error reporting tool.
  11408. Configuring the Yocto Project to use this tool causes the
  11409. OpenEmbedded build system to produce error reporting commands as
  11410. part of the console output.
  11411. You can enter the commands after the build completes to log
  11412. error information into a common database, that can help you
  11413. figure out what might be going wrong.
  11414. For information on how to enable and use this feature, see the
  11415. "<link linkend='using-the-error-reporting-tool'>Using the Error Reporting Tool</link>"
  11416. section.
  11417. </note>
  11418. </para>
  11419. <para>
  11420. The following list shows the debugging topics in the remainder of
  11421. this section:
  11422. <itemizedlist>
  11423. <listitem><para>
  11424. "<link linkend='dev-debugging-viewing-logs-from-failed-tasks'>Viewing Logs from Failed Tasks</link>"
  11425. describes how to find and view logs from tasks that
  11426. failed during the build process.
  11427. </para></listitem>
  11428. <listitem><para>
  11429. "<link linkend='dev-debugging-viewing-variable-values'>Viewing Variable Values</link>"
  11430. describes how to use the BitBake <filename>-e</filename>
  11431. option to examine variable values after a recipe has been
  11432. parsed.
  11433. </para></listitem>
  11434. <listitem><para>
  11435. "<link linkend='viewing-package-information-with-oe-pkgdata-util'>Viewing Package Information with <filename>oe-pkgdata-util</filename></link>"
  11436. describes how to use the
  11437. <filename>oe-pkgdata-util</filename> utility to query
  11438. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  11439. and display package-related information for built
  11440. packages.
  11441. </para></listitem>
  11442. <listitem><para>
  11443. "<link linkend='dev-viewing-dependencies-between-recipes-and-tasks'>Viewing Dependencies Between Recipes and Tasks</link>"
  11444. describes how to use the BitBake <filename>-g</filename>
  11445. option to display recipe dependency information used
  11446. during the build.
  11447. </para></listitem>
  11448. <listitem><para>
  11449. "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  11450. describes how to use the
  11451. <filename>bitbake-dumpsig</filename> command in
  11452. conjunction with key subdirectories in the
  11453. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  11454. to determine variable dependencies.
  11455. </para></listitem>
  11456. <listitem><para>
  11457. "<link linkend='dev-debugging-taskrunning'>Running Specific Tasks</link>"
  11458. describes how to use several BitBake options (e.g.
  11459. <filename>-c</filename>, <filename>-C</filename>, and
  11460. <filename>-f</filename>) to run specific tasks in the
  11461. build chain.
  11462. It can be useful to run tasks "out-of-order" when trying
  11463. isolate build issues.
  11464. </para></listitem>
  11465. <listitem><para>
  11466. "<link linkend='dev-debugging-bitbake'>General BitBake Problems</link>"
  11467. describes how to use BitBake's <filename>-D</filename>
  11468. debug output option to reveal more about what BitBake is
  11469. doing during the build.
  11470. </para></listitem>
  11471. <listitem><para>
  11472. "<link linkend='dev-debugging-buildfile'>Building with No Dependencies</link>"
  11473. describes how to use the BitBake <filename>-b</filename>
  11474. option to build a recipe while ignoring dependencies.
  11475. </para></listitem>
  11476. <listitem><para>
  11477. "<link linkend='recipe-logging-mechanisms'>Recipe Logging Mechanisms</link>"
  11478. describes how to use the many recipe logging functions
  11479. to produce debugging output and report errors and warnings.
  11480. </para></listitem>
  11481. <listitem><para>
  11482. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  11483. describes how to debug situations where the build consists
  11484. of several parts that are run simultaneously and when the
  11485. output or result of one part is not ready for use with a
  11486. different part of the build that depends on that output.
  11487. </para></listitem>
  11488. <listitem><para>
  11489. "<link linkend='platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</link>"
  11490. describes how to use GDB to allow you to examine running
  11491. programs, which can help you fix problems.
  11492. </para></listitem>
  11493. <listitem><para>
  11494. "<link linkend='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>Debugging with the GNU Project Debugger (GDB) on the Target</link>"
  11495. describes how to use GDB directly on target hardware for
  11496. debugging.
  11497. </para></listitem>
  11498. <listitem><para>
  11499. "<link linkend='dev-other-debugging-others'>Other Debugging Tips</link>"
  11500. describes miscellaneous debugging tips that can be useful.
  11501. </para></listitem>
  11502. </itemizedlist>
  11503. </para>
  11504. <para>
  11505. For debugging information within the popular
  11506. <trademark class='trade'>Eclipse</trademark> IDE, see the
  11507. "<ulink url='&YOCTO_DOCS_SDK_URL;#adt-eclipse'>Working within Eclipse</ulink>"
  11508. section in the Yocto Project Application Development and the
  11509. Extensible Software Development Kit (eSDK) manual.
  11510. </para>
  11511. <section id='dev-debugging-viewing-logs-from-failed-tasks'>
  11512. <title>Viewing Logs from Failed Tasks</title>
  11513. <para>
  11514. You can find the log for a task in the file
  11515. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>.
  11516. For example, the log for the
  11517. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  11518. task of the QEMU minimal image for the x86 machine
  11519. (<filename>qemux86</filename>) might be in
  11520. <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>.
  11521. To see the commands
  11522. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  11523. ran to generate a log, look at the corresponding
  11524. <filename>run.do_</filename><replaceable>taskname</replaceable>
  11525. file in the same directory.
  11526. </para>
  11527. <para>
  11528. <filename>log.do_</filename><replaceable>taskname</replaceable>
  11529. and
  11530. <filename>run.do_</filename><replaceable>taskname</replaceable>
  11531. are actually symbolic links to
  11532. <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>
  11533. and
  11534. <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>,
  11535. where <replaceable>pid</replaceable> is the PID the task had
  11536. when it ran.
  11537. The symlinks always point to the files corresponding to the most
  11538. recent run.
  11539. </para>
  11540. </section>
  11541. <section id='dev-debugging-viewing-variable-values'>
  11542. <title>Viewing Variable Values</title>
  11543. <para>
  11544. BitBake's <filename>-e</filename> option is used to display
  11545. variable values after parsing.
  11546. The following command displays the variable values after the
  11547. configuration files (i.e. <filename>local.conf</filename>,
  11548. <filename>bblayers.conf</filename>,
  11549. <filename>bitbake.conf</filename> and so forth) have been
  11550. parsed:
  11551. <literallayout class='monospaced'>
  11552. $ bitbake -e
  11553. </literallayout>
  11554. The following command displays variable values after a specific
  11555. recipe has been parsed.
  11556. The variables include those from the configuration as well:
  11557. <literallayout class='monospaced'>
  11558. $ bitbake -e recipename
  11559. </literallayout>
  11560. <note><para>
  11561. Each recipe has its own private set of variables
  11562. (datastore).
  11563. Internally, after parsing the configuration, a copy of the
  11564. resulting datastore is made prior to parsing each recipe.
  11565. This copying implies that variables set in one recipe will
  11566. not be visible to other recipes.</para>
  11567. <para>Likewise, each task within a recipe gets a private
  11568. datastore based on the recipe datastore, which means that
  11569. variables set within one task will not be visible to
  11570. other tasks.</para>
  11571. </note>
  11572. </para>
  11573. <para>
  11574. In the output of <filename>bitbake -e</filename>, each
  11575. variable is preceded by a description of how the variable
  11576. got its value, including temporary values that were later
  11577. overriden.
  11578. This description also includes variable flags (varflags) set on
  11579. the variable.
  11580. The output can be very helpful during debugging.
  11581. </para>
  11582. <para>
  11583. Variables that are exported to the environment are preceded by
  11584. <filename>export</filename> in the output of
  11585. <filename>bitbake -e</filename>.
  11586. See the following example:
  11587. <literallayout class='monospaced'>
  11588. export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
  11589. </literallayout>
  11590. </para>
  11591. <para>
  11592. In addition to variable values, the output of the
  11593. <filename>bitbake -e</filename> and
  11594. <filename>bitbake -e</filename>&nbsp;<replaceable>recipe</replaceable>
  11595. commands includes the following information:
  11596. <itemizedlist>
  11597. <listitem><para>
  11598. The output starts with a tree listing all configuration
  11599. files and classes included globally, recursively listing
  11600. the files they include or inherit in turn.
  11601. Much of the behavior of the OpenEmbedded build system
  11602. (including the behavior of the
  11603. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>)
  11604. is implemented in the
  11605. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink>
  11606. class and the classes it inherits, rather than being
  11607. built into BitBake itself.
  11608. </para></listitem>
  11609. <listitem><para>
  11610. After the variable values, all functions appear in the
  11611. output.
  11612. For shell functions, variables referenced within the
  11613. function body are expanded.
  11614. If a function has been modified using overrides or
  11615. using override-style operators like
  11616. <filename>_append</filename> and
  11617. <filename>_prepend</filename>, then the final assembled
  11618. function body appears in the output.
  11619. </para></listitem>
  11620. </itemizedlist>
  11621. </para>
  11622. </section>
  11623. <section id='viewing-package-information-with-oe-pkgdata-util'>
  11624. <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title>
  11625. <para>
  11626. You can use the <filename>oe-pkgdata-util</filename>
  11627. command-line utility to query
  11628. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  11629. and display various package-related information.
  11630. When you use the utility, you must use it to view information
  11631. on packages that have already been built.
  11632. </para>
  11633. <para>
  11634. Following are a few of the available
  11635. <filename>oe-pkgdata-util</filename> subcommands.
  11636. <note>
  11637. You can use the standard * and ? globbing wildcards as part
  11638. of package names and paths.
  11639. </note>
  11640. <itemizedlist>
  11641. <listitem><para>
  11642. <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>:
  11643. Lists all packages that have been built, optionally
  11644. limiting the match to packages that match
  11645. <replaceable>pattern</replaceable>.
  11646. </para></listitem>
  11647. <listitem><para>
  11648. <filename>oe-pkgdata-util list-pkg-files&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  11649. Lists the files and directories contained in the given
  11650. packages.
  11651. <note>
  11652. <para>
  11653. A different way to view the contents of a package is
  11654. to look at the
  11655. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  11656. directory of the recipe that generates the
  11657. package.
  11658. This directory is created by the
  11659. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  11660. task and has one subdirectory for each package the
  11661. recipe generates, which contains the files stored in
  11662. that package.</para>
  11663. <para>
  11664. If you want to inspect the
  11665. <filename>${WORKDIR}/packages-split</filename>
  11666. directory, make sure that
  11667. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  11668. is not enabled when you build the recipe.
  11669. </para>
  11670. </note>
  11671. </para></listitem>
  11672. <listitem><para>
  11673. <filename>oe-pkgdata-util find-path&nbsp;</filename><replaceable>path</replaceable><filename>&nbsp;...</filename>:
  11674. Lists the names of the packages that contain the given
  11675. paths.
  11676. For example, the following tells us that
  11677. <filename>/usr/share/man/man1/make.1</filename>
  11678. is contained in the <filename>make-doc</filename>
  11679. package:
  11680. <literallayout class='monospaced'>
  11681. $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
  11682. make-doc: /usr/share/man/man1/make.1
  11683. </literallayout>
  11684. </para></listitem>
  11685. <listitem><para>
  11686. <filename>oe-pkgdata-util lookup-recipe&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  11687. Lists the name of the recipes that
  11688. produce the given packages.
  11689. </para></listitem>
  11690. </itemizedlist>
  11691. </para>
  11692. <para>
  11693. For more information on the <filename>oe-pkgdata-util</filename>
  11694. command, use the help facility:
  11695. <literallayout class='monospaced'>
  11696. $ oe-pkgdata-util &dash;&dash;help
  11697. $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help
  11698. </literallayout>
  11699. </para>
  11700. </section>
  11701. <section id='dev-viewing-dependencies-between-recipes-and-tasks'>
  11702. <title>Viewing Dependencies Between Recipes and Tasks</title>
  11703. <para>
  11704. Sometimes it can be hard to see why BitBake wants to build other
  11705. recipes before the one you have specified.
  11706. Dependency information can help you understand why a recipe is
  11707. built.
  11708. </para>
  11709. <para>
  11710. To generate dependency information for a recipe, run the
  11711. following command:
  11712. <literallayout class='monospaced'>
  11713. $ bitbake -g <replaceable>recipename</replaceable>
  11714. </literallayout>
  11715. This command writes the following files in the current
  11716. directory:
  11717. <itemizedlist>
  11718. <listitem><para>
  11719. <filename>pn-buildlist</filename>: A list of
  11720. recipes/targets involved in building
  11721. <replaceable>recipename</replaceable>.
  11722. "Involved" here means that at least one task from the
  11723. recipe needs to run when building
  11724. <replaceable>recipename</replaceable> from scratch.
  11725. Targets that are in
  11726. <ulink url='&YOCTO_DOCS_REF_URL;#var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></ulink>
  11727. are not listed.
  11728. </para></listitem>
  11729. <listitem><para>
  11730. <filename>task-depends.dot</filename>: A graph showing
  11731. dependencies between tasks.
  11732. </para></listitem>
  11733. </itemizedlist>
  11734. </para>
  11735. <para>
  11736. The graphs are in
  11737. <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink>
  11738. format and can be converted to images (e.g. using the
  11739. <filename>dot</filename> tool from
  11740. <ulink url='http://www.graphviz.org/'>Graphviz</ulink>).
  11741. <note><title>Notes</title>
  11742. <itemizedlist>
  11743. <listitem><para>
  11744. DOT files use a plain text format.
  11745. The graphs generated using the
  11746. <filename>bitbake -g</filename> command are often so
  11747. large as to be difficult to read without special
  11748. pruning (e.g. with Bitbake's
  11749. <filename>-I</filename> option) and processing.
  11750. Despite the form and size of the graphs, the
  11751. corresponding <filename>.dot</filename> files can
  11752. still be possible to read and provide useful
  11753. information.
  11754. </para>
  11755. <para>As an example, the
  11756. <filename>task-depends.dot</filename> file contains
  11757. lines such as the following:
  11758. <literallayout class='monospaced'>
  11759. "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
  11760. </literallayout>
  11761. The above example line reveals that the
  11762. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  11763. task in <filename>libxslt</filename> depends on the
  11764. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  11765. task in <filename>libxml2</filename>, which is a
  11766. normal
  11767. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  11768. dependency between the two recipes.
  11769. </para></listitem>
  11770. <listitem><para>
  11771. For an example of how <filename>.dot</filename>
  11772. files can be processed, see the
  11773. <filename>scripts/contrib/graph-tool</filename>
  11774. Python script, which finds and displays paths
  11775. between graph nodes.
  11776. </para></listitem>
  11777. </itemizedlist>
  11778. </note>
  11779. </para>
  11780. <para>
  11781. You can use a different method to view dependency information
  11782. by using the following command:
  11783. <literallayout class='monospaced'>
  11784. $ bitbake -g -u taskexp <replaceable>recipename</replaceable>
  11785. </literallayout>
  11786. This command displays a GUI window from which you can view
  11787. build-time and runtime dependencies for the recipes involved in
  11788. building <replaceable>recipename</replaceable>.
  11789. </para>
  11790. </section>
  11791. <section id='dev-viewing-task-variable-dependencies'>
  11792. <title>Viewing Task Variable Dependencies</title>
  11793. <para>
  11794. As mentioned in the
  11795. "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>"
  11796. section of the BitBake User Manual, BitBake tries to
  11797. automatically determine what variables a task depends on so
  11798. that it can rerun the task if any values of the variables
  11799. change.
  11800. This determination is usually reliable.
  11801. However, if you do things like construct variable names at
  11802. runtime, then you might have to manually declare dependencies
  11803. on those variables using <filename>vardeps</filename> as
  11804. described in the
  11805. "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
  11806. section of the BitBake User Manual.
  11807. </para>
  11808. <para>
  11809. If you are unsure whether a variable dependency is being
  11810. picked up automatically for a given task, you can list the
  11811. variable dependencies BitBake has determined by doing the
  11812. following:
  11813. <orderedlist>
  11814. <listitem><para>
  11815. Build the recipe containing the task:
  11816. <literallayout class='monospaced'>
  11817. $ bitbake <replaceable>recipename</replaceable>
  11818. </literallayout>
  11819. </para></listitem>
  11820. <listitem><para>
  11821. Inside the
  11822. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink>
  11823. directory, find the signature data
  11824. (<filename>sigdata</filename>) file that corresponds
  11825. to the task.
  11826. The <filename>sigdata</filename> files contain a pickled
  11827. Python database of all the metadata that went into
  11828. creating the input checksum for the task.
  11829. As an example, for the
  11830. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  11831. task of the <filename>db</filename> recipe, the
  11832. <filename>sigdata</filename> file might be found in the
  11833. following location:
  11834. <literallayout class='monospaced'>
  11835. ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  11836. </literallayout>
  11837. For tasks that are accelerated through the shared state
  11838. (<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>sstate</ulink>)
  11839. cache, an additional <filename>siginfo</filename> file
  11840. is written into
  11841. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  11842. along with the cached task output.
  11843. The <filename>siginfo</filename> files contain exactly
  11844. the same information as <filename>sigdata</filename>
  11845. files.
  11846. </para></listitem>
  11847. <listitem><para>
  11848. Run <filename>bitbake-dumpsig</filename> on the
  11849. <filename>sigdata</filename> or
  11850. <filename>siginfo</filename> file.
  11851. Here is an example:
  11852. <literallayout class='monospaced'>
  11853. $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  11854. </literallayout>
  11855. In the output of the above command, you will find a
  11856. line like the following, which lists all the (inferred)
  11857. variable dependencies for the task.
  11858. This list also includes indirect dependencies from
  11859. variables depending on other variables, recursively.
  11860. <literallayout class='monospaced'>
  11861. Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
  11862. </literallayout>
  11863. <note>
  11864. Functions (e.g. <filename>base_do_fetch</filename>)
  11865. also count as variable dependencies.
  11866. These functions in turn depend on the variables they
  11867. reference.
  11868. </note>
  11869. The output of <filename>bitbake-dumpsig</filename> also
  11870. includes the value each variable had, a list of
  11871. dependencies for each variable, and
  11872. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink>
  11873. information.
  11874. </para></listitem>
  11875. </orderedlist>
  11876. </para>
  11877. <para>
  11878. There is also a <filename>bitbake-diffsigs</filename> command
  11879. for comparing two <filename>siginfo</filename> or
  11880. <filename>sigdata</filename> files.
  11881. This command can be helpful when trying to figure out what
  11882. changed between two versions of a task.
  11883. If you call <filename>bitbake-diffsigs</filename> with just one
  11884. file, the command behaves like
  11885. <filename>bitbake-dumpsig</filename>.
  11886. </para>
  11887. <para>
  11888. You can also use BitBake to dump out the signature construction
  11889. information without executing tasks by using either of the
  11890. following BitBake command-line options:
  11891. <literallayout class='monospaced'>
  11892. &dash;&dash;dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable>
  11893. -S <replaceable>SIGNATURE_HANDLER</replaceable>
  11894. </literallayout>
  11895. <note>
  11896. Two common values for
  11897. <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and
  11898. "printdiff", which dump only the signature or compare the
  11899. dumped signature with the cached one, respectively.
  11900. </note>
  11901. Using BitBake with either of these options causes BitBake to
  11902. dump out <filename>sigdata</filename> files in the
  11903. <filename>stamps</filename> directory for every task it would
  11904. have executed instead of building the specified target package.
  11905. </para>
  11906. </section>
  11907. <section id='dev-viewing-metadata-used-to-create-the-input-signature-of-a-shared-state-task'>
  11908. <title>Viewing Metadata Used to Create the Input Signature of a Shared State Task</title>
  11909. <para>
  11910. Seeing what metadata went into creating the input signature
  11911. of a shared state (sstate) task can be a useful debugging
  11912. aid.
  11913. This information is available in signature information
  11914. (<filename>siginfo</filename>) files in
  11915. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>.
  11916. For information on how to view and interpret information in
  11917. <filename>siginfo</filename> files, see the
  11918. "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  11919. section.
  11920. </para>
  11921. <para>
  11922. For conceptual information on shared state, see the
  11923. "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>Shared State</ulink>"
  11924. section in the Yocto Project Overview and Concepts Manual.
  11925. </para>
  11926. </section>
  11927. <section id='dev-invalidating-shared-state-to-force-a-task-to-run'>
  11928. <title>Invalidating Shared State to Force a Task to Run</title>
  11929. <para>
  11930. The OpenEmbedded build system uses
  11931. <ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>checksums</ulink>
  11932. and
  11933. <ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>shared state</ulink>
  11934. cache to avoid unnecessarily rebuilding tasks.
  11935. Collectively, this scheme is known as "shared state code."
  11936. </para>
  11937. <para>
  11938. As with all schemes, this one has some drawbacks.
  11939. It is possible that you could make implicit changes to your
  11940. code that the checksum calculations do not take into
  11941. account.
  11942. These implicit changes affect a task's output but do not
  11943. trigger the shared state code into rebuilding a recipe.
  11944. Consider an example during which a tool changes its output.
  11945. Assume that the output of <filename>rpmdeps</filename>
  11946. changes.
  11947. The result of the change should be that all the
  11948. <filename>package</filename> and
  11949. <filename>package_write_rpm</filename> shared state cache
  11950. items become invalid.
  11951. However, because the change to the output is
  11952. external to the code and therefore implicit,
  11953. the associated shared state cache items do not become
  11954. invalidated.
  11955. In this case, the build process uses the cached items
  11956. rather than running the task again.
  11957. Obviously, these types of implicit changes can cause
  11958. problems.
  11959. </para>
  11960. <para>
  11961. To avoid these problems during the build, you need to
  11962. understand the effects of any changes you make.
  11963. Realize that changes you make directly to a function
  11964. are automatically factored into the checksum calculation.
  11965. Thus, these explicit changes invalidate the associated
  11966. area of shared state cache.
  11967. However, you need to be aware of any implicit changes that
  11968. are not obvious changes to the code and could affect
  11969. the output of a given task.
  11970. </para>
  11971. <para>
  11972. When you identify an implicit change, you can easily
  11973. take steps to invalidate the cache and force the tasks
  11974. to run.
  11975. The steps you can take are as simple as changing a
  11976. function's comments in the source code.
  11977. For example, to invalidate package shared state files,
  11978. change the comment statements of
  11979. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  11980. or the comments of one of the functions it calls.
  11981. Even though the change is purely cosmetic, it causes the
  11982. checksum to be recalculated and forces the build system to
  11983. run the task again.
  11984. <note>
  11985. For an example of a commit that makes a cosmetic
  11986. change to invalidate shared state, see this
  11987. <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54'>commit</ulink>.
  11988. </note>
  11989. </para>
  11990. </section>
  11991. <section id='dev-debugging-taskrunning'>
  11992. <title>Running Specific Tasks</title>
  11993. <para>
  11994. Any given recipe consists of a set of tasks.
  11995. The standard BitBake behavior in most cases is:
  11996. <filename>do_fetch</filename>,
  11997. <filename>do_unpack</filename>,
  11998. <filename>do_patch</filename>,
  11999. <filename>do_configure</filename>,
  12000. <filename>do_compile</filename>,
  12001. <filename>do_install</filename>,
  12002. <filename>do_package</filename>,
  12003. <filename>do_package_write_*</filename>, and
  12004. <filename>do_build</filename>.
  12005. The default task is <filename>do_build</filename> and any tasks
  12006. on which it depends build first.
  12007. Some tasks, such as <filename>do_devshell</filename>, are not
  12008. part of the default build chain.
  12009. If you wish to run a task that is not part of the default build
  12010. chain, you can use the <filename>-c</filename> option in
  12011. BitBake.
  12012. Here is an example:
  12013. <literallayout class='monospaced'>
  12014. $ bitbake matchbox-desktop -c devshell
  12015. </literallayout>
  12016. </para>
  12017. <para>
  12018. The <filename>-c</filename> option respects task dependencies,
  12019. which means that all other tasks (including tasks from other
  12020. recipes) that the specified task depends on will be run before
  12021. the task.
  12022. Even when you manually specify a task to run with
  12023. <filename>-c</filename>, BitBake will only run the task if it
  12024. considers it "out of date".
  12025. See the
  12026. "<ulink url='&YOCTO_DOCS_OM_URL;#stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</ulink>"
  12027. section in the Yocto Project Overview and Concepts Manual for
  12028. how BitBake determines whether a task is "out of date".
  12029. </para>
  12030. <para>
  12031. If you want to force an up-to-date task to be rerun (e.g.
  12032. because you made manual modifications to the recipe's
  12033. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  12034. that you want to try out), then you can use the
  12035. <filename>-f</filename> option.
  12036. <note>
  12037. The reason <filename>-f</filename> is never required when
  12038. running the
  12039. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-devshell'><filename>do_devshell</filename></ulink>
  12040. task is because the
  12041. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename>
  12042. variable flag is already set for the task.
  12043. </note>
  12044. The following example shows one way you can use the
  12045. <filename>-f</filename> option:
  12046. <literallayout class='monospaced'>
  12047. $ bitbake matchbox-desktop
  12048. .
  12049. .
  12050. make some changes to the source code in the work directory
  12051. .
  12052. .
  12053. $ bitbake matchbox-desktop -c compile -f
  12054. $ bitbake matchbox-desktop
  12055. </literallayout>
  12056. </para>
  12057. <para>
  12058. This sequence first builds and then recompiles
  12059. <filename>matchbox-desktop</filename>.
  12060. The last command reruns all tasks (basically the packaging
  12061. tasks) after the compile.
  12062. BitBake recognizes that the <filename>do_compile</filename>
  12063. task was rerun and therefore understands that the other tasks
  12064. also need to be run again.
  12065. </para>
  12066. <para>
  12067. Another, shorter way to rerun a task and all
  12068. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>
  12069. that depend on it is to use the <filename>-C</filename>
  12070. option.
  12071. <note>
  12072. This option is upper-cased and is separate from the
  12073. <filename>-c</filename> option, which is lower-cased.
  12074. </note>
  12075. Using this option invalidates the given task and then runs the
  12076. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-build'><filename>do_build</filename></ulink>
  12077. task, which is the default task if no task is given, and the
  12078. tasks on which it depends.
  12079. You could replace the final two commands in the previous example
  12080. with the following single command:
  12081. <literallayout class='monospaced'>
  12082. $ bitbake matchbox-desktop -C compile
  12083. </literallayout>
  12084. Internally, the <filename>-f</filename> and
  12085. <filename>-C</filename> options work by tainting (modifying) the
  12086. input checksum of the specified task.
  12087. This tainting indirectly causes the task and its
  12088. dependent tasks to be rerun through the normal task dependency
  12089. mechanisms.
  12090. <note>
  12091. BitBake explicitly keeps track of which tasks have been
  12092. tainted in this fashion, and will print warnings such as the
  12093. following for builds involving such tasks:
  12094. <literallayout class='monospaced'>
  12095. WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
  12096. </literallayout>
  12097. The purpose of the warning is to let you know that the work
  12098. directory and build output might not be in the clean state
  12099. they would be in for a "normal" build, depending on what
  12100. actions you took.
  12101. To get rid of such warnings, you can remove the work
  12102. directory and rebuild the recipe, as follows:
  12103. <literallayout class='monospaced'>
  12104. $ bitbake matchbox-desktop -c clean
  12105. $ bitbake matchbox-desktop
  12106. </literallayout>
  12107. </note>
  12108. </para>
  12109. <para>
  12110. You can view a list of tasks in a given package by running the
  12111. <filename>do_listtasks</filename> task as follows:
  12112. <literallayout class='monospaced'>
  12113. $ bitbake matchbox-desktop -c listtasks
  12114. </literallayout>
  12115. The results appear as output to the console and are also in the
  12116. file <filename>${WORKDIR}/temp/log.do_listtasks</filename>.
  12117. </para>
  12118. </section>
  12119. <section id='dev-debugging-bitbake'>
  12120. <title>General BitBake Problems</title>
  12121. <para>
  12122. You can see debug output from BitBake by using the
  12123. <filename>-D</filename> option.
  12124. The debug output gives more information about what BitBake
  12125. is doing and the reason behind it.
  12126. Each <filename>-D</filename> option you use increases the
  12127. logging level.
  12128. The most common usage is <filename>-DDD</filename>.
  12129. </para>
  12130. <para>
  12131. The output from
  12132. <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable>
  12133. can reveal why BitBake chose a certain version of a package or
  12134. why BitBake picked a certain provider.
  12135. This command could also help you in a situation where you think
  12136. BitBake did something unexpected.
  12137. </para>
  12138. </section>
  12139. <section id='dev-debugging-buildfile'>
  12140. <title>Building with No Dependencies</title>
  12141. <para>
  12142. To build a specific recipe (<filename>.bb</filename> file),
  12143. you can use the following command form:
  12144. <literallayout class='monospaced'>
  12145. $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb
  12146. </literallayout>
  12147. This command form does not check for dependencies.
  12148. Consequently, you should use it only when you know existing
  12149. dependencies have been met.
  12150. <note>
  12151. You can also specify fragments of the filename.
  12152. In this case, BitBake checks for a unique match.
  12153. </note>
  12154. </para>
  12155. </section>
  12156. <section id='recipe-logging-mechanisms'>
  12157. <title>Recipe Logging Mechanisms</title>
  12158. <para>
  12159. The Yocto Project provides several logging functions for
  12160. producing debugging output and reporting errors and warnings.
  12161. For Python functions, the following logging functions exist.
  12162. All of these functions log to
  12163. <filename>${T}/log.do_</filename><replaceable>task</replaceable>,
  12164. and can also log to standard output (stdout) with the right
  12165. settings:
  12166. <itemizedlist>
  12167. <listitem><para>
  12168. <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12169. Writes <replaceable>msg</replaceable> as is to the
  12170. log while also logging to stdout.
  12171. </para></listitem>
  12172. <listitem><para>
  12173. <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12174. Writes "NOTE: <replaceable>msg</replaceable>" to the
  12175. log.
  12176. Also logs to stdout if BitBake is called with "-v".
  12177. </para></listitem>
  12178. <listitem><para>
  12179. <filename>bb.debug(</filename><replaceable>level</replaceable><filename>,&nbsp;</filename><replaceable>msg</replaceable><filename>)</filename>:
  12180. Writes "DEBUG: <replaceable>msg</replaceable>" to the
  12181. log.
  12182. Also logs to stdout if the log level is greater than or
  12183. equal to <replaceable>level</replaceable>.
  12184. See the
  12185. "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>"
  12186. option in the BitBake User Manual for more information.
  12187. </para></listitem>
  12188. <listitem><para>
  12189. <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12190. Writes "WARNING: <replaceable>msg</replaceable>" to the
  12191. log while also logging to stdout.
  12192. </para></listitem>
  12193. <listitem><para>
  12194. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12195. Writes "ERROR: <replaceable>msg</replaceable>" to the
  12196. log while also logging to standard out (stdout).
  12197. <note>
  12198. Calling this function does not cause the task to fail.
  12199. </note>
  12200. </para></listitem>
  12201. <listitem><para>
  12202. <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>:
  12203. This logging function is similar to
  12204. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>
  12205. but also causes the calling task to fail.
  12206. <note>
  12207. <filename>bb.fatal()</filename> raises an exception,
  12208. which means you do not need to put a "return"
  12209. statement after the function.
  12210. </note>
  12211. </para></listitem>
  12212. </itemizedlist>
  12213. </para>
  12214. <para>
  12215. The same logging functions are also available in shell
  12216. functions, under the names
  12217. <filename>bbplain</filename>, <filename>bbnote</filename>,
  12218. <filename>bbdebug</filename>, <filename>bbwarn</filename>,
  12219. <filename>bberror</filename>, and <filename>bbfatal</filename>.
  12220. The
  12221. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-logging'><filename>logging</filename></ulink>
  12222. class implements these functions.
  12223. See that class in the
  12224. <filename>meta/classes</filename> folder of the
  12225. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  12226. for information.
  12227. </para>
  12228. <section id='logging-with-python'>
  12229. <title>Logging With Python</title>
  12230. <para>
  12231. When creating recipes using Python and inserting code that
  12232. handles build logs, keep in mind the goal is to have
  12233. informative logs while keeping the console as "silent" as
  12234. possible.
  12235. Also, if you want status messages in the log, use the
  12236. "debug" loglevel.
  12237. </para>
  12238. <para>
  12239. Following is an example written in Python.
  12240. The code handles logging for a function that determines the
  12241. number of tasks needed to be run.
  12242. See the
  12243. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-listtasks'><filename>do_listtasks</filename></ulink>"
  12244. section for additional information:
  12245. <literallayout class='monospaced'>
  12246. python do_listtasks() {
  12247. bb.debug(2, "Starting to figure out the task list")
  12248. if noteworthy_condition:
  12249. bb.note("There are 47 tasks to run")
  12250. bb.debug(2, "Got to point xyz")
  12251. if warning_trigger:
  12252. bb.warn("Detected warning_trigger, this might be a problem later.")
  12253. if recoverable_error:
  12254. bb.error("Hit recoverable_error, you really need to fix this!")
  12255. if fatal_error:
  12256. bb.fatal("fatal_error detected, unable to print the task list")
  12257. bb.plain("The tasks present are abc")
  12258. bb.debug(2, "Finished figuring out the tasklist")
  12259. }
  12260. </literallayout>
  12261. </para>
  12262. </section>
  12263. <section id='logging-with-bash'>
  12264. <title>Logging With Bash</title>
  12265. <para>
  12266. When creating recipes using Bash and inserting code that
  12267. handles build logs, you have the same goals - informative
  12268. with minimal console output.
  12269. The syntax you use for recipes written in Bash is similar
  12270. to that of recipes written in Python described in the
  12271. previous section.
  12272. </para>
  12273. <para>
  12274. Following is an example written in Bash.
  12275. The code logs the progress of the <filename>do_my_function</filename> function.
  12276. <literallayout class='monospaced'>
  12277. do_my_function() {
  12278. bbdebug 2 "Running do_my_function"
  12279. if [ exceptional_condition ]; then
  12280. bbnote "Hit exceptional_condition"
  12281. fi
  12282. bbdebug 2 "Got to point xyz"
  12283. if [ warning_trigger ]; then
  12284. bbwarn "Detected warning_trigger, this might cause a problem later."
  12285. fi
  12286. if [ recoverable_error ]; then
  12287. bberror "Hit recoverable_error, correcting"
  12288. fi
  12289. if [ fatal_error ]; then
  12290. bbfatal "fatal_error detected"
  12291. fi
  12292. bbdebug 2 "Completed do_my_function"
  12293. }
  12294. </literallayout>
  12295. </para>
  12296. </section>
  12297. </section>
  12298. <section id='debugging-parallel-make-races'>
  12299. <title>Debugging Parallel Make Races</title>
  12300. <para>
  12301. A parallel <filename>make</filename> race occurs when the build
  12302. consists of several parts that are run simultaneously and
  12303. a situation occurs when the output or result of one
  12304. part is not ready for use with a different part of the build
  12305. that depends on that output.
  12306. Parallel make races are annoying and can sometimes be difficult
  12307. to reproduce and fix.
  12308. However, some simple tips and tricks exist that can help
  12309. you debug and fix them.
  12310. This section presents a real-world example of an error
  12311. encountered on the Yocto Project autobuilder and the process
  12312. used to fix it.
  12313. <note>
  12314. If you cannot properly fix a <filename>make</filename> race
  12315. condition, you can work around it by clearing either the
  12316. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  12317. or
  12318. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  12319. variables.
  12320. </note>
  12321. </para>
  12322. <section id='the-failure'>
  12323. <title>The Failure</title>
  12324. <para>
  12325. For this example, assume that you are building an image that
  12326. depends on the "neard" package.
  12327. And, during the build, BitBake runs into problems and
  12328. creates the following output.
  12329. <note>
  12330. This example log file has longer lines artificially
  12331. broken to make the listing easier to read.
  12332. </note>
  12333. If you examine the output or the log file, you see the
  12334. failure during <filename>make</filename>:
  12335. <literallayout class='monospaced'>
  12336. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  12337. | DEBUG: Executing shell function do_compile
  12338. | NOTE: make -j 16
  12339. | make --no-print-directory all-am
  12340. | /bin/mkdir -p include/near
  12341. | /bin/mkdir -p include/near
  12342. | /bin/mkdir -p include/near
  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/types.h include/near/types.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/log.h include/near/log.h
  12347. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12348. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  12349. | /bin/mkdir -p include/near
  12350. | /bin/mkdir -p include/near
  12351. | /bin/mkdir -p include/near
  12352. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12353. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  12354. | /bin/mkdir -p include/near
  12355. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12356. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  12357. | /bin/mkdir -p include/near
  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/ndef.h include/near/ndef.h
  12360. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12361. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  12362. | /bin/mkdir -p include/near
  12363. | /bin/mkdir -p include/near
  12364. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12365. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  12366. | /bin/mkdir -p include/near
  12367. | /bin/mkdir -p include/near
  12368. | /bin/mkdir -p include/near
  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/device.h include/near/device.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/nfc_copy.h include/near/nfc_copy.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/snep.h include/near/snep.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/version.h include/near/version.h
  12377. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  12378. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  12379. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  12380. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  12381. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  12382. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  12383. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  12384. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  12385. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  12386. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  12387. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  12388. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  12389. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  12390. -o tools/snep-send.o tools/snep-send.c
  12391. | In file included from tools/snep-send.c:16:0:
  12392. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  12393. | #include &lt;near/dbus.h&gt;
  12394. | ^
  12395. | compilation terminated.
  12396. | make[1]: *** [tools/snep-send.o] Error 1
  12397. | make[1]: *** Waiting for unfinished jobs....
  12398. | make: *** [all] Error 2
  12399. | ERROR: oe_runmake failed
  12400. </literallayout>
  12401. </para>
  12402. </section>
  12403. <section id='reproducing-the-error'>
  12404. <title>Reproducing the Error</title>
  12405. <para>
  12406. Because race conditions are intermittent, they do not
  12407. manifest themselves every time you do the build.
  12408. In fact, most times the build will complete without problems
  12409. even though the potential race condition exists.
  12410. Thus, once the error surfaces, you need a way to reproduce
  12411. it.
  12412. </para>
  12413. <para>
  12414. In this example, compiling the "neard" package is causing
  12415. the problem.
  12416. So the first thing to do is build "neard" locally.
  12417. Before you start the build, set the
  12418. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  12419. variable in your <filename>local.conf</filename> file to
  12420. a high number (e.g. "-j 20").
  12421. Using a high value for <filename>PARALLEL_MAKE</filename>
  12422. increases the chances of the race condition showing up:
  12423. <literallayout class='monospaced'>
  12424. $ bitbake neard
  12425. </literallayout>
  12426. </para>
  12427. <para>
  12428. Once the local build for "neard" completes, start a
  12429. <filename>devshell</filename> build:
  12430. <literallayout class='monospaced'>
  12431. $ bitbake neard -c devshell
  12432. </literallayout>
  12433. For information on how to use a
  12434. <filename>devshell</filename>, see the
  12435. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  12436. section.
  12437. </para>
  12438. <para>
  12439. In the <filename>devshell</filename>, do the following:
  12440. <literallayout class='monospaced'>
  12441. $ make clean
  12442. $ make tools/snep-send.o
  12443. </literallayout>
  12444. The <filename>devshell</filename> commands cause the failure
  12445. to clearly be visible.
  12446. In this case, a missing dependency exists for the "neard"
  12447. Makefile target.
  12448. Here is some abbreviated, sample output with the
  12449. missing dependency clearly visible at the end:
  12450. <literallayout class='monospaced'>
  12451. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  12452. .
  12453. .
  12454. .
  12455. tools/snep-send.c
  12456. In file included from tools/snep-send.c:16:0:
  12457. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  12458. #include &lt;near/dbus.h&gt;
  12459. ^
  12460. compilation terminated.
  12461. make: *** [tools/snep-send.o] Error 1
  12462. $
  12463. </literallayout>
  12464. </para>
  12465. </section>
  12466. <section id='creating-a-patch-for-the-fix'>
  12467. <title>Creating a Patch for the Fix</title>
  12468. <para>
  12469. Because there is a missing dependency for the Makefile
  12470. target, you need to patch the
  12471. <filename>Makefile.am</filename> file, which is generated
  12472. from <filename>Makefile.in</filename>.
  12473. You can use Quilt to create the patch:
  12474. <literallayout class='monospaced'>
  12475. $ quilt new parallelmake.patch
  12476. Patch patches/parallelmake.patch is now on top
  12477. $ quilt add Makefile.am
  12478. File Makefile.am added to patch patches/parallelmake.patch
  12479. </literallayout>
  12480. For more information on using Quilt, see the
  12481. "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
  12482. section.
  12483. </para>
  12484. <para>
  12485. At this point you need to make the edits to
  12486. <filename>Makefile.am</filename> to add the missing
  12487. dependency.
  12488. For our example, you have to add the following line
  12489. to the file:
  12490. <literallayout class='monospaced'>
  12491. tools/snep-send.$(OBJEXT): include/near/dbus.h
  12492. </literallayout>
  12493. </para>
  12494. <para>
  12495. Once you have edited the file, use the
  12496. <filename>refresh</filename> command to create the patch:
  12497. <literallayout class='monospaced'>
  12498. $ quilt refresh
  12499. Refreshed patch patches/parallelmake.patch
  12500. </literallayout>
  12501. Once the patch file exists, you need to add it back to the
  12502. originating recipe folder.
  12503. Here is an example assuming a top-level
  12504. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  12505. named <filename>poky</filename>:
  12506. <literallayout class='monospaced'>
  12507. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  12508. </literallayout>
  12509. The final thing you need to do to implement the fix in the
  12510. build is to update the "neard" recipe (i.e.
  12511. <filename>neard-0.14.bb</filename>) so that the
  12512. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  12513. statement includes the patch file.
  12514. The recipe file is in the folder above the patch.
  12515. Here is what the edited <filename>SRC_URI</filename>
  12516. statement would look like:
  12517. <literallayout class='monospaced'>
  12518. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  12519. file://neard.in \
  12520. file://neard.service.in \
  12521. file://parallelmake.patch \
  12522. "
  12523. </literallayout>
  12524. </para>
  12525. <para>
  12526. With the patch complete and moved to the correct folder and
  12527. the <filename>SRC_URI</filename> statement updated, you can
  12528. exit the <filename>devshell</filename>:
  12529. <literallayout class='monospaced'>
  12530. $ exit
  12531. </literallayout>
  12532. </para>
  12533. </section>
  12534. <section id='testing-the-build'>
  12535. <title>Testing the Build</title>
  12536. <para>
  12537. With everything in place, you can get back to trying the
  12538. build again locally:
  12539. <literallayout class='monospaced'>
  12540. $ bitbake neard
  12541. </literallayout>
  12542. This build should succeed.
  12543. </para>
  12544. <para>
  12545. Now you can open up a <filename>devshell</filename> again
  12546. and repeat the clean and make operations as follows:
  12547. <literallayout class='monospaced'>
  12548. $ bitbake neard -c devshell
  12549. $ make clean
  12550. $ make tools/snep-send.o
  12551. </literallayout>
  12552. The build should work without issue.
  12553. </para>
  12554. <para>
  12555. As with all solved problems, if they originated upstream,
  12556. you need to submit the fix for the recipe in OE-Core and
  12557. upstream so that the problem is taken care of at its
  12558. source.
  12559. See the
  12560. "<link linkend='how-to-submit-a-change'>Submitting a Change to the Yocto Project</link>"
  12561. section for more information.
  12562. </para>
  12563. </section>
  12564. </section>
  12565. <section id="platdev-gdb-remotedebug">
  12566. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  12567. <para>
  12568. GDB allows you to examine running programs, which in turn helps
  12569. you to understand and fix problems.
  12570. It also allows you to perform post-mortem style analysis of
  12571. program crashes.
  12572. GDB is available as a package within the Yocto Project and is
  12573. installed in SDK images by default.
  12574. See the
  12575. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  12576. chapter in the Yocto Project Reference Manual for a description of
  12577. these images.
  12578. You can find information on GDB at
  12579. <ulink url="http://sourceware.org/gdb/"/>.
  12580. <note><title>Tip</title>
  12581. For best results, install debug (<filename>-dbg</filename>)
  12582. packages for the applications you are going to debug.
  12583. Doing so makes extra debug symbols available that give you
  12584. more meaningful output.
  12585. </note>
  12586. </para>
  12587. <para>
  12588. Sometimes, due to memory or disk space constraints, it is not
  12589. possible to use GDB directly on the remote target to debug
  12590. applications.
  12591. These constraints arise because GDB needs to load the debugging
  12592. information and the binaries of the process being debugged.
  12593. Additionally, GDB needs to perform many computations to locate
  12594. information such as function names, variable names and values,
  12595. stack traces and so forth - even before starting the debugging
  12596. process.
  12597. These extra computations place more load on the target system
  12598. and can alter the characteristics of the program being debugged.
  12599. </para>
  12600. <para>
  12601. To help get past the previously mentioned constraints, you can
  12602. use gdbserver, which runs on the remote target and does not
  12603. load any debugging information from the debugged process.
  12604. Instead, a GDB instance processes the debugging information that
  12605. is run on a remote computer - the host GDB.
  12606. The host GDB then sends control commands to gdbserver to make
  12607. it stop or start the debugged program, as well as read or write
  12608. memory regions of that debugged program.
  12609. All the debugging information loaded and processed as well
  12610. as all the heavy debugging is done by the host GDB.
  12611. Offloading these processes gives the gdbserver running on the
  12612. target a chance to remain small and fast.
  12613. </para>
  12614. <para>
  12615. Because the host GDB is responsible for loading the debugging
  12616. information and for doing the necessary processing to make
  12617. actual debugging happen, you have to make sure the host can
  12618. access the unstripped binaries complete with their debugging
  12619. information and also be sure the target is compiled with no
  12620. optimizations.
  12621. The host GDB must also have local access to all the libraries
  12622. used by the debugged program.
  12623. Because gdbserver does not need any local debugging information,
  12624. the binaries on the remote target can remain stripped.
  12625. However, the binaries must also be compiled without optimization
  12626. so they match the host's binaries.
  12627. </para>
  12628. <para>
  12629. To remain consistent with GDB documentation and terminology,
  12630. the binary being debugged on the remote target machine is
  12631. referred to as the "inferior" binary.
  12632. For documentation on GDB see the
  12633. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  12634. </para>
  12635. <para>
  12636. The following steps show you how to debug using the GNU project
  12637. debugger.
  12638. <orderedlist>
  12639. <listitem><para>
  12640. <emphasis>Configure your build system to construct the
  12641. companion debug filesystem:</emphasis></para>
  12642. <para>In your <filename>local.conf</filename> file, set
  12643. the following:
  12644. <literallayout class='monospaced'>
  12645. IMAGE_GEN_DEBUGFS = "1"
  12646. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  12647. </literallayout>
  12648. These options cause the OpenEmbedded build system
  12649. to generate a special companion filesystem fragment,
  12650. which contains the matching source and debug symbols to
  12651. your deployable filesystem.
  12652. The build system does this by looking at what is in the
  12653. deployed filesystem, and pulling the corresponding
  12654. <filename>-dbg</filename> packages.</para>
  12655. <para>The companion debug filesystem is not a complete
  12656. filesystem, but only contains the debug fragments.
  12657. This filesystem must be combined with the full filesystem
  12658. for debugging.
  12659. Subsequent steps in this procedure show how to combine
  12660. the partial filesystem with the full filesystem.
  12661. </para></listitem>
  12662. <listitem><para>
  12663. <emphasis>Configure the system to include gdbserver in
  12664. the target filesystem:</emphasis></para>
  12665. <para>Make the following addition in either your
  12666. <filename>local.conf</filename> file or in an image
  12667. recipe:
  12668. <literallayout class='monospaced'>
  12669. IMAGE_INSTALL_append = “ gdbserver"
  12670. </literallayout>
  12671. The change makes sure the <filename>gdbserver</filename>
  12672. package is included.
  12673. </para></listitem>
  12674. <listitem><para>
  12675. <emphasis>Build the environment:</emphasis></para>
  12676. <para>Use the following command to construct the image
  12677. and the companion Debug Filesystem:
  12678. <literallayout class='monospaced'>
  12679. $ bitbake <replaceable>image</replaceable>
  12680. </literallayout>
  12681. Build the cross GDB component and make it available
  12682. for debugging.
  12683. Build the SDK that matches the image.
  12684. Building the SDK is best for a production build
  12685. that can be used later for debugging, especially
  12686. during long term maintenance:
  12687. <literallayout class='monospaced'>
  12688. $ bitbake -c populate_sdk <replaceable>image</replaceable>
  12689. </literallayout></para>
  12690. <para>Alternatively, you can build the minimal
  12691. toolchain components that match the target.
  12692. Doing so creates a smaller than typical SDK and only
  12693. contains a minimal set of components with which to
  12694. build simple test applications, as well as run the
  12695. debugger:
  12696. <literallayout class='monospaced'>
  12697. $ bitbake meta-toolchain
  12698. </literallayout></para>
  12699. <para>A final method is to build Gdb itself within
  12700. the build system:
  12701. <literallayout class='monospaced'>
  12702. $ bitbake gdb-cross-<replaceable>architecture</replaceable>
  12703. </literallayout>
  12704. Doing so produces a temporary copy of
  12705. <filename>cross-gdb</filename> you can use for
  12706. debugging during development.
  12707. While this is the quickest approach, the two previous
  12708. methods in this step are better when considering
  12709. long-term maintenance strategies.
  12710. <note>
  12711. If you run
  12712. <filename>bitbake gdb-cross</filename>, the
  12713. OpenEmbedded build system suggests the actual
  12714. image (e.g. <filename>gdb-cross-i586</filename>).
  12715. The suggestion is usually the actual name you want
  12716. to use.
  12717. </note>
  12718. </para></listitem>
  12719. <listitem><para>
  12720. <emphasis>Set up the</emphasis>&nbsp;<filename>debugfs</filename></para>
  12721. <para>Run the following commands to set up the
  12722. <filename>debugfs</filename>:
  12723. <literallayout class='monospaced'>
  12724. $ mkdir debugfs
  12725. $ cd debugfs
  12726. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2
  12727. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2
  12728. </literallayout>
  12729. </para></listitem>
  12730. <listitem><para>
  12731. <emphasis>Set up GDB</emphasis></para>
  12732. <para>Install the SDK (if you built one) and then
  12733. source the correct environment file.
  12734. Sourcing the environment file puts the SDK in your
  12735. <filename>PATH</filename> environment variable.</para>
  12736. <para>If you are using the build system, Gdb is
  12737. located in
  12738. <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb
  12739. </para></listitem>
  12740. <listitem><para>
  12741. <emphasis>Boot the target:</emphasis></para>
  12742. <para>For information on how to run QEMU, see the
  12743. <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>.
  12744. <note>
  12745. Be sure to verify that your host can access the
  12746. target via TCP.
  12747. </note>
  12748. </para></listitem>
  12749. <listitem><para>
  12750. <emphasis>Debug a program:</emphasis></para>
  12751. <para>Debugging a program involves running gdbserver
  12752. on the target and then running Gdb on the host.
  12753. The example in this step debugs
  12754. <filename>gzip</filename>:
  12755. <literallayout class='monospaced'>
  12756. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  12757. </literallayout>
  12758. For additional gdbserver options, see the
  12759. <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>.
  12760. </para>
  12761. <para>After running gdbserver on the target, you need
  12762. to run Gdb on the host and configure it and connect to
  12763. the target.
  12764. Use these commands:
  12765. <literallayout class='monospaced'>
  12766. $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable>
  12767. $ <replaceable>arch</replaceable>-gdb
  12768. (gdb) set sysroot debugfs
  12769. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  12770. (gdb) target remote <replaceable>IP-of-target</replaceable>:1234
  12771. </literallayout>
  12772. At this point, everything should automatically load
  12773. (i.e. matching binaries, symbols and headers).
  12774. <note>
  12775. The Gdb <filename>set</filename> commands in the
  12776. previous example can be placed into the users
  12777. <filename>~/.gdbinit</filename> file.
  12778. Upon starting, Gdb automatically runs whatever
  12779. commands are in that file.
  12780. </note>
  12781. </para></listitem>
  12782. <listitem><para>
  12783. <emphasis>Deploying without a full image
  12784. rebuild:</emphasis></para>
  12785. <para>In many cases, during development you want a
  12786. quick method to deploy a new binary to the target and
  12787. debug it, without waiting for a full image build.
  12788. </para>
  12789. <para>One approach to solving this situation is to
  12790. just build the component you want to debug.
  12791. Once you have built the component, copy the
  12792. executable directly to both the target and the
  12793. host <filename>debugfs</filename>.</para>
  12794. <para>If the binary is processed through the debug
  12795. splitting in OpenEmbedded, you should also
  12796. copy the debug items (i.e. <filename>.debug</filename>
  12797. contents and corresponding
  12798. <filename>/usr/src/debug</filename> files)
  12799. from the work directory.
  12800. Here is an example:
  12801. <literallayout class='monospaced'>
  12802. $ bitbake bash
  12803. $ bitbake -c devshell bash
  12804. $ cd ..
  12805. $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash
  12806. $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs
  12807. </literallayout>
  12808. </para></listitem>
  12809. </orderedlist>
  12810. </para>
  12811. </section>
  12812. <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>
  12813. <title>Debugging with the GNU Project Debugger (GDB) on the Target</title>
  12814. <para>
  12815. The previous section addressed using GDB remotely for debugging
  12816. purposes, which is the most usual case due to the inherent
  12817. hardware limitations on many embedded devices.
  12818. However, debugging in the target hardware itself is also
  12819. possible with more powerful devices.
  12820. This section describes what you need to do in order to support
  12821. using GDB to debug on the target hardware.
  12822. </para>
  12823. <para>
  12824. To support this kind of debugging, you need do the following:
  12825. <itemizedlist>
  12826. <listitem><para>
  12827. Ensure that GDB is on the target.
  12828. You can do this by adding "gdb" to
  12829. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  12830. <literallayout class='monospaced'>
  12831. IMAGE_INSTALL_append = " gdb"
  12832. </literallayout>
  12833. Alternatively, you can add "tools-debug" to
  12834. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  12835. <literallayout class='monospaced'>
  12836. IMAGE_FEATURES_append = " tools-debug"
  12837. </literallayout>
  12838. </para></listitem>
  12839. <listitem><para>
  12840. Ensure that debug symbols are present.
  12841. You can make sure these symbols are present by
  12842. installing <filename>-dbg</filename>:
  12843. <literallayout class='monospaced'>
  12844. IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg"
  12845. </literallayout>
  12846. Alternatively, you can do the following to include all
  12847. the debug symbols:
  12848. <literallayout class='monospaced'>
  12849. IMAGE_FEATURES_append = " dbg-pkgs"
  12850. </literallayout>
  12851. </para></listitem>
  12852. </itemizedlist>
  12853. <note>
  12854. To improve the debug information accuracy, you can reduce
  12855. the level of optimization used by the compiler.
  12856. For example, when adding the following line to your
  12857. <filename>local.conf</filename> file, you will reduce
  12858. optimization from
  12859. <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink>
  12860. of "-O2" to
  12861. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink>
  12862. of "-O -fno-omit-frame-pointer":
  12863. <literallayout class='monospaced'>
  12864. DEBUG_BUILD = "1"
  12865. </literallayout>
  12866. Consider that this will reduce the application's performance
  12867. and is recommended only for debugging purposes.
  12868. </note>
  12869. </para>
  12870. </section>
  12871. <section id='dev-other-debugging-others'>
  12872. <title>Other Debugging Tips</title>
  12873. <para>
  12874. Here are some other tips that you might find useful:
  12875. <itemizedlist>
  12876. <listitem><para>
  12877. When adding new packages, it is worth watching for
  12878. undesirable items making their way into compiler command
  12879. lines.
  12880. For example, you do not want references to local system
  12881. files like
  12882. <filename>/usr/lib/</filename> or
  12883. <filename>/usr/include/</filename>.
  12884. </para></listitem>
  12885. <listitem><para>
  12886. If you want to remove the <filename>psplash</filename>
  12887. boot splashscreen,
  12888. add <filename>psplash=false</filename> to the kernel
  12889. command line.
  12890. Doing so prevents <filename>psplash</filename> from
  12891. loading and thus allows you to see the console.
  12892. It is also possible to switch out of the splashscreen by
  12893. switching the virtual console (e.g. Fn+Left or Fn+Right
  12894. on a Zaurus).
  12895. </para></listitem>
  12896. <listitem><para>
  12897. Removing
  12898. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  12899. (usually <filename>tmp/</filename>, within the
  12900. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>)
  12901. can often fix temporary build issues.
  12902. Removing <filename>TMPDIR</filename> is usually a
  12903. relatively cheap operation, because task output will be
  12904. cached in
  12905. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  12906. (usually <filename>sstate-cache/</filename>, which is
  12907. also in the Build Directory).
  12908. <note>
  12909. Removing <filename>TMPDIR</filename> might be a
  12910. workaround rather than a fix.
  12911. Consequently, trying to determine the underlying
  12912. cause of an issue before removing the directory is
  12913. a good idea.
  12914. </note>
  12915. </para></listitem>
  12916. <listitem><para>
  12917. Understanding how a feature is used in practice within
  12918. existing recipes can be very helpful.
  12919. It is recommended that you configure some method that
  12920. allows you to quickly search through files.</para>
  12921. <para>Using GNU Grep, you can use the following shell
  12922. function to recursively search through common
  12923. recipe-related files, skipping binary files,
  12924. <filename>.git</filename> directories, and the
  12925. Build Directory (assuming its name starts with
  12926. "build"):
  12927. <literallayout class='monospaced'>
  12928. g() {
  12929. grep -Ir \
  12930. --exclude-dir=.git \
  12931. --exclude-dir='build*' \
  12932. --include='*.bb*' \
  12933. --include='*.inc*' \
  12934. --include='*.conf*' \
  12935. --include='*.py*' \
  12936. "$@"
  12937. }
  12938. </literallayout>
  12939. Following are some usage examples:
  12940. <literallayout class='monospaced'>
  12941. $ g FOO # Search recursively for "FOO"
  12942. $ g -i foo # Search recursively for "foo", ignoring case
  12943. $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
  12944. </literallayout>
  12945. If figuring out how some feature works requires a lot of
  12946. searching, it might indicate that the documentation
  12947. should be extended or improved.
  12948. In such cases, consider filing a documentation bug using
  12949. the Yocto Project implementation of
  12950. <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>.
  12951. For information on how to submit a bug against
  12952. the Yocto Project, see the Yocto Project Bugzilla
  12953. <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink>
  12954. and the
  12955. "<link linkend='submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</link>"
  12956. section.
  12957. <note>
  12958. The manuals might not be the right place to document
  12959. variables that are purely internal and have a
  12960. limited scope (e.g. internal variables used to
  12961. implement a single <filename>.bbclass</filename>
  12962. file).
  12963. </note>
  12964. </para></listitem>
  12965. </itemizedlist>
  12966. </para>
  12967. </section>
  12968. </section>
  12969. <section id='making-changes-to-the-yocto-project'>
  12970. <title>Making Changes to the Yocto Project</title>
  12971. <para>
  12972. Because the Yocto Project is an open-source, community-based
  12973. project, you can effect changes to the project.
  12974. This section presents procedures that show you how to submit
  12975. a defect against the project and how to submit a change.
  12976. </para>
  12977. <section id='submitting-a-defect-against-the-yocto-project'>
  12978. <title>Submitting a Defect Against the Yocto Project</title>
  12979. <para>
  12980. Use the Yocto Project implementation of
  12981. <ulink url='http://www.bugzilla.org/about/'>Bugzilla</ulink>
  12982. to submit a defect (bug) against the Yocto Project.
  12983. For additional information on this implementation of Bugzilla see the
  12984. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-bugtracker'>Yocto Project Bugzilla</ulink>"
  12985. section in the Yocto Project Reference Manual.
  12986. For more detail on any of the following steps, see the Yocto Project
  12987. <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>Bugzilla wiki page</ulink>.
  12988. </para>
  12989. <para>
  12990. Use the following general steps to submit a bug"
  12991. <orderedlist>
  12992. <listitem><para>
  12993. Open the Yocto Project implementation of
  12994. <ulink url='&YOCTO_BUGZILLA_URL;'>Bugzilla</ulink>.
  12995. </para></listitem>
  12996. <listitem><para>
  12997. Click "File a Bug" to enter a new bug.
  12998. </para></listitem>
  12999. <listitem><para>
  13000. Choose the appropriate "Classification", "Product", and
  13001. "Component" for which the bug was found.
  13002. Bugs for the Yocto Project fall into one of several
  13003. classifications, which in turn break down into several
  13004. products and components.
  13005. For example, for a bug against the
  13006. <filename>meta-intel</filename> layer, you would choose
  13007. "Build System, Metadata &amp; Runtime", "BSPs", and
  13008. "bsps-meta-intel", respectively.
  13009. </para></listitem>
  13010. <listitem><para>
  13011. Choose the "Version" of the Yocto Project for which you found
  13012. the bug (e.g. &DISTRO;).
  13013. </para></listitem>
  13014. <listitem><para>
  13015. Determine and select the "Severity" of the bug.
  13016. The severity indicates how the bug impacted your work.
  13017. </para></listitem>
  13018. <listitem><para>
  13019. Choose the "Hardware" that the bug impacts.
  13020. </para></listitem>
  13021. <listitem><para>
  13022. Choose the "Architecture" that the bug impacts.
  13023. </para></listitem>
  13024. <listitem><para>
  13025. Choose a "Documentation change" item for the bug.
  13026. Fixing a bug might or might not affect the Yocto Project
  13027. documentation.
  13028. If you are unsure of the impact to the documentation, select
  13029. "Don't Know".
  13030. </para></listitem>
  13031. <listitem><para>
  13032. Provide a brief "Summary" of the bug.
  13033. Try to limit your summary to just a line or two and be sure
  13034. to capture the essence of the bug.
  13035. </para></listitem>
  13036. <listitem><para>
  13037. Provide a detailed "Description" of the bug.
  13038. You should provide as much detail as you can about the context,
  13039. behavior, output, and so forth that surrounds the bug.
  13040. You can even attach supporting files for output from logs by
  13041. using the "Add an attachment" button.
  13042. </para></listitem>
  13043. <listitem><para>
  13044. Click the "Submit Bug" button submit the bug.
  13045. A new Bugzilla number is assigned to the bug and the defect
  13046. is logged in the bug tracking system.
  13047. </para></listitem>
  13048. </orderedlist>
  13049. Once you file a bug, the bug is processed by the Yocto Project Bug
  13050. Triage Team and further details concerning the bug are assigned
  13051. (e.g. priority and owner).
  13052. You are the "Submitter" of the bug and any further categorization,
  13053. progress, or comments on the bug result in Bugzilla sending you an
  13054. automated email concerning the particular change or progress to the
  13055. bug.
  13056. </para>
  13057. </section>
  13058. <section id='how-to-submit-a-change'>
  13059. <title>Submitting a Change to the Yocto Project</title>
  13060. <para>
  13061. Contributions to the Yocto Project and OpenEmbedded are very welcome.
  13062. Because the system is extremely configurable and flexible, we recognize
  13063. that developers will want to extend, configure or optimize it for
  13064. their specific uses.
  13065. </para>
  13066. <para>
  13067. The Yocto Project uses a mailing list and a patch-based workflow
  13068. that is similar to the Linux kernel but contains important
  13069. differences.
  13070. In general, a mailing list exists through which you can submit
  13071. patches.
  13072. You should send patches to the appropriate mailing list so that they
  13073. can be reviewed and merged by the appropriate maintainer.
  13074. The specific mailing list you need to use depends on the
  13075. location of the code you are changing.
  13076. Each component (e.g. layer) should have a
  13077. <filename>README</filename> file that indicates where to send
  13078. the changes and which process to follow.
  13079. </para>
  13080. <para>
  13081. You can send the patch to the mailing list using whichever approach
  13082. you feel comfortable with to generate the patch.
  13083. Once sent, the patch is usually reviewed by the community at large.
  13084. If somebody has concerns with the patch, they will usually voice
  13085. their concern over the mailing list.
  13086. If a patch does not receive any negative reviews, the maintainer of
  13087. the affected layer typically takes the patch, tests it, and then
  13088. based on successful testing, merges the patch.
  13089. </para>
  13090. <para id='figuring-out-the-mailing-list-to-use'>
  13091. The "poky" repository, which is the Yocto Project's reference build
  13092. environment, is a hybrid repository that contains several
  13093. individual pieces (e.g. BitBake, Metadata, documentation,
  13094. and so forth) built using the combo-layer tool.
  13095. The upstream location used for submitting changes varies by
  13096. component:
  13097. <itemizedlist>
  13098. <listitem><para>
  13099. <emphasis>Core Metadata:</emphasis>
  13100. Send your patch to the
  13101. <ulink url='http://lists.openembedded.org/mailman/listinfo/openembedded-core'>openembedded-core</ulink>
  13102. mailing list. For example, a change to anything under
  13103. the <filename>meta</filename> or
  13104. <filename>scripts</filename> directories should be sent
  13105. to this mailing list.
  13106. </para></listitem>
  13107. <listitem><para>
  13108. <emphasis>BitBake:</emphasis>
  13109. For changes to BitBake (i.e. anything under the
  13110. <filename>bitbake</filename> directory), send your patch
  13111. to the
  13112. <ulink url='http://lists.openembedded.org/mailman/listinfo/bitbake-devel'>bitbake-devel</ulink>
  13113. mailing list.
  13114. </para></listitem>
  13115. <listitem><para>
  13116. <emphasis>"meta-*" trees:</emphasis>
  13117. These trees contain Metadata.
  13118. Use the
  13119. <ulink url='https://lists.yoctoproject.org/listinfo/poky'>poky</ulink>
  13120. mailing list.
  13121. </para></listitem>
  13122. </itemizedlist>
  13123. </para>
  13124. <para>
  13125. For changes to other layers hosted in the Yocto Project source
  13126. repositories (i.e. <filename>yoctoproject.org</filename>), tools,
  13127. and the Yocto Project documentation, use the
  13128. <ulink url='https://lists.yoctoproject.org/listinfo/yocto'>Yocto Project</ulink>
  13129. general mailing list.
  13130. <note>
  13131. Sometimes a layer's documentation specifies to use a
  13132. particular mailing list.
  13133. If so, use that list.
  13134. </note>
  13135. For additional recipes that do not fit into the core Metadata, you
  13136. should determine which layer the recipe should go into and submit
  13137. the change in the manner recommended by the documentation (e.g.
  13138. the <filename>README</filename> file) supplied with the layer.
  13139. If in doubt, please ask on the Yocto general mailing list or on
  13140. the openembedded-devel mailing list.
  13141. </para>
  13142. <para>
  13143. You can also push a change upstream and request a maintainer to
  13144. pull the change into the component's upstream repository.
  13145. You do this by pushing to a contribution repository that is upstream.
  13146. See the
  13147. "<ulink url='&YOCTO_DOCS_OM_URL;#gs-git-workflows-and-the-yocto-project'>Git Workflows and the Yocto Project</ulink>"
  13148. section in the Yocto Project Overview and Concepts Manual for additional
  13149. concepts on working in the Yocto Project development environment.
  13150. </para>
  13151. <para>
  13152. Two commonly used testing repositories exist for
  13153. OpenEmbedded-Core:
  13154. <itemizedlist>
  13155. <listitem><para>
  13156. <emphasis>"ross/mut" branch:</emphasis>
  13157. The "mut" (master-under-test) tree
  13158. exists in the <filename>poky-contrib</filename> repository
  13159. in the
  13160. <ulink url='&YOCTO_GIT_URL;'>Yocto Project source repositories</ulink>.
  13161. </para></listitem>
  13162. <listitem><para>
  13163. <emphasis>"master-next" branch:</emphasis>
  13164. This branch is part of the main
  13165. "poky" repository in the Yocto Project source repositories.
  13166. </para></listitem>
  13167. </itemizedlist>
  13168. Maintainers use these branches to test submissions prior to merging
  13169. patches.
  13170. Thus, you can get an idea of the status of a patch based on
  13171. whether the patch has been merged into one of these branches.
  13172. <note>
  13173. This system is imperfect and changes can sometimes get lost in the
  13174. flow.
  13175. Asking about the status of a patch or change is reasonable if the
  13176. change has been idle for a while with no feedback.
  13177. The Yocto Project does have plans to use
  13178. <ulink url='https://en.wikipedia.org/wiki/Patchwork_(software)'>Patchwork</ulink>
  13179. to track the status of patches and also to automatically preview
  13180. patches.
  13181. </note>
  13182. </para>
  13183. <para>
  13184. The following sections provide procedures for submitting a change.
  13185. </para>
  13186. <section id='pushing-a-change-upstream'>
  13187. <title>Using Scripts to Push a Change Upstream and Request a Pull</title>
  13188. <para>
  13189. Follow this procedure to push a change to an upstream "contrib"
  13190. Git repository:
  13191. <note>
  13192. You can find general Git information on how to push a change
  13193. upstream in the
  13194. <ulink url='http://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows'>Git Community Book</ulink>.
  13195. </note>
  13196. <orderedlist>
  13197. <listitem><para>
  13198. <emphasis>Make Your Changes Locally:</emphasis>
  13199. Make your changes in your local Git repository.
  13200. You should make small, controlled, isolated changes.
  13201. Keeping changes small and isolated aids review,
  13202. makes merging/rebasing easier and keeps the change
  13203. history clean should anyone need to refer to it in
  13204. future.
  13205. </para></listitem>
  13206. <listitem><para>
  13207. <emphasis>Stage Your Changes:</emphasis>
  13208. Stage your changes by using the <filename>git add</filename>
  13209. command on each file you changed.
  13210. </para></listitem>
  13211. <listitem><para id='making-sure-you-have-correct-commit-information'>
  13212. <emphasis>Commit Your Changes:</emphasis>
  13213. Commit the change by using the
  13214. <filename>git commit</filename> command.
  13215. Make sure your commit information follows standards by
  13216. following these accepted conventions:
  13217. <itemizedlist>
  13218. <listitem><para>
  13219. Be sure to include a "Signed-off-by:" line in the
  13220. same style as required by the Linux kernel.
  13221. Adding this line signifies that you, the submitter,
  13222. have agreed to the Developer's Certificate of
  13223. Origin 1.1 as follows:
  13224. <literallayout class='monospaced'>
  13225. Developer's Certificate of Origin 1.1
  13226. By making a contribution to this project, I certify that:
  13227. (a) The contribution was created in whole or in part by me and I
  13228. have the right to submit it under the open source license
  13229. indicated in the file; or
  13230. (b) The contribution is based upon previous work that, to the best
  13231. of my knowledge, is covered under an appropriate open source
  13232. license and I have the right under that license to submit that
  13233. work with modifications, whether created in whole or in part
  13234. by me, under the same open source license (unless I am
  13235. permitted to submit under a different license), as indicated
  13236. in the file; or
  13237. (c) The contribution was provided directly to me by some other
  13238. person who certified (a), (b) or (c) and I have not modified
  13239. it.
  13240. (d) I understand and agree that this project and the contribution
  13241. are public and that a record of the contribution (including all
  13242. personal information I submit with it, including my sign-off) is
  13243. maintained indefinitely and may be redistributed consistent with
  13244. this project or the open source license(s) involved.
  13245. </literallayout>
  13246. </para></listitem>
  13247. <listitem><para>
  13248. Provide a single-line summary of the change.
  13249. and,
  13250. if more explanation is needed, provide more
  13251. detail in the body of the commit.
  13252. This summary is typically viewable in the
  13253. "shortlist" of changes.
  13254. Thus, providing something short and descriptive
  13255. that gives the reader a summary of the change is
  13256. useful when viewing a list of many commits.
  13257. You should prefix this short description with the
  13258. recipe name (if changing a recipe), or else with
  13259. the short form path to the file being changed.
  13260. </para></listitem>
  13261. <listitem><para>
  13262. For the body of the commit message, provide
  13263. detailed information that describes what you
  13264. changed, why you made the change, and the approach
  13265. you used.
  13266. It might also be helpful if you mention how you
  13267. tested the change.
  13268. Provide as much detail as you can in the body of
  13269. the commit message.
  13270. <note>
  13271. You do not need to provide a more detailed
  13272. explanation of a change if the change is
  13273. minor to the point of the single line
  13274. summary providing all the information.
  13275. </note>
  13276. </para></listitem>
  13277. <listitem><para>
  13278. If the change addresses a specific bug or issue
  13279. that is associated with a bug-tracking ID,
  13280. include a reference to that ID in your detailed
  13281. description.
  13282. For example, the Yocto Project uses a specific
  13283. convention for bug references - any commit that
  13284. addresses a specific bug should use the following
  13285. form for the detailed description.
  13286. Be sure to use the actual bug-tracking ID from
  13287. Bugzilla for
  13288. <replaceable>bug-id</replaceable>:
  13289. <literallayout class='monospaced'>
  13290. Fixes [YOCTO #<replaceable>bug-id</replaceable>]
  13291. <replaceable>detailed description of change</replaceable>
  13292. </literallayout>
  13293. </para></listitem>
  13294. </itemizedlist>
  13295. </para></listitem>
  13296. <listitem><para>
  13297. <emphasis>Push Your Commits to a "Contrib" Upstream:</emphasis>
  13298. If you have arranged for permissions to push to an
  13299. upstream contrib repository, push the change to that
  13300. repository:
  13301. <literallayout class='monospaced'>
  13302. $ git push <replaceable>upstream_remote_repo</replaceable> <replaceable>local_branch_name</replaceable>
  13303. </literallayout>
  13304. For example, suppose you have permissions to push into the
  13305. upstream <filename>meta-intel-contrib</filename>
  13306. repository and you are working in a local branch named
  13307. <replaceable>your_name</replaceable><filename>/README</filename>.
  13308. The following command pushes your local commits to the
  13309. <filename>meta-intel-contrib</filename> upstream
  13310. repository and puts the commit in a branch named
  13311. <replaceable>your_name</replaceable><filename>/README</filename>:
  13312. <literallayout class='monospaced'>
  13313. $ git push meta-intel-contrib <replaceable>your_name</replaceable>/README
  13314. </literallayout>
  13315. </para></listitem>
  13316. <listitem><para id='push-determine-who-to-notify'>
  13317. <emphasis>Determine Who to Notify:</emphasis>
  13318. Determine the maintainer or the mailing list
  13319. that you need to notify for the change.</para>
  13320. <para>Before submitting any change, you need to be sure
  13321. who the maintainer is or what mailing list that you need
  13322. to notify.
  13323. Use either these methods to find out:
  13324. <itemizedlist>
  13325. <listitem><para>
  13326. <emphasis>Maintenance File:</emphasis>
  13327. Examine the <filename>maintainers.inc</filename>
  13328. file, which is located in the
  13329. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  13330. at
  13331. <filename>meta/conf/distro/include</filename>,
  13332. to see who is responsible for code.
  13333. </para></listitem>
  13334. <listitem><para>
  13335. <emphasis>Search by File:</emphasis>
  13336. Using <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>,
  13337. you can enter the following command to bring up a
  13338. short list of all commits against a specific file:
  13339. <literallayout class='monospaced'>
  13340. git shortlog -- <replaceable>filename</replaceable>
  13341. </literallayout>
  13342. Just provide the name of the file for which you
  13343. are interested.
  13344. The information returned is not ordered by history
  13345. but does include a list of everyone who has
  13346. committed grouped by name.
  13347. From the list, you can see who is responsible for
  13348. the bulk of the changes against the file.
  13349. </para></listitem>
  13350. <listitem><para>
  13351. <emphasis>Examine the List of Mailing Lists:</emphasis>
  13352. For a list of the Yocto Project and related mailing
  13353. lists, see the
  13354. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>"
  13355. section in the Yocto Project Reference Manual.
  13356. </para></listitem>
  13357. </itemizedlist>
  13358. </para></listitem>
  13359. <listitem><para>
  13360. <emphasis>Make a Pull Request:</emphasis>
  13361. Notify the maintainer or the mailing list that you have
  13362. pushed a change by making a pull request.</para>
  13363. <para>The Yocto Project provides two scripts that
  13364. conveniently let you generate and send pull requests to the
  13365. Yocto Project.
  13366. These scripts are <filename>create-pull-request</filename>
  13367. and <filename>send-pull-request</filename>.
  13368. You can find these scripts in the
  13369. <filename>scripts</filename> directory within the
  13370. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  13371. (e.g. <filename>~/poky/scripts</filename>).
  13372. </para>
  13373. <para>Using these scripts correctly formats the requests
  13374. without introducing any whitespace or HTML formatting.
  13375. The maintainer that receives your patches either directly
  13376. or through the mailing list needs to be able to save and
  13377. apply them directly from your emails.
  13378. Using these scripts is the preferred method for sending
  13379. patches.</para>
  13380. <para>First, create the pull request.
  13381. For example, the following command runs the script,
  13382. specifies the upstream repository in the contrib directory
  13383. into which you pushed the change, and provides a subject
  13384. line in the created patch files:
  13385. <literallayout class='monospaced'>
  13386. $ ~/poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
  13387. </literallayout>
  13388. Running this script forms
  13389. <filename>*.patch</filename> files in a folder named
  13390. <filename>pull-</filename><replaceable>PID</replaceable>
  13391. in the current directory.
  13392. One of the patch files is a cover letter.</para>
  13393. <para>Before running the
  13394. <filename>send-pull-request</filename> script, you must
  13395. edit the cover letter patch to insert information about
  13396. your change.
  13397. After editing the cover letter, send the pull request.
  13398. For example, the following command runs the script and
  13399. specifies the patch directory and email address.
  13400. In this example, the email address is a mailing list:
  13401. <literallayout class='monospaced'>
  13402. $ ~/poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@yoctoproject.org
  13403. </literallayout>
  13404. You need to follow the prompts as the script is
  13405. interactive.
  13406. <note>
  13407. For help on using these scripts, simply provide the
  13408. <filename>-h</filename> argument as follows:
  13409. <literallayout class='monospaced'>
  13410. $ poky/scripts/create-pull-request -h
  13411. $ poky/scripts/send-pull-request -h
  13412. </literallayout>
  13413. </note>
  13414. </para></listitem>
  13415. </orderedlist>
  13416. </para>
  13417. </section>
  13418. <section id='submitting-a-patch'>
  13419. <title>Using Email to Submit a Patch</title>
  13420. <para>
  13421. You can submit patches without using the
  13422. <filename>create-pull-request</filename> and
  13423. <filename>send-pull-request</filename> scripts described in the
  13424. previous section.
  13425. However, keep in mind, the preferred method is to use the scripts.
  13426. </para>
  13427. <para>
  13428. Depending on the components changed, you need to submit the email
  13429. to a specific mailing list.
  13430. For some guidance on which mailing list to use, see the
  13431. <link linkend='figuring-out-the-mailing-list-to-use'>list</link>
  13432. at the beginning of this section.
  13433. For a description of all the available mailing lists, see the
  13434. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing Lists</ulink>"
  13435. section in the Yocto Project Reference Manual.
  13436. </para>
  13437. <para>
  13438. Here is the general procedure on how to submit a patch through
  13439. email without using the scripts:
  13440. <orderedlist>
  13441. <listitem><para>
  13442. <emphasis>Make Your Changes Locally:</emphasis>
  13443. Make your changes in your local Git repository.
  13444. You should make small, controlled, isolated changes.
  13445. Keeping changes small and isolated aids review,
  13446. makes merging/rebasing easier and keeps the change
  13447. history clean should anyone need to refer to it in
  13448. future.
  13449. </para></listitem>
  13450. <listitem><para>
  13451. <emphasis>Stage Your Changes:</emphasis>
  13452. Stage your changes by using the <filename>git add</filename>
  13453. command on each file you changed.
  13454. </para></listitem>
  13455. <listitem><para>
  13456. <emphasis>Commit Your Changes:</emphasis>
  13457. Commit the change by using the
  13458. <filename>git commit --signoff</filename> command.
  13459. Using the <filename>--signoff</filename> option identifies
  13460. you as the person making the change and also satisfies
  13461. the Developer's Certificate of Origin (DCO) shown earlier.
  13462. </para>
  13463. <para>When you form a commit, you must follow certain
  13464. standards established by the Yocto Project development
  13465. team.
  13466. See
  13467. <link linkend='making-sure-you-have-correct-commit-information'>Step 3</link>
  13468. in the previous section for information on how to
  13469. provide commit information that meets Yocto Project
  13470. commit message standards.
  13471. </para></listitem>
  13472. <listitem><para>
  13473. <emphasis>Format the Commit:</emphasis>
  13474. Format the commit into an email message.
  13475. To format commits, use the
  13476. <filename>git format-patch</filename> command.
  13477. When you provide the command, you must include a revision
  13478. list or a number of patches as part of the command.
  13479. For example, either of these two commands takes your most
  13480. recent single commit and formats it as an email message in
  13481. the current directory:
  13482. <literallayout class='monospaced'>
  13483. $ git format-patch -1
  13484. </literallayout>
  13485. or
  13486. <literallayout class='monospaced'>
  13487. $ git format-patch HEAD~
  13488. </literallayout></para>
  13489. <para>After the command is run, the current directory
  13490. contains a numbered <filename>.patch</filename> file for
  13491. the commit.</para>
  13492. <para>If you provide several commits as part of the
  13493. command, the <filename>git format-patch</filename> command
  13494. produces a series of numbered files in the current
  13495. directory – one for each commit.
  13496. If you have more than one patch, you should also use the
  13497. <filename>--cover</filename> option with the command,
  13498. which generates a cover letter as the first "patch" in
  13499. the series.
  13500. You can then edit the cover letter to provide a
  13501. description for the series of patches.
  13502. For information on the
  13503. <filename>git format-patch</filename> command,
  13504. see <filename>GIT_FORMAT_PATCH(1)</filename> displayed
  13505. using the <filename>man git-format-patch</filename>
  13506. command.
  13507. <note>
  13508. If you are or will be a frequent contributor to the
  13509. Yocto Project or to OpenEmbedded, you might consider
  13510. requesting a contrib area and the necessary associated
  13511. rights.
  13512. </note>
  13513. </para></listitem>
  13514. <listitem><para>
  13515. <emphasis>Import the Files Into Your Mail Client:</emphasis>
  13516. Import the files into your mail client by using the
  13517. <filename>git send-email</filename> command.
  13518. <note>
  13519. In order to use <filename>git send-email</filename>,
  13520. you must have the proper Git packages installed on
  13521. your host.
  13522. For Ubuntu, Debian, and Fedora the package is
  13523. <filename>git-email</filename>.
  13524. </note></para>
  13525. <para>The <filename>git send-email</filename> command
  13526. sends email by using a local or remote Mail Transport Agent
  13527. (MTA) such as <filename>msmtp</filename>,
  13528. <filename>sendmail</filename>, or through a direct
  13529. <filename>smtp</filename> configuration in your Git
  13530. <filename>~/.gitconfig</filename> file.
  13531. If you are submitting patches through email only, it is
  13532. very important that you submit them without any whitespace
  13533. or HTML formatting that either you or your mailer
  13534. introduces.
  13535. The maintainer that receives your patches needs to be able
  13536. to save and apply them directly from your emails.
  13537. A good way to verify that what you are sending will be
  13538. applicable by the maintainer is to do a dry run and send
  13539. them to yourself and then save and apply them as the
  13540. maintainer would.</para>
  13541. <para>The <filename>git send-email</filename> command is
  13542. the preferred method for sending your patches using
  13543. email since there is no risk of compromising whitespace
  13544. in the body of the message, which can occur when you use
  13545. your own mail client.
  13546. The command also has several options that let you
  13547. specify recipients and perform further editing of the
  13548. email message.
  13549. For information on how to use the
  13550. <filename>git send-email</filename> command,
  13551. see <filename>GIT-SEND-EMAIL(1)</filename> displayed using
  13552. the <filename>man git-send-email</filename> command.
  13553. </para></listitem>
  13554. </orderedlist>
  13555. </para>
  13556. </section>
  13557. </section>
  13558. </section>
  13559. <section id='working-with-licenses'>
  13560. <title>Working With Licenses</title>
  13561. <para>
  13562. As mentioned in the
  13563. "<ulink url='&YOCTO_DOCS_OM_URL;#licensing'>Licensing</ulink>"
  13564. section in the Yocto Project Overview and Concepts Manual,
  13565. open source projects are open to the public and they
  13566. consequently have different licensing structures in place.
  13567. This section describes the mechanism by which the
  13568. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  13569. tracks changes to licensing text and covers how to maintain open
  13570. source license compliance during your project's lifecycle.
  13571. The section also describes how to enable commercially licensed
  13572. recipes, which by default are disabled.
  13573. </para>
  13574. <section id="usingpoky-configuring-LIC_FILES_CHKSUM">
  13575. <title>Tracking License Changes</title>
  13576. <para>
  13577. The license of an upstream project might change in the future.
  13578. In order to prevent these changes going unnoticed, the
  13579. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  13580. variable tracks changes to the license text. The checksums are
  13581. validated at the end of the configure step, and if the
  13582. checksums do not match, the build will fail.
  13583. </para>
  13584. <section id="usingpoky-specifying-LIC_FILES_CHKSUM">
  13585. <title>Specifying the <filename>LIC_FILES_CHKSUM</filename> Variable</title>
  13586. <para>
  13587. The <filename>LIC_FILES_CHKSUM</filename>
  13588. variable contains checksums of the license text in the
  13589. source code for the recipe.
  13590. Following is an example of how to specify
  13591. <filename>LIC_FILES_CHKSUM</filename>:
  13592. <literallayout class='monospaced'>
  13593. LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \
  13594. file://licfile1.txt;beginline=5;endline=29;md5=yyyy \
  13595. file://licfile2.txt;endline=50;md5=zzzz \
  13596. ..."
  13597. </literallayout>
  13598. <note><title>Notes</title>
  13599. <itemizedlist>
  13600. <listitem><para>
  13601. When using "beginline" and "endline", realize
  13602. that line numbering begins with one and not
  13603. zero.
  13604. Also, the included lines are inclusive (i.e.
  13605. lines five through and including 29 in the
  13606. previous example for
  13607. <filename>licfile1.txt</filename>).
  13608. </para></listitem>
  13609. <listitem><para>
  13610. When a license check fails, the selected license
  13611. text is included as part of the QA message.
  13612. Using this output, you can determine the exact
  13613. start and finish for the needed license text.
  13614. </para></listitem>
  13615. </itemizedlist>
  13616. </note>
  13617. </para>
  13618. <para>
  13619. The build system uses the
  13620. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  13621. variable as the default directory when searching files
  13622. listed in <filename>LIC_FILES_CHKSUM</filename>.
  13623. The previous example employs the default directory.
  13624. </para>
  13625. <para>
  13626. Consider this next example:
  13627. <literallayout class='monospaced'>
  13628. LIC_FILES_CHKSUM = "file://src/ls.c;beginline=5;endline=16;\
  13629. md5=bb14ed3c4cda583abc85401304b5cd4e"
  13630. LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6"
  13631. </literallayout>
  13632. </para>
  13633. <para>
  13634. The first line locates a file in
  13635. <filename>${S}/src/ls.c</filename> and isolates lines five
  13636. through 16 as license text.
  13637. The second line refers to a file in
  13638. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  13639. </para>
  13640. <para>
  13641. Note that <filename>LIC_FILES_CHKSUM</filename> variable is
  13642. mandatory for all recipes, unless the
  13643. <filename>LICENSE</filename> variable is set to "CLOSED".
  13644. </para>
  13645. </section>
  13646. <section id="usingpoky-LIC_FILES_CHKSUM-explanation-of-syntax">
  13647. <title>Explanation of Syntax</title>
  13648. <para>
  13649. As mentioned in the previous section, the
  13650. <filename>LIC_FILES_CHKSUM</filename> variable lists all
  13651. the important files that contain the license text for the
  13652. source code.
  13653. It is possible to specify a checksum for an entire file,
  13654. or a specific section of a file (specified by beginning and
  13655. ending line numbers with the "beginline" and "endline"
  13656. parameters, respectively).
  13657. The latter is useful for source files with a license
  13658. notice header, README documents, and so forth.
  13659. If you do not use the "beginline" parameter, then it is
  13660. assumed that the text begins on the first line of the file.
  13661. Similarly, if you do not use the "endline" parameter,
  13662. it is assumed that the license text ends with the last
  13663. line of the file.
  13664. </para>
  13665. <para>
  13666. The "md5" parameter stores the md5 checksum of the license
  13667. text.
  13668. If the license text changes in any way as compared to
  13669. this parameter then a mismatch occurs.
  13670. This mismatch triggers a build failure and notifies
  13671. the developer.
  13672. Notification allows the developer to review and address
  13673. the license text changes.
  13674. Also note that if a mismatch occurs during the build,
  13675. the correct md5 checksum is placed in the build log and
  13676. can be easily copied to the recipe.
  13677. </para>
  13678. <para>
  13679. There is no limit to how many files you can specify using
  13680. the <filename>LIC_FILES_CHKSUM</filename> variable.
  13681. Generally, however, every project requires a few
  13682. specifications for license tracking.
  13683. Many projects have a "COPYING" file that stores the
  13684. license information for all the source code files.
  13685. This practice allows you to just track the "COPYING"
  13686. file as long as it is kept up to date.
  13687. <note><title>Tips</title>
  13688. <itemizedlist>
  13689. <listitem><para>
  13690. If you specify an empty or invalid "md5"
  13691. parameter,
  13692. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  13693. returns an md5 mis-match
  13694. error and displays the correct "md5" parameter
  13695. value during the build.
  13696. The correct parameter is also captured in
  13697. the build log.
  13698. </para></listitem>
  13699. <listitem><para>
  13700. If the whole file contains only license text,
  13701. you do not need to use the "beginline" and
  13702. "endline" parameters.
  13703. </para></listitem>
  13704. </itemizedlist>
  13705. </note>
  13706. </para>
  13707. </section>
  13708. </section>
  13709. <section id="enabling-commercially-licensed-recipes">
  13710. <title>Enabling Commercially Licensed Recipes</title>
  13711. <para>
  13712. By default, the OpenEmbedded build system disables
  13713. components that have commercial or other special licensing
  13714. requirements.
  13715. Such requirements are defined on a
  13716. recipe-by-recipe basis through the
  13717. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS'><filename>LICENSE_FLAGS</filename></ulink>
  13718. variable definition in the affected recipe.
  13719. For instance, the
  13720. <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename>
  13721. recipe contains the following statement:
  13722. <literallayout class='monospaced'>
  13723. LICENSE_FLAGS = "commercial"
  13724. </literallayout>
  13725. Here is a slightly more complicated example that contains both
  13726. an explicit recipe name and version (after variable expansion):
  13727. <literallayout class='monospaced'>
  13728. LICENSE_FLAGS = "license_${PN}_${PV}"
  13729. </literallayout>
  13730. In order for a component restricted by a
  13731. <filename>LICENSE_FLAGS</filename> definition to be enabled and
  13732. included in an image, it needs to have a matching entry in the
  13733. global
  13734. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS_WHITELIST'><filename>LICENSE_FLAGS_WHITELIST</filename></ulink>
  13735. variable, which is a variable typically defined in your
  13736. <filename>local.conf</filename> file.
  13737. For example, to enable the
  13738. <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename>
  13739. package, you could add either the string
  13740. "commercial_gst-plugins-ugly" or the more general string
  13741. "commercial" to <filename>LICENSE_FLAGS_WHITELIST</filename>.
  13742. See the
  13743. "<link linkend='license-flag-matching'>License Flag Matching</link>"
  13744. section for a full
  13745. explanation of how <filename>LICENSE_FLAGS</filename> matching
  13746. works.
  13747. Here is the example:
  13748. <literallayout class='monospaced'>
  13749. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly"
  13750. </literallayout>
  13751. Likewise, to additionally enable the package built from the
  13752. recipe containing
  13753. <filename>LICENSE_FLAGS = "license_${PN}_${PV}"</filename>,
  13754. and assuming that the actual recipe name was
  13755. <filename>emgd_1.10.bb</filename>, the following string would
  13756. enable that package as well as the original
  13757. <filename>gst-plugins-ugly</filename> package:
  13758. <literallayout class='monospaced'>
  13759. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10"
  13760. </literallayout>
  13761. As a convenience, you do not need to specify the complete
  13762. license string in the whitelist for every package.
  13763. You can use an abbreviated form, which consists
  13764. of just the first portion or portions of the license
  13765. string before the initial underscore character or characters.
  13766. A partial string will match any license that contains the
  13767. given string as the first portion of its license.
  13768. For example, the following whitelist string will also match
  13769. both of the packages previously mentioned as well as any other
  13770. packages that have licenses starting with "commercial" or
  13771. "license".
  13772. <literallayout class='monospaced'>
  13773. LICENSE_FLAGS_WHITELIST = "commercial license"
  13774. </literallayout>
  13775. </para>
  13776. <section id="license-flag-matching">
  13777. <title>License Flag Matching</title>
  13778. <para>
  13779. License flag matching allows you to control what recipes
  13780. the OpenEmbedded build system includes in the build.
  13781. Fundamentally, the build system attempts to match
  13782. <filename>LICENSE_FLAGS</filename> strings found in recipes
  13783. against <filename>LICENSE_FLAGS_WHITELIST</filename>
  13784. strings found in the whitelist.
  13785. A match causes the build system to include a recipe in the
  13786. build, while failure to find a match causes the build
  13787. system to exclude a recipe.
  13788. </para>
  13789. <para>
  13790. In general, license flag matching is simple.
  13791. However, understanding some concepts will help you
  13792. correctly and effectively use matching.
  13793. </para>
  13794. <para>
  13795. Before a flag
  13796. defined by a particular recipe is tested against the
  13797. contents of the whitelist, the expanded string
  13798. <filename>_${PN}</filename> is appended to the flag.
  13799. This expansion makes each
  13800. <filename>LICENSE_FLAGS</filename> value recipe-specific.
  13801. After expansion, the string is then matched against the
  13802. whitelist.
  13803. Thus, specifying
  13804. <filename>LICENSE_FLAGS = "commercial"</filename>
  13805. in recipe "foo", for example, results in the string
  13806. <filename>"commercial_foo"</filename>.
  13807. And, to create a match, that string must appear in the
  13808. whitelist.
  13809. </para>
  13810. <para>
  13811. Judicious use of the <filename>LICENSE_FLAGS</filename>
  13812. strings and the contents of the
  13813. <filename>LICENSE_FLAGS_WHITELIST</filename> variable
  13814. allows you a lot of flexibility for including or excluding
  13815. recipes based on licensing.
  13816. For example, you can broaden the matching capabilities by
  13817. using license flags string subsets in the whitelist.
  13818. <note>
  13819. When using a string subset, be sure to use the part of
  13820. the expanded string that precedes the appended
  13821. underscore character (e.g.
  13822. <filename>usethispart_1.3</filename>,
  13823. <filename>usethispart_1.4</filename>, and so forth).
  13824. </note>
  13825. For example, simply specifying the string "commercial" in
  13826. the whitelist matches any expanded
  13827. <filename>LICENSE_FLAGS</filename> definition that starts
  13828. with the string "commercial" such as "commercial_foo" and
  13829. "commercial_bar", which are the strings the build system
  13830. automatically generates for hypothetical recipes named
  13831. "foo" and "bar" assuming those recipes simply specify the
  13832. following:
  13833. <literallayout class='monospaced'>
  13834. LICENSE_FLAGS = "commercial"
  13835. </literallayout>
  13836. Thus, you can choose to exhaustively
  13837. enumerate each license flag in the whitelist and
  13838. allow only specific recipes into the image, or
  13839. you can use a string subset that causes a broader range of
  13840. matches to allow a range of recipes into the image.
  13841. </para>
  13842. <para>
  13843. This scheme works even if the
  13844. <filename>LICENSE_FLAGS</filename> string already
  13845. has <filename>_${PN}</filename> appended.
  13846. For example, the build system turns the license flag
  13847. "commercial_1.2_foo" into "commercial_1.2_foo_foo" and
  13848. would match both the general "commercial" and the specific
  13849. "commercial_1.2_foo" strings found in the whitelist, as
  13850. expected.
  13851. </para>
  13852. <para>
  13853. Here are some other scenarios:
  13854. <itemizedlist>
  13855. <listitem><para>
  13856. You can specify a versioned string in the recipe
  13857. such as "commercial_foo_1.2" in a "foo" recipe.
  13858. The build system expands this string to
  13859. "commercial_foo_1.2_foo".
  13860. Combine this license flag with a whitelist that has
  13861. the string "commercial" and you match the flag
  13862. along with any other flag that starts with the
  13863. string "commercial".
  13864. </para></listitem>
  13865. <listitem><para>
  13866. Under the same circumstances, you can use
  13867. "commercial_foo" in the whitelist and the build
  13868. system not only matches "commercial_foo_1.2" but
  13869. also matches any license flag with the string
  13870. "commercial_foo", regardless of the version.
  13871. </para></listitem>
  13872. <listitem><para>
  13873. You can be very specific and use both the
  13874. package and version parts in the whitelist (e.g.
  13875. "commercial_foo_1.2") to specifically match a
  13876. versioned recipe.
  13877. </para></listitem>
  13878. </itemizedlist>
  13879. </para>
  13880. </section>
  13881. <section id="other-variables-related-to-commercial-licenses">
  13882. <title>Other Variables Related to Commercial Licenses</title>
  13883. <para>
  13884. Other helpful variables related to commercial
  13885. license handling exist and are defined in the
  13886. <filename>poky/meta/conf/distro/include/default-distrovars.inc</filename> file:
  13887. <literallayout class='monospaced'>
  13888. COMMERCIAL_AUDIO_PLUGINS ?= ""
  13889. COMMERCIAL_VIDEO_PLUGINS ?= ""
  13890. </literallayout>
  13891. If you want to enable these components, you can do so by
  13892. making sure you have statements similar to the following
  13893. in your <filename>local.conf</filename> configuration file:
  13894. <literallayout class='monospaced'>
  13895. COMMERCIAL_AUDIO_PLUGINS = "gst-plugins-ugly-mad \
  13896. gst-plugins-ugly-mpegaudioparse"
  13897. COMMERCIAL_VIDEO_PLUGINS = "gst-plugins-ugly-mpeg2dec \
  13898. gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse"
  13899. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly commercial_gst-plugins-bad commercial_qmmp"
  13900. </literallayout>
  13901. Of course, you could also create a matching whitelist
  13902. for those components using the more general "commercial"
  13903. in the whitelist, but that would also enable all the
  13904. other packages with <filename>LICENSE_FLAGS</filename>
  13905. containing "commercial", which you may or may not want:
  13906. <literallayout class='monospaced'>
  13907. LICENSE_FLAGS_WHITELIST = "commercial"
  13908. </literallayout>
  13909. </para>
  13910. <para>
  13911. Specifying audio and video plug-ins as part of the
  13912. <filename>COMMERCIAL_AUDIO_PLUGINS</filename> and
  13913. <filename>COMMERCIAL_VIDEO_PLUGINS</filename> statements
  13914. (along with the enabling
  13915. <filename>LICENSE_FLAGS_WHITELIST</filename>) includes the
  13916. plug-ins or components into built images, thus adding
  13917. support for media formats or components.
  13918. </para>
  13919. </section>
  13920. </section>
  13921. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  13922. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  13923. <para>
  13924. One of the concerns for a development organization using open source
  13925. software is how to maintain compliance with various open source
  13926. licensing during the lifecycle of the product.
  13927. While this section does not provide legal advice or
  13928. comprehensively cover all scenarios, it does
  13929. present methods that you can use to
  13930. assist you in meeting the compliance requirements during a software
  13931. release.
  13932. </para>
  13933. <para>
  13934. With hundreds of different open source licenses that the Yocto
  13935. Project tracks, it is difficult to know the requirements of each
  13936. and every license.
  13937. However, the requirements of the major FLOSS licenses can begin
  13938. to be covered by
  13939. assuming that three main areas of concern exist:
  13940. <itemizedlist>
  13941. <listitem><para>Source code must be provided.</para></listitem>
  13942. <listitem><para>License text for the software must be
  13943. provided.</para></listitem>
  13944. <listitem><para>Compilation scripts and modifications to the
  13945. source code must be provided.
  13946. </para></listitem>
  13947. </itemizedlist>
  13948. There are other requirements beyond the scope of these
  13949. three and the methods described in this section
  13950. (e.g. the mechanism through which source code is distributed).
  13951. </para>
  13952. <para>
  13953. As different organizations have different methods of complying with
  13954. open source licensing, this section is not meant to imply that
  13955. there is only one single way to meet your compliance obligations,
  13956. but rather to describe one method of achieving compliance.
  13957. The remainder of this section describes methods supported to meet the
  13958. previously mentioned three requirements.
  13959. Once you take steps to meet these requirements,
  13960. and prior to releasing images, sources, and the build system,
  13961. you should audit all artifacts to ensure completeness.
  13962. <note>
  13963. The Yocto Project generates a license manifest during
  13964. image creation that is located
  13965. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  13966. to assist with any audits.
  13967. </note>
  13968. </para>
  13969. <section id='providing-the-source-code'>
  13970. <title>Providing the Source Code</title>
  13971. <para>
  13972. Compliance activities should begin before you generate the
  13973. final image.
  13974. The first thing you should look at is the requirement that
  13975. tops the list for most compliance groups - providing
  13976. the source.
  13977. The Yocto Project has a few ways of meeting this
  13978. requirement.
  13979. </para>
  13980. <para>
  13981. One of the easiest ways to meet this requirement is
  13982. to provide the entire
  13983. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  13984. used by the build.
  13985. This method, however, has a few issues.
  13986. The most obvious is the size of the directory since it includes
  13987. all sources used in the build and not just the source used in
  13988. the released image.
  13989. It will include toolchain source, and other artifacts, which
  13990. you would not generally release.
  13991. However, the more serious issue for most companies is accidental
  13992. release of proprietary software.
  13993. The Yocto Project provides an
  13994. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  13995. class to help avoid some of these concerns.
  13996. </para>
  13997. <para>
  13998. Before you employ <filename>DL_DIR</filename> or the
  13999. <filename>archiver</filename> class, you need to decide how
  14000. you choose to provide source.
  14001. The source <filename>archiver</filename> class can generate
  14002. tarballs and SRPMs and can create them with various levels of
  14003. compliance in mind.
  14004. </para>
  14005. <para>
  14006. One way of doing this (but certainly not the only way) is to
  14007. release just the source as a tarball.
  14008. You can do this by adding the following to the
  14009. <filename>local.conf</filename> file found in the
  14010. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  14011. <literallayout class='monospaced'>
  14012. INHERIT += "archiver"
  14013. ARCHIVER_MODE[src] = "original"
  14014. </literallayout>
  14015. During the creation of your image, the source from all
  14016. recipes that deploy packages to the image is placed within
  14017. subdirectories of
  14018. <filename>DEPLOY_DIR/sources</filename> based on the
  14019. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  14020. for each recipe.
  14021. Releasing the entire directory enables you to comply with
  14022. requirements concerning providing the unmodified source.
  14023. It is important to note that the size of the directory can
  14024. get large.
  14025. </para>
  14026. <para>
  14027. A way to help mitigate the size issue is to only release
  14028. tarballs for licenses that require the release of
  14029. source.
  14030. Let us assume you are only concerned with GPL code as
  14031. identified by running the following script:
  14032. <literallayout class='monospaced'>
  14033. # Script to archive a subset of packages matching specific license(s)
  14034. # Source and license files are copied into sub folders of package folder
  14035. # Must be run from build folder
  14036. #!/bin/bash
  14037. src_release_dir="source-release"
  14038. mkdir -p $src_release_dir
  14039. for a in tmp/deploy/sources/*; do
  14040. for d in $a/*; do
  14041. # Get package name from path
  14042. p=`basename $d`
  14043. p=${p%-*}
  14044. p=${p%-*}
  14045. # Only archive GPL packages (update *GPL* regex for your license check)
  14046. numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
  14047. if [ $numfiles -gt 1 ]; then
  14048. echo Archiving $p
  14049. mkdir -p $src_release_dir/$p/source
  14050. cp $d/* $src_release_dir/$p/source 2> /dev/null
  14051. mkdir -p $src_release_dir/$p/license
  14052. cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
  14053. fi
  14054. done
  14055. done
  14056. </literallayout>
  14057. At this point, you could create a tarball from the
  14058. <filename>gpl_source_release</filename> directory and
  14059. provide that to the end user.
  14060. This method would be a step toward achieving compliance
  14061. with section 3a of GPLv2 and with section 6 of GPLv3.
  14062. </para>
  14063. </section>
  14064. <section id='providing-license-text'>
  14065. <title>Providing License Text</title>
  14066. <para>
  14067. One requirement that is often overlooked is inclusion
  14068. of license text.
  14069. This requirement also needs to be dealt with prior to
  14070. generating the final image.
  14071. Some licenses require the license text to accompany
  14072. the binary.
  14073. You can achieve this by adding the following to your
  14074. <filename>local.conf</filename> file:
  14075. <literallayout class='monospaced'>
  14076. COPY_LIC_MANIFEST = "1"
  14077. COPY_LIC_DIRS = "1"
  14078. LICENSE_CREATE_PACKAGE = "1"
  14079. </literallayout>
  14080. Adding these statements to the configuration file ensures
  14081. that the licenses collected during package generation
  14082. are included on your image.
  14083. <note>
  14084. <para>Setting all three variables to "1" results in the
  14085. image having two copies of the same license file.
  14086. One copy resides in
  14087. <filename>/usr/share/common-licenses</filename> and
  14088. the other resides in
  14089. <filename>/usr/share/license</filename>.</para>
  14090. <para>The reason for this behavior is because
  14091. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink>
  14092. and
  14093. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink>
  14094. add a copy of the license when the image is built but do
  14095. not offer a path for adding licenses for newly installed
  14096. packages to an image.
  14097. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink>
  14098. adds a separate package and an upgrade path for adding
  14099. licenses to an image.</para>
  14100. </note>
  14101. </para>
  14102. <para>
  14103. As the source <filename>archiver</filename> class has already
  14104. archived the original
  14105. unmodified source that contains the license files,
  14106. you would have already met the requirements for inclusion
  14107. of the license information with source as defined by the GPL
  14108. and other open source licenses.
  14109. </para>
  14110. </section>
  14111. <section id='providing-compilation-scripts-and-source-code-modifications'>
  14112. <title>Providing Compilation Scripts and Source Code Modifications</title>
  14113. <para>
  14114. At this point, we have addressed all we need to
  14115. prior to generating the image.
  14116. The next two requirements are addressed during the final
  14117. packaging of the release.
  14118. </para>
  14119. <para>
  14120. By releasing the version of the OpenEmbedded build system
  14121. and the layers used during the build, you will be providing both
  14122. compilation scripts and the source code modifications in one
  14123. step.
  14124. </para>
  14125. <para>
  14126. If the deployment team has a
  14127. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  14128. and a distro layer, and those those layers are used to patch,
  14129. compile, package, or modify (in any way) any open source
  14130. software included in your released images, you
  14131. might be required to release those layers under section 3 of
  14132. GPLv2 or section 1 of GPLv3.
  14133. One way of doing that is with a clean
  14134. checkout of the version of the Yocto Project and layers used
  14135. during your build.
  14136. Here is an example:
  14137. <literallayout class='monospaced'>
  14138. # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo
  14139. $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky
  14140. $ cd poky
  14141. # We built using the release_branch for our layers
  14142. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  14143. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  14144. # clean up the .git repos
  14145. $ find . -name ".git" -type d -exec rm -rf {} \;
  14146. </literallayout>
  14147. One thing a development organization might want to consider
  14148. for end-user convenience is to modify
  14149. <filename>meta-poky/conf/bblayers.conf.sample</filename> to
  14150. ensure that when the end user utilizes the released build
  14151. system to build an image, the development organization's
  14152. layers are included in the <filename>bblayers.conf</filename>
  14153. file automatically:
  14154. <literallayout class='monospaced'>
  14155. # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
  14156. # changes incompatibly
  14157. POKY_BBLAYERS_CONF_VERSION = "2"
  14158. BBPATH = "${TOPDIR}"
  14159. BBFILES ?= ""
  14160. BBLAYERS ?= " \
  14161. ##OEROOT##/meta \
  14162. ##OEROOT##/meta-poky \
  14163. ##OEROOT##/meta-yocto-bsp \
  14164. ##OEROOT##/meta-mylayer \
  14165. "
  14166. </literallayout>
  14167. Creating and providing an archive of the
  14168. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  14169. layers (recipes, configuration files, and so forth)
  14170. enables you to meet your
  14171. requirements to include the scripts to control compilation
  14172. as well as any modifications to the original source.
  14173. </para>
  14174. </section>
  14175. </section>
  14176. <section id='copying-licenses-that-do-not-exist'>
  14177. <title>Copying Licenses that Do Not Exist</title>
  14178. <para>
  14179. Some packages, such as the linux-firmware package, have many
  14180. licenses that are not in any way common.
  14181. You can avoid adding a lot of these types of common license
  14182. files, which are only applicable to a specific package, by using
  14183. the
  14184. <ulink url='&YOCTO_DOCS_REF_URL;#var-NO_GENERIC_LICENSE'><filename>NO_GENERIC_LICENSE</filename></ulink>
  14185. variable.
  14186. Using this variable also avoids QA errors when you use a
  14187. non-common, non-CLOSED license in a recipe.
  14188. </para>
  14189. <para>
  14190. The following is an example that uses the
  14191. <filename>LICENSE.Abilis.txt</filename>
  14192. file as the license from the fetched source:
  14193. <literallayout class='monospaced'>
  14194. NO_GENERIC_LICENSE[Firmware-Abilis] = "LICENSE.Abilis.txt"
  14195. </literallayout>
  14196. </para>
  14197. </section>
  14198. </section>
  14199. <section id='using-the-error-reporting-tool'>
  14200. <title>Using the Error Reporting Tool</title>
  14201. <para>
  14202. The error reporting tool allows you to
  14203. submit errors encountered during builds to a central database.
  14204. Outside of the build environment, you can use a web interface to
  14205. browse errors, view statistics, and query for errors.
  14206. The tool works using a client-server system where the client
  14207. portion is integrated with the installed Yocto Project
  14208. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  14209. (e.g. <filename>poky</filename>).
  14210. The server receives the information collected and saves it in a
  14211. database.
  14212. </para>
  14213. <para>
  14214. A live instance of the error reporting server exists at
  14215. <ulink url='http://errors.yoctoproject.org'></ulink>.
  14216. This server exists so that when you want to get help with
  14217. build failures, you can submit all of the information on the
  14218. failure easily and then point to the URL in your bug report
  14219. or send an email to the mailing list.
  14220. <note>
  14221. If you send error reports to this server, the reports become
  14222. publicly visible.
  14223. </note>
  14224. </para>
  14225. <section id='enabling-and-using-the-tool'>
  14226. <title>Enabling and Using the Tool</title>
  14227. <para>
  14228. By default, the error reporting tool is disabled.
  14229. You can enable it by inheriting the
  14230. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  14231. class by adding the following statement to the end of
  14232. your <filename>local.conf</filename> file in your
  14233. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  14234. <literallayout class='monospaced'>
  14235. INHERIT += "report-error"
  14236. </literallayout>
  14237. </para>
  14238. <para>
  14239. By default, the error reporting feature stores information in
  14240. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  14241. However, you can specify a directory to use by adding the following
  14242. to your <filename>local.conf</filename> file:
  14243. <literallayout class='monospaced'>
  14244. ERR_REPORT_DIR = "path"
  14245. </literallayout>
  14246. Enabling error reporting causes the build process to collect
  14247. the errors and store them in a file as previously described.
  14248. When the build system encounters an error, it includes a
  14249. command as part of the console output.
  14250. You can run the command to send the error file to the server.
  14251. For example, the following command sends the errors to an
  14252. upstream server:
  14253. <literallayout class='monospaced'>
  14254. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  14255. </literallayout>
  14256. In the previous example, the errors are sent to a public
  14257. database available at
  14258. <ulink url='http://errors.yoctoproject.org'></ulink>, which is
  14259. used by the entire community.
  14260. If you specify a particular server, you can send the errors
  14261. to a different database.
  14262. Use the following command for more information on available
  14263. options:
  14264. <literallayout class='monospaced'>
  14265. $ send-error-report --help
  14266. </literallayout>
  14267. </para>
  14268. <para>
  14269. When sending the error file, you are prompted to review the
  14270. data being sent as well as to provide a name and optional
  14271. email address.
  14272. Once you satisfy these prompts, the command returns a link
  14273. from the server that corresponds to your entry in the database.
  14274. For example, here is a typical link:
  14275. <literallayout class='monospaced'>
  14276. http://errors.yoctoproject.org/Errors/Details/9522/
  14277. </literallayout>
  14278. Following the link takes you to a web interface where you can
  14279. browse, query the errors, and view statistics.
  14280. </para>
  14281. </section>
  14282. <section id='disabling-the-tool'>
  14283. <title>Disabling the Tool</title>
  14284. <para>
  14285. To disable the error reporting feature, simply remove or comment
  14286. out the following statement from the end of your
  14287. <filename>local.conf</filename> file in your
  14288. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  14289. <literallayout class='monospaced'>
  14290. INHERIT += "report-error"
  14291. </literallayout>
  14292. </para>
  14293. </section>
  14294. <section id='setting-up-your-own-error-reporting-server'>
  14295. <title>Setting Up Your Own Error Reporting Server</title>
  14296. <para>
  14297. If you want to set up your own error reporting server, you
  14298. can obtain the code from the Git repository at
  14299. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  14300. Instructions on how to set it up are in the README document.
  14301. </para>
  14302. </section>
  14303. </section>
  14304. <section id="dev-using-wayland-and-weston">
  14305. <title>Using Wayland and Weston</title>
  14306. <para>
  14307. <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)'>Wayland</ulink>
  14308. is a computer display server protocol that
  14309. provides a method for compositing window managers to communicate
  14310. directly with applications and video hardware and expects them to
  14311. communicate with input hardware using other libraries.
  14312. Using Wayland with supporting targets can result in better control
  14313. over graphics frame rendering than an application might otherwise
  14314. achieve.
  14315. </para>
  14316. <para>
  14317. The Yocto Project provides the Wayland protocol libraries and the
  14318. reference
  14319. <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston'>Weston</ulink>
  14320. compositor as part of its release.
  14321. You can find the integrated packages in the
  14322. <filename>meta</filename> layer of the
  14323. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  14324. Specifically, you can find the recipes that build both Wayland
  14325. and Weston at <filename>meta/recipes-graphics/wayland</filename>.
  14326. </para>
  14327. <para>
  14328. You can build both the Wayland and Weston packages for use only
  14329. with targets that accept the
  14330. <ulink url='https://en.wikipedia.org/wiki/Mesa_(computer_graphics)'>Mesa 3D and Direct Rendering Infrastructure</ulink>,
  14331. which is also known as Mesa DRI.
  14332. This implies that you cannot build and use the packages if your
  14333. target uses, for example, the
  14334. <trademark class='registered'>Intel</trademark> Embedded Media
  14335. and Graphics Driver
  14336. (<trademark class='registered'>Intel</trademark> EMGD) that
  14337. overrides Mesa DRI.
  14338. <note>
  14339. Due to lack of EGL support, Weston 1.0.3 will not run
  14340. directly on the emulated QEMU hardware.
  14341. However, this version of Weston will run under X emulation
  14342. without issues.
  14343. </note>
  14344. </para>
  14345. <para>
  14346. This section describes what you need to do to implement Wayland and
  14347. use the Weston compositor when building an image for a supporting
  14348. target.
  14349. </para>
  14350. <section id="enabling-wayland-in-an-image">
  14351. <title>Enabling Wayland in an Image</title>
  14352. <para>
  14353. To enable Wayland, you need to enable it to be built and enable
  14354. it to be included (installed) in the image.
  14355. </para>
  14356. <section id="enable-building">
  14357. <title>Building</title>
  14358. <para>
  14359. To cause Mesa to build the <filename>wayland-egl</filename>
  14360. platform and Weston to build Wayland with Kernel Mode
  14361. Setting
  14362. (<ulink url='https://wiki.archlinux.org/index.php/Kernel_Mode_Setting'>KMS</ulink>)
  14363. support, include the "wayland" flag in the
  14364. <ulink url="&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES"><filename>DISTRO_FEATURES</filename></ulink>
  14365. statement in your <filename>local.conf</filename> file:
  14366. <literallayout class='monospaced'>
  14367. DISTRO_FEATURES_append = " wayland"
  14368. </literallayout>
  14369. <note>
  14370. If X11 has been enabled elsewhere, Weston will build
  14371. Wayland with X11 support
  14372. </note>
  14373. </para>
  14374. </section>
  14375. <section id="enable-installation-in-an-image">
  14376. <title>Installing</title>
  14377. <para>
  14378. To install the Wayland feature into an image, you must
  14379. include the following
  14380. <ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'><filename>CORE_IMAGE_EXTRA_INSTALL</filename></ulink>
  14381. statement in your <filename>local.conf</filename> file:
  14382. <literallayout class='monospaced'>
  14383. CORE_IMAGE_EXTRA_INSTALL += "wayland weston"
  14384. </literallayout>
  14385. </para>
  14386. </section>
  14387. </section>
  14388. <section id="running-weston">
  14389. <title>Running Weston</title>
  14390. <para>
  14391. To run Weston inside X11, enabling it as described earlier and
  14392. building a Sato image is sufficient.
  14393. If you are running your image under Sato, a Weston Launcher
  14394. appears in the "Utility" category.
  14395. </para>
  14396. <para>
  14397. Alternatively, you can run Weston through the command-line
  14398. interpretor (CLI), which is better suited for development work.
  14399. To run Weston under the CLI, you need to do the following after
  14400. your image is built:
  14401. <orderedlist>
  14402. <listitem><para>
  14403. Run these commands to export
  14404. <filename>XDG_RUNTIME_DIR</filename>:
  14405. <literallayout class='monospaced'>
  14406. mkdir -p /tmp/$USER-weston
  14407. chmod 0700 /tmp/$USER-weston
  14408. export XDG_RUNTIME_DIR=/tmp/$USER-weston
  14409. </literallayout>
  14410. </para></listitem>
  14411. <listitem><para>
  14412. Launch Weston in the shell:
  14413. <literallayout class='monospaced'>
  14414. weston
  14415. </literallayout></para></listitem>
  14416. </orderedlist>
  14417. </para>
  14418. </section>
  14419. </section>
  14420. </chapter>
  14421. <!--
  14422. vim: expandtab tw=80 ts=4
  14423. -->